Version Notes
==== v1.2.0 =====
==== New features ====
- Added delivery options to the checkout flow. Customers can now choose where, when and how they want their order shipped when choosing their preferred shipping method.
- Added support for evening delivery, early pickup locations and parcel dispenser locations.
- Added Dutch postcode validation support.
- Added the option to create a parcelware export csv file directly from the Magento backend.
- Added a MijnPakket login feature. Customers who have a MijnPakket account can use this feature to automatically fill in their preferred billing and shipping address.
==== Minor improvements ====
- Refactored the label printing functionality. Shipping labels will now be opened in a separate window from where they may be printed or downloaded.
- Added the option to select where on an A4 page the shipping labels will start printing. This allows you to re-use partially used sticker-sheets.
- Added many new customization options for the shipment grid in the Magento backend.
- Added the ability to view and edit a chosen post office delivery address from the Magento backend.
- Added the option to only show the PostNL Checkout feature to customers who have a MijnPakket account.
- Refactored many sections of the source code to improve readability and extensibility.
- Moved several configuration settings.
- Merged the 'test/live mode' settings of PostNl Checkout and Label Printing & Confirming functionality. There is now a single option to set the entire extension to test or live mode.
- Added the option to upload separate csv files for the PostNL shipping method in 'table rate' configuration.
==== Bug fixes ====
- Fixed an issue where it was not possible to choose to only manually send track & trace information.
- Fixed several typos and translation errors.
==== v1.1.5 =====
==== Bug fixes ====
- Fixed a problem with account validation only using test mode account credentials
- Made a minor security improvement to the notification system.
- Fixed an issue where shipments could not be confirmed if the shipping address did not have an email address.
- Fixed an issue where PostNl Checkout would incorrectly identify a product as being out of stock.
- Fixed an issue where for some shops PostNl Checkout would not function due to incorrect usage of https in an http environment.
==== 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
Release Info
Developer | TIG |
Extension | tig_postnl |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.5 to 1.2.0
- app/code/community/TIG/PostNL/Block/Adminhtml/Carrier/Postnl/Tablerate/Grid.php +58 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/CronNotification.php +32 -27
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/ProductOptions.php +49 -39
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/Create/ShipmentOptions.php +56 -51
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/ShippingStatus.php +43 -35
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/Tab/StatusHistory.php +39 -39
- app/code/community/TIG/PostNL/Block/Adminhtml/Sales/Order/Shipment/View/Tabs.php +31 -29
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form.php +96 -54
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ActivateButton.php +27 -24
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ActivatedFieldHeader.php +39 -33
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Anchor.php +92 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ConfigCheck.php +9 -5
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/InfoBox.php +22 -16
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/Obscure.php +90 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/SplitAddressCheck.php +44 -30
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/SupportTab.php +57 -25
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/TablerateExport.php +82 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/TablerateImport.php +90 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/TextBox/Abstract.php +29 -22
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/ValidateButton.php +25 -24
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Field/WarningBox.php +22 -16
- app/code/community/TIG/PostNL/Block/Adminhtml/System/Config/Form/Fieldset.php +18 -18
- app/code/community/TIG/PostNL/Block/Adminhtml/Template.php +60 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Action.php +97 -61
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Barcode.php +28 -26
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ConfirmDate.php +27 -27
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ConfirmStatus.php +26 -23
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/DeliveryDate.php +80 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ShipmentType.php +106 -53
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ShippingDescription.php +123 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/ShippingPhase.php +20 -20
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Time.php +32 -28
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/Translate.php +19 -19
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Column/Renderer/YesNo.php +23 -23
- app/code/community/TIG/PostNL/Block/Adminhtml/Widget/Grid/Massaction/LabelStartPos.php +51 -0
- app/code/community/TIG/PostNL/Block/Adminhtml/WindowsTheme.php +86 -0
- app/code/community/TIG/PostNL/Block/Checkout/Cart/CheckoutLink.php +47 -18
- app/code/community/TIG/PostNL/Block/Checkout/Cart/Js.php +102 -58
- app/code/community/TIG/PostNL/Block/Checkout/Summary.php +48 -41
- app/code/community/TIG/PostNL/Block/Core/JsTranslate.php +215 -0
- app/code/community/TIG/PostNL/Block/Core/ShippingStatus.php +41 -33
- app/code/community/TIG/PostNL/Block/Core/Template.php +60 -0
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Checkout/AddPhoneNumber.php +124 -0
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Checkout/DeliveryOptions.php +560 -0
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Js.php +70 -0
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Template.php +123 -0
- app/code/community/TIG/PostNL/Block/DeliveryOptions/Theme.php +120 -0
- app/code/community/TIG/PostNL/Block/Mijnpakket/AccountNotification.php +355 -0
- app/code/community/TIG/PostNL/Block/Mijnpakket/Js.php +143 -0
- app/code/community/TIG/PostNL/Block/Mijnpakket/LoginButton.php +216 -0
- app/code/community/TIG/PostNL/Block/Mijnpakket/OrderSuccessJs.php +70 -0
- app/code/community/TIG/PostNL/Exception.php +42 -44
- app/code/community/TIG/PostNL/Helper/AddressValidation.php +400 -0
- app/code/community/TIG/PostNL/Helper/Carrier.php +54 -51
- app/code/community/TIG/PostNL/Helper/Checkout.php +40 -55
- app/code/community/TIG/PostNL/Helper/Cif.php +578 -197
- app/code/community/TIG/PostNL/Helper/Data.php +310 -87
- app/code/community/TIG/PostNL/Helper/DeliveryOptions.php +739 -0
- app/code/community/TIG/PostNL/Helper/Mijnpakket.php +105 -0
- app/code/community/TIG/PostNL/Helper/Parcelware.php +146 -0
- app/code/community/TIG/PostNL/Helper/Webservices.php +59 -86
- app/code/community/TIG/PostNL/Model/AddressValidation/Cendris.php +101 -0
- app/code/community/TIG/PostNL/Model/AddressValidation/Cendris/Abstract.php +113 -0
- app/code/community/TIG/PostNL/Model/AddressValidation/Observer/AddressBook.php +110 -0
- app/code/community/TIG/PostNL/Model/AddressValidation/Observer/OneStepCheckout.php +129 -0
- app/code/community/TIG/PostNL/Model/AddressValidation/Observer/Onepage.php +170 -0
- app/code/community/TIG/PostNL/Model/AddressValidation/System/Config/Backend/ValidateAccount.php +284 -0
- app/code/community/TIG/PostNL/Model/Admin/Logging/Handler/Postnl.php +66 -0
- app/code/community/TIG/PostNL/Model/Admin/Logging/Observer.php +67 -0
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/OrderGrid.php +95 -19
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentGrid.php +338 -75
- app/code/community/TIG/PostNL/Model/Adminhtml/Observer/ShipmentView.php +90 -26
- app/code/community/TIG/PostNL/Model/Adminhtml/System/Config/Source/ShipmentGridColumns.php +33 -17
- app/code/community/TIG/PostNL/Model/{Core → Adminhtml}/System/Config/Source/ShipmentGridMassaction.php +22 -18
- app/code/community/TIG/PostNL/Model/Carrier/Postnl.php +162 -47
- app/code/community/TIG/PostNL/Model/Carrier/Resource/Tablerate.php +152 -0
- app/code/community/TIG/PostNL/Model/Carrier/Resource/Tablerate/Collection.php +53 -0
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Backend/Tablerate.php +50 -0
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Source/RateType.php +17 -17
- app/code/community/TIG/PostNL/Model/Carrier/System/Config/Source/TablerateSource.php +62 -0
- app/code/community/TIG/PostNL/Model/Carrier/Tablerate.php +54 -0
- app/code/community/TIG/PostNL/Model/Checkout/Cif.php +218 -189
- app/code/community/TIG/PostNL/Model/Checkout/Observer/Order.php +29 -25
- app/code/community/TIG/PostNL/Model/Checkout/Observer/Shipment.php +32 -29
- app/code/community/TIG/PostNL/Model/Checkout/Order.php +20 -135
- app/code/community/TIG/PostNL/Model/Checkout/Service.php +972 -868
- app/code/community/TIG/PostNL/Model/Checkout/System/Config/Source/ActivePaymentMethods.php +20 -20
- app/code/community/TIG/PostNL/Model/Checkout/System/Config/Source/CmsPage.php +35 -32
- app/code/community/TIG/PostNL/Model/Core/Cif.php +331 -325
- app/code/community/TIG/PostNL/Model/Core/Cif/Abstract.php +349 -226
- app/code/community/TIG/PostNL/Model/Core/Cif/Exception.php +46 -43
- app/code/community/TIG/PostNL/Model/Core/Label.php +55 -40
- app/code/community/TIG/PostNL/Model/Core/Observer/Barcode.php +62 -37
- app/code/community/TIG/PostNL/Model/Core/Observer/Cron.php +44 -7
- app/code/community/TIG/PostNL/Model/Core/Observer/SaveShipment.php +27 -25
- app/code/community/TIG/PostNL/Model/Core/Order.php +247 -0
- app/code/community/TIG/PostNL/Model/{Checkout → Core}/Resource/Order.php +19 -19
- app/code/community/TIG/PostNL/Model/{Checkout → Core}/Resource/Order/Collection.php +20 -20
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment.php +17 -17
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Barcode.php +16 -16
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Barcode/Collection.php +17 -17
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Collection.php +17 -17
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Label.php +16 -16
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Label/Collection.php +17 -17
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Status/History.php +17 -17
- app/code/community/TIG/PostNL/Model/Core/Resource/Shipment/Status/History/Collection.php +17 -17
- app/code/community/TIG/PostNL/Model/Core/Shipment.php +890 -310
- app/code/community/TIG/PostNL/Model/Core/Shipment/Barcode.php +41 -21
- app/code/community/TIG/PostNL/Model/Core/Shipment/Label.php +31 -21
- app/code/community/TIG/PostNL/Model/Core/Shipment/Process.php +54 -37
- app/code/community/TIG/PostNL/Model/Core/Shipment/Status/History.php +63 -36
- app/code/community/TIG/PostNL/Model/Core/System/Config/Backend/ValidateDefaultOption.php +152 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/AllProductOptions.php +175 -61
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/Attributes.php +24 -20
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/DebugMode.php +16 -16
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/Direction.php +16 -16
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/EuProductOptions.php +4 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/GlobalProductOptions.php +32 -30
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/GlobalpackShipmentType.php +74 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/LabelSize.php +16 -16
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/PakjeGemakProductOptions.php +92 -41
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/PakketautomaatProductOptions.php +113 -0
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/ReferenceType.php +16 -16
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StandardProductOptions.php +111 -52
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StreetField.php +30 -30
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/StreetFieldWithDefault.php +18 -18
- app/code/community/TIG/PostNL/Model/Core/System/Config/Source/WeightUnit.php +18 -18
- app/code/community/TIG/PostNL/Model/DeliveryOptions/Cif.php +394 -0
@@ -0,0 +1,58 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Carrier_Postnl_Tablerate_Grid
|
40 |
+
extends Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* Prepare shipping table rate collection
|
44 |
+
*
|
45 |
+
* @return Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid
|
46 |
+
*/
|
47 |
+
protected function _prepareCollection()
|
48 |
+
{
|
49 |
+
/** @var $collection Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection */
|
50 |
+
$collection = Mage::getResourceModel('postnl_carrier/tablerate_collection');
|
51 |
+
$collection->setConditionFilter($this->getConditionName())
|
52 |
+
->setWebsiteFilter($this->getWebsiteId());
|
53 |
+
|
54 |
+
$this->setCollection($collection);
|
55 |
+
|
56 |
+
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
57 |
+
}
|
58 |
+
}
|
@@ -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.
|
@@ -33,20 +33,25 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_CronNotification extends
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Cron expression for cronjobs working in 'always' cron mode
|
43 |
Â
*/
|
44 |
Â
const ALWAYS_CRON_EXPR = 'always';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* Check to see if the cron is running. This is done by checking if the last executed cron task
|
48 |
Â
* was executed less than 1 hour ago.
|
49 |
-
*
|
50 |
Â
* @return boolean
|
51 |
Â
*/
|
52 |
Â
public function isCronActive()
|
@@ -56,7 +61,7 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends Mage_Adminhtml_Block_A
|
|
56 |
Â
*/
|
57 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
58 |
Â
$readConnection = $coreResource->getConnection('core_read');
|
59 |
-
|
60 |
Â
/**
|
61 |
Â
* Create an array of cronjobs that need to be ignored
|
62 |
Â
*/
|
@@ -66,7 +71,7 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends Mage_Adminhtml_Block_A
|
|
66 |
Â
if (!isset($cronData['schedule']) || !isset($cronData['schedule']['cron_expr'])) {
|
67 |
Â
continue;
|
68 |
Â
}
|
69 |
-
|
70 |
Â
/**
|
71 |
Â
* Cron jobs with the cron_expr 'always' work on a different cron mode
|
72 |
Â
*/
|
@@ -74,13 +79,13 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends Mage_Adminhtml_Block_A
|
|
74 |
Â
$ignoreCronjobs[] = $cronjob;
|
75 |
Â
}
|
76 |
Â
}
|
77 |
-
|
78 |
Â
/**
|
79 |
Â
* Select the last executed cronjob
|
80 |
Â
*/
|
81 |
Â
$select = $readConnection->select();
|
82 |
Â
$select->from($coreResource->getTablename('cron/schedule'), array('MAX(executed_at)'));
|
83 |
-
|
84 |
Â
/**
|
85 |
Â
* Filter out the invalid cronjobs
|
86 |
Â
*/
|
@@ -88,19 +93,19 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends Mage_Adminhtml_Block_A
|
|
88 |
Â
$ignoreCronjobs = implode(',', $ignoreCronjobs);
|
89 |
Â
$select->where('job_code NOT IN (?)', $ignoreCronjobs);
|
90 |
Â
}
|
91 |
-
|
92 |
Â
/**
|
93 |
Â
* Get the last execution time of a PostNL cronjob
|
94 |
Â
*/
|
95 |
Â
$lastExecutionTime = $readConnection->fetchOne($select);
|
96 |
-
|
97 |
Â
/**
|
98 |
Â
* If no execution time was found it means the cron has never run before
|
99 |
Â
*/
|
100 |
Â
if (!$lastExecutionTime) {
|
101 |
Â
return false;
|
102 |
Â
}
|
103 |
-
|
104 |
Â
/**
|
105 |
Â
* Check if the last execution time was more than an hour ago.
|
106 |
Â
* If no crontask has been executed in an hour it's likely that something is wrong.
|
@@ -108,11 +113,11 @@ class TIG_PostNL_Block_Adminhtml_CronNotification extends Mage_Adminhtml_Block_A
|
|
108 |
Â
$currentTimestamp = Mage::getModel('core/date')->gmtTimestamp();
|
109 |
Â
$oneHourAgoTimestamp = strtotime('-1 hour', $currentTimestamp);
|
110 |
Â
$lastExecutionTimestamp = strtotime($lastExecutionTime);
|
111 |
-
|
112 |
Â
if ($lastExecutionTimestamp < $oneHourAgoTimestamp) {
|
113 |
Â
return false;
|
114 |
Â
}
|
115 |
-
|
116 |
Â
return true;
|
117 |
Â
}
|
118 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_CronNotification extends TIG_PostNL_Block_Adminhtml_Template
|
40 |
Â
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_adminhtml_cronnotification';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Cron expression for cronjobs working in 'always' cron mode
|
48 |
Â
*/
|
49 |
Â
const ALWAYS_CRON_EXPR = 'always';
|
50 |
+
|
51 |
Â
/**
|
52 |
Â
* Check to see if the cron is running. This is done by checking if the last executed cron task
|
53 |
Â
* was executed less than 1 hour ago.
|
54 |
+
*
|
55 |
Â
* @return boolean
|
56 |
Â
*/
|
57 |
Â
public function isCronActive()
|
61 |
Â
*/
|
62 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
63 |
Â
$readConnection = $coreResource->getConnection('core_read');
|
64 |
+
|
65 |
Â
/**
|
66 |
Â
* Create an array of cronjobs that need to be ignored
|
67 |
Â
*/
|
71 |
Â
if (!isset($cronData['schedule']) || !isset($cronData['schedule']['cron_expr'])) {
|
72 |
Â
continue;
|
73 |
Â
}
|
74 |
+
|
75 |
Â
/**
|
76 |
Â
* Cron jobs with the cron_expr 'always' work on a different cron mode
|
77 |
Â
*/
|
79 |
Â
$ignoreCronjobs[] = $cronjob;
|
80 |
Â
}
|
81 |
Â
}
|
82 |
+
|
83 |
Â
/**
|
84 |
Â
* Select the last executed cronjob
|
85 |
Â
*/
|
86 |
Â
$select = $readConnection->select();
|
87 |
Â
$select->from($coreResource->getTablename('cron/schedule'), array('MAX(executed_at)'));
|
88 |
+
|
89 |
Â
/**
|
90 |
Â
* Filter out the invalid cronjobs
|
91 |
Â
*/
|
93 |
Â
$ignoreCronjobs = implode(',', $ignoreCronjobs);
|
94 |
Â
$select->where('job_code NOT IN (?)', $ignoreCronjobs);
|
95 |
Â
}
|
96 |
+
|
97 |
Â
/**
|
98 |
Â
* Get the last execution time of a PostNL cronjob
|
99 |
Â
*/
|
100 |
Â
$lastExecutionTime = $readConnection->fetchOne($select);
|
101 |
+
|
102 |
Â
/**
|
103 |
Â
* If no execution time was found it means the cron has never run before
|
104 |
Â
*/
|
105 |
Â
if (!$lastExecutionTime) {
|
106 |
Â
return false;
|
107 |
Â
}
|
108 |
+
|
109 |
Â
/**
|
110 |
Â
* Check if the last execution time was more than an hour ago.
|
111 |
Â
* If no crontask has been executed in an hour it's likely that something is wrong.
|
113 |
Â
$currentTimestamp = Mage::getModel('core/date')->gmtTimestamp();
|
114 |
Â
$oneHourAgoTimestamp = strtotime('-1 hour', $currentTimestamp);
|
115 |
Â
$lastExecutionTimestamp = strtotime($lastExecutionTime);
|
116 |
+
|
117 |
Â
if ($lastExecutionTimestamp < $oneHourAgoTimestamp) {
|
118 |
Â
return false;
|
119 |
Â
}
|
120 |
+
|
121 |
Â
return true;
|
122 |
Â
}
|
123 |
Â
}
|
@@ -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.
|
@@ -33,77 +33,87 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions extends
|
40 |
-
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Get available product options
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function getExtraCoverProductOptions()
|
47 |
Â
{
|
48 |
-
if ($this->
|
49 |
-
return $this->
|
50 |
Â
}
|
51 |
-
|
52 |
Â
$productOptions = Mage::getModel('postnl_core/system_config_source_allProductOptions')
|
53 |
Â
->getExtraCoverOptions(true);
|
54 |
-
|
55 |
Â
$this->setExtraCoverProductOptions($productOptions);
|
56 |
Â
return $productOptions;
|
57 |
Â
}
|
58 |
-
|
59 |
Â
/**
|
60 |
Â
* Get available GlobalPack product option
|
61 |
-
*
|
62 |
Â
* @return string
|
63 |
Â
*/
|
64 |
Â
public function getGlobalPackProductOption()
|
65 |
Â
{
|
66 |
-
if ($this->
|
67 |
-
return $this->
|
68 |
Â
}
|
69 |
-
|
70 |
Â
$globalPackProductOption = Mage::getModel('postnl_core/system_config_source_globalProductOptions')
|
71 |
Â
->getAvailableOptions();
|
72 |
-
|
73 |
Â
if (empty($globalPackProductOption)) {
|
74 |
Â
return '';
|
75 |
Â
}
|
76 |
-
|
77 |
Â
$optionValue = $globalPackProductOption[0]['value'];
|
78 |
Â
$this->setGlobalpackProductOption($optionValue);
|
79 |
Â
return $optionValue;
|
80 |
Â
}
|
81 |
-
|
82 |
Â
/**
|
83 |
Â
* Gets an array of shipment types for use with GlobalPack shipments
|
84 |
-
*
|
85 |
Â
* @return array
|
86 |
Â
*/
|
87 |
Â
public function getShipmentTypes()
|
88 |
Â
{
|
89 |
Â
$shipmentTypes = Mage::helper('postnl/cif')->getShipmentTypes();
|
90 |
-
|
91 |
Â
return $shipmentTypes;
|
92 |
Â
}
|
93 |
-
|
94 |
Â
/**
|
95 |
Â
* Check if the PostNL module is enabled before rendering
|
96 |
-
*
|
97 |
Â
* @return string | parent::_toHtml()
|
98 |
-
*
|
99 |
Â
* @see Mage_Adminhtml_Block_Abstract::_toHtml()
|
100 |
Â
*/
|
101 |
Â
protected function _toHtml()
|
102 |
-
{
|
103 |
-
if (!Mage::helper('postnl')->isEnabled()) {
|
104 |
-
return '';
|
105 |
Â
}
|
106 |
-
|
107 |
Â
return parent::_toHtml();
|
108 |
Â
}
|
109 |
Â
}
|
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.
|
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 |
+
* @method boolean hasExtraCoverProductOptions()
|
40 |
+
* @method TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions setExtraCoverProductOptions(array $value)
|
41 |
+
* @method boolean hasGlobalpackProductOption()
|
42 |
+
* @method TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions setGlobalpackProductOption(array $value)
|
43 |
Â
*/
|
44 |
+
class TIG_PostNL_Block_Adminhtml_Sales_Order_ProductOptions extends TIG_PostNL_Block_Adminhtml_Template
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $_eventPrefix = 'postnl_adminhtml_sales_order_productoptions';
|
50 |
+
|
51 |
Â
/**
|
52 |
Â
* Get available product options
|
53 |
+
*
|
54 |
Â
* @return array
|
55 |
Â
*/
|
56 |
Â
public function getExtraCoverProductOptions()
|
57 |
Â
{
|
58 |
+
if ($this->hasExtraCoverProductOptions()) {
|
59 |
+
return $this->_getData('extra_cover_product_options');
|
60 |
Â
}
|
61 |
+
|
62 |
Â
$productOptions = Mage::getModel('postnl_core/system_config_source_allProductOptions')
|
63 |
Â
->getExtraCoverOptions(true);
|
64 |
+
|
65 |
Â
$this->setExtraCoverProductOptions($productOptions);
|
66 |
Â
return $productOptions;
|
67 |
Â
}
|
68 |
+
|
69 |
Â
/**
|
70 |
Â
* Get available GlobalPack product option
|
71 |
+
*
|
72 |
Â
* @return string
|
73 |
Â
*/
|
74 |
Â
public function getGlobalPackProductOption()
|
75 |
Â
{
|
76 |
+
if ($this->hasGlobalpackProductOption()) {
|
77 |
+
return $this->_getData('globalpack_product_option');
|
78 |
Â
}
|
79 |
+
|
80 |
Â
$globalPackProductOption = Mage::getModel('postnl_core/system_config_source_globalProductOptions')
|
81 |
Â
->getAvailableOptions();
|
82 |
+
|
83 |
Â
if (empty($globalPackProductOption)) {
|
84 |
Â
return '';
|
85 |
Â
}
|
86 |
+
|
87 |
Â
$optionValue = $globalPackProductOption[0]['value'];
|
88 |
Â
$this->setGlobalpackProductOption($optionValue);
|
89 |
Â
return $optionValue;
|
90 |
Â
}
|
91 |
+
|
92 |
Â
/**
|
93 |
Â
* Gets an array of shipment types for use with GlobalPack shipments
|
94 |
+
*
|
95 |
Â
* @return array
|
96 |
Â
*/
|
97 |
Â
public function getShipmentTypes()
|
98 |
Â
{
|
99 |
Â
$shipmentTypes = Mage::helper('postnl/cif')->getShipmentTypes();
|
100 |
+
|
101 |
Â
return $shipmentTypes;
|
102 |
Â
}
|
103 |
+
|
104 |
Â
/**
|
105 |
Â
* Check if the PostNL module is enabled before rendering
|
106 |
+
*
|
107 |
Â
* @return string | parent::_toHtml()
|
108 |
+
*
|
109 |
Â
* @see Mage_Adminhtml_Block_Abstract::_toHtml()
|
110 |
Â
*/
|
111 |
Â
protected function _toHtml()
|
112 |
+
{
|
113 |
+
if (!Mage::helper('postnl')->isEnabled()) {
|
114 |
+
return '';
|
115 |
Â
}
|
116 |
+
|
117 |
Â
return parent::_toHtml();
|
118 |
Â
}
|
119 |
Â
}
|
@@ -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.
|
@@ -33,14 +33,19 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions extends
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Get current shipment
|
43 |
-
*
|
44 |
Â
* @return Mage_Sales_Model_Order_Shipment
|
45 |
Â
*/
|
46 |
Â
public function getShipment()
|
@@ -48,16 +53,16 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
48 |
Â
if ($this->getData('shipment')) {
|
49 |
Â
return $this->getData('shipment');
|
50 |
Â
}
|
51 |
-
|
52 |
-
$shipment = Mage::registry('current_shipment');
|
53 |
-
|
54 |
Â
$this->setShipment($shipment);
|
55 |
Â
return $shipment;
|
56 |
Â
}
|
57 |
-
|
58 |
Â
/**
|
59 |
Â
* Get available product options for the current shipment
|
60 |
-
*
|
61 |
Â
* @return array
|
62 |
Â
*/
|
63 |
Â
public function getProductOptions()
|
@@ -65,18 +70,18 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
65 |
Â
if ($this->getData('product_options')) {
|
66 |
Â
return $this->getData('product_options');
|
67 |
Â
}
|
68 |
-
|
69 |
Â
$shipment = $this->getShipment();
|
70 |
-
|
71 |
Â
$productOptions = Mage::helper('postnl/cif')->getProductOptionsForShipment($shipment);
|
72 |
-
|
73 |
Â
$this->setProductOptions($productOptions);
|
74 |
Â
return $productOptions;
|
75 |
Â
}
|
76 |
-
|
77 |
Â
/**
|
78 |
Â
* Get the default product option for the current shipment
|
79 |
-
*
|
80 |
Â
* @return string
|
81 |
Â
*/
|
82 |
Â
public function getDefaultProductOption()
|
@@ -84,30 +89,30 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
84 |
Â
if ($this->getData('default_product_option')) {
|
85 |
Â
return $this->getData('default_product_option');
|
86 |
Â
}
|
87 |
-
|
88 |
Â
$shipment = $this->getShipment();
|
89 |
-
|
90 |
Â
$productOption = Mage::helper('postnl/cif')->getDefaultProductOptionForShipment($shipment);
|
91 |
-
|
92 |
Â
$this->setDefaultProductOption($productOption);
|
93 |
Â
return $productOption;
|
94 |
Â
}
|
95 |
-
|
96 |
Â
/**
|
97 |
Â
* Gets an array of shipment types for use with GlobalPack shipments
|
98 |
-
*
|
99 |
Â
* @return array
|
100 |
Â
*/
|
101 |
Â
public function getShipmentTypes()
|
102 |
Â
{
|
103 |
Â
$shipmentTypes = Mage::helper('postnl/cif')->getShipmentTypes();
|
104 |
-
|
105 |
Â
return $shipmentTypes;
|
106 |
Â
}
|
107 |
-
|
108 |
Â
/**
|
109 |
Â
* Check if the current shipment is belgian
|
110 |
-
*
|
111 |
Â
* @return boolean
|
112 |
Â
*/
|
113 |
Â
public function isBelgium()
|
@@ -116,48 +121,48 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions ext
|
|
116 |
Â
if ($shipment->getShippingAddress()->getCountry() == 'BE') {
|
117 |
Â
return true;
|
118 |
Â
}
|
119 |
-
|
120 |
Â
return false;
|
121 |
Â
}
|
122 |
-
|
123 |
Â
/**
|
124 |
Â
* Gets the number of parcels in this shipment based on it's weight
|
125 |
-
*
|
126 |
Â
* @return int
|
127 |
Â
*/
|
128 |
Â
public function getParcelCount()
|
129 |
Â
{
|
130 |
Â
$shipment = $this->getShipment();
|
131 |
-
|
132 |
Â
$parcelCount = Mage::helper('postnl/cif')->getParcelCount($shipment);
|
133 |
Â
return $parcelCount;
|
134 |
Â
}
|
135 |
-
|
136 |
Â
/**
|
137 |
Â
* Do a few checks to see if the template should be rendered before actually rendering it
|
138 |
-
*
|
139 |
Â
* @return string | parent::_toHtml()
|
140 |
-
*
|
141 |
Â
* @see Mage_Adminhtml_Block_Abstract::_toHtml()
|
142 |
Â
*/
|
143 |
Â
protected function _toHtml()
|
144 |
Â
{
|
145 |
Â
$helper = Mage::helper('postnl');
|
146 |
-
if (!$helper->isEnabled()) {
|
147 |
-
return '';
|
148 |
-
}
|
149 |
-
|
150 |
Â
$shipment = $this->getShipment();
|
151 |
-
|
152 |
Â
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
153 |
-
if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
|
154 |
-
return '';
|
155 |
Â
}
|
156 |
-
|
157 |
Â
if (Mage::helper('postnl/cif')->isGlobalShipment($shipment) && !$helper->isGlobalAllowed()) {
|
158 |
Â
return '';
|
159 |
Â
}
|
160 |
-
|
161 |
Â
return parent::_toHtml();
|
162 |
Â
}
|
163 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_Create_ShipmentOptions extends TIG_PostNL_Block_Adminhtml_Template
|
40 |
Â
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_adminhtml_sales_order_shipment_create_shipmentoptions';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Get current shipment
|
48 |
+
*
|
49 |
Â
* @return Mage_Sales_Model_Order_Shipment
|
50 |
Â
*/
|
51 |
Â
public function getShipment()
|
53 |
Â
if ($this->getData('shipment')) {
|
54 |
Â
return $this->getData('shipment');
|
55 |
Â
}
|
56 |
+
|
57 |
+
$shipment = Mage::registry('current_shipment');
|
58 |
+
|
59 |
Â
$this->setShipment($shipment);
|
60 |
Â
return $shipment;
|
61 |
Â
}
|
62 |
+
|
63 |
Â
/**
|
64 |
Â
* Get available product options for the current shipment
|
65 |
+
*
|
66 |
Â
* @return array
|
67 |
Â
*/
|
68 |
Â
public function getProductOptions()
|
70 |
Â
if ($this->getData('product_options')) {
|
71 |
Â
return $this->getData('product_options');
|
72 |
Â
}
|
73 |
+
|
74 |
Â
$shipment = $this->getShipment();
|
75 |
+
|
76 |
Â
$productOptions = Mage::helper('postnl/cif')->getProductOptionsForShipment($shipment);
|
77 |
+
|
78 |
Â
$this->setProductOptions($productOptions);
|
79 |
Â
return $productOptions;
|
80 |
Â
}
|
81 |
+
|
82 |
Â
/**
|
83 |
Â
* Get the default product option for the current shipment
|
84 |
+
*
|
85 |
Â
* @return string
|
86 |
Â
*/
|
87 |
Â
public function getDefaultProductOption()
|
89 |
Â
if ($this->getData('default_product_option')) {
|
90 |
Â
return $this->getData('default_product_option');
|
91 |
Â
}
|
92 |
+
|
93 |
Â
$shipment = $this->getShipment();
|
94 |
+
|
95 |
Â
$productOption = Mage::helper('postnl/cif')->getDefaultProductOptionForShipment($shipment);
|
96 |
+
|
97 |
Â
$this->setDefaultProductOption($productOption);
|
98 |
Â
return $productOption;
|
99 |
Â
}
|
100 |
+
|
101 |
Â
/**
|
102 |
Â
* Gets an array of shipment types for use with GlobalPack shipments
|
103 |
+
*
|
104 |
Â
* @return array
|
105 |
Â
*/
|
106 |
Â
public function getShipmentTypes()
|
107 |
Â
{
|
108 |
Â
$shipmentTypes = Mage::helper('postnl/cif')->getShipmentTypes();
|
109 |
+
|
110 |
Â
return $shipmentTypes;
|
111 |
Â
}
|
112 |
+
|
113 |
Â
/**
|
114 |
Â
* Check if the current shipment is belgian
|
115 |
+
*
|
116 |
Â
* @return boolean
|
117 |
Â
*/
|
118 |
Â
public function isBelgium()
|
121 |
Â
if ($shipment->getShippingAddress()->getCountry() == 'BE') {
|
122 |
Â
return true;
|
123 |
Â
}
|
124 |
+
|
125 |
Â
return false;
|
126 |
Â
}
|
127 |
+
|
128 |
Â
/**
|
129 |
Â
* Gets the number of parcels in this shipment based on it's weight
|
130 |
+
*
|
131 |
Â
* @return int
|
132 |
Â
*/
|
133 |
Â
public function getParcelCount()
|
134 |
Â
{
|
135 |
Â
$shipment = $this->getShipment();
|
136 |
+
|
137 |
Â
$parcelCount = Mage::helper('postnl/cif')->getParcelCount($shipment);
|
138 |
Â
return $parcelCount;
|
139 |
Â
}
|
140 |
+
|
141 |
Â
/**
|
142 |
Â
* Do a few checks to see if the template should be rendered before actually rendering it
|
143 |
+
*
|
144 |
Â
* @return string | parent::_toHtml()
|
145 |
+
*
|
146 |
Â
* @see Mage_Adminhtml_Block_Abstract::_toHtml()
|
147 |
Â
*/
|
148 |
Â
protected function _toHtml()
|
149 |
Â
{
|
150 |
Â
$helper = Mage::helper('postnl');
|
151 |
+
if (!$helper->isEnabled()) {
|
152 |
+
return '';
|
153 |
+
}
|
154 |
+
|
155 |
Â
$shipment = $this->getShipment();
|
156 |
+
|
157 |
Â
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
158 |
+
if (!in_array($shipment->getOrder()->getShippingMethod(), $postnlShippingMethods)) {
|
159 |
+
return '';
|
160 |
Â
}
|
161 |
+
|
162 |
Â
if (Mage::helper('postnl/cif')->isGlobalShipment($shipment) && !$helper->isGlobalAllowed()) {
|
163 |
Â
return '';
|
164 |
Â
}
|
165 |
+
|
166 |
Â
return parent::_toHtml();
|
167 |
Â
}
|
168 |
Â
}
|
@@ -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.
|
@@ -33,32 +33,37 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extends
|
40 |
-
{
|
41 |
-
/**
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
42 |
Â
* Available status classes for the status bar html element
|
43 |
-
*/
|
44 |
Â
const CLASS_UNCONFIRMED = '';
|
45 |
Â
const CLASS_COLLECTION = 'status-collection';
|
46 |
Â
const CLASS_DISTRIBUTION = 'status-distribution';
|
47 |
Â
const CLASS_TRANSIT = 'status-transit';
|
48 |
Â
const CLASS_DELIVERED = 'status-delivered';
|
49 |
Â
const CLASS_NOT_POSTNL = 'hidden';
|
50 |
-
|
51 |
Â
/**
|
52 |
Â
* Get the current shipping status for a shipment
|
53 |
-
*
|
54 |
Â
* @param Mage_Sales_Model_Order_Shipment $shipment
|
55 |
-
*
|
56 |
Â
* @return string
|
57 |
Â
*/
|
58 |
Â
public function getShippingStatus($shipment)
|
59 |
Â
{
|
60 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
61 |
-
|
62 |
Â
/**
|
63 |
Â
* Check if the postnl shipment exists. Otherwise it was probably not shipped using PostNL.
|
64 |
Â
* Even if it was, we would not be able to check the status of it anyway.
|
@@ -66,18 +71,18 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extend
|
|
66 |
Â
if (!$postnlShipment->getId()) {
|
67 |
Â
return self::CLASS_NOT_POSTNL;
|
68 |
Â
}
|
69 |
-
|
70 |
Â
switch ($postnlShipment->getShippingPhase()) {
|
71 |
-
case 1:
|
72 |
Â
$class = self::CLASS_COLLECTION;
|
73 |
Â
break;
|
74 |
-
case 2:
|
75 |
Â
$class = self::CLASS_DISTRIBUTION;
|
76 |
Â
break;
|
77 |
-
case 3:
|
78 |
Â
$class = self::CLASS_TRANSIT;
|
79 |
Â
break;
|
80 |
-
case 4:
|
81 |
Â
$class = self::CLASS_DELIVERED;
|
82 |
Â
break;
|
83 |
Â
default:
|
@@ -86,27 +91,30 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extend
|
|
86 |
Â
}
|
87 |
Â
return $class;
|
88 |
Â
}
|
89 |
-
|
90 |
Â
/**
|
91 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
92 |
-
*
|
93 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
94 |
-
*
|
95 |
Â
* @return boolean
|
96 |
Â
*/
|
97 |
Â
public function isConfirmed($shipment)
|
98 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
99 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
100 |
Â
if ($postnlShipment->getConfirmStatus() == $postnlShipment::CONFIRM_STATUS_CONFIRMED) {
|
101 |
Â
return true;
|
102 |
Â
}
|
103 |
-
|
104 |
Â
return false;
|
105 |
Â
}
|
106 |
-
|
107 |
Â
/**
|
108 |
Â
* Check if the PostNL module is enabled. Otherwise return an empty string.
|
109 |
-
*
|
110 |
Â
* @return string | Mage_Core_Block_Template::_toHtml()
|
111 |
Â
*/
|
112 |
Â
protected function _toHtml()
|
@@ -114,7 +122,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extend
|
|
114 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
115 |
Â
return '';
|
116 |
Â
}
|
117 |
-
|
118 |
Â
return parent::_toHtml();
|
119 |
Â
}
|
120 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_ShippingStatus extends TIG_PostNL_Block_Adminhtml_Template
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_adminhtml_sales_order_shipment_view_shippingstatus';
|
45 |
+
|
46 |
+
/**
|
47 |
Â
* Available status classes for the status bar html element
|
48 |
+
*/
|
49 |
Â
const CLASS_UNCONFIRMED = '';
|
50 |
Â
const CLASS_COLLECTION = 'status-collection';
|
51 |
Â
const CLASS_DISTRIBUTION = 'status-distribution';
|
52 |
Â
const CLASS_TRANSIT = 'status-transit';
|
53 |
Â
const CLASS_DELIVERED = 'status-delivered';
|
54 |
Â
const CLASS_NOT_POSTNL = 'hidden';
|
55 |
+
|
56 |
Â
/**
|
57 |
Â
* Get the current shipping status for a shipment
|
58 |
+
*
|
59 |
Â
* @param Mage_Sales_Model_Order_Shipment $shipment
|
60 |
+
*
|
61 |
Â
* @return string
|
62 |
Â
*/
|
63 |
Â
public function getShippingStatus($shipment)
|
64 |
Â
{
|
65 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
66 |
+
|
67 |
Â
/**
|
68 |
Â
* Check if the postnl shipment exists. Otherwise it was probably not shipped using PostNL.
|
69 |
Â
* Even if it was, we would not be able to check the status of it anyway.
|
71 |
Â
if (!$postnlShipment->getId()) {
|
72 |
Â
return self::CLASS_NOT_POSTNL;
|
73 |
Â
}
|
74 |
+
|
75 |
Â
switch ($postnlShipment->getShippingPhase()) {
|
76 |
+
case 1:
|
77 |
Â
$class = self::CLASS_COLLECTION;
|
78 |
Â
break;
|
79 |
+
case 2:
|
80 |
Â
$class = self::CLASS_DISTRIBUTION;
|
81 |
Â
break;
|
82 |
+
case 3:
|
83 |
Â
$class = self::CLASS_TRANSIT;
|
84 |
Â
break;
|
85 |
+
case 4:
|
86 |
Â
$class = self::CLASS_DELIVERED;
|
87 |
Â
break;
|
88 |
Â
default:
|
91 |
Â
}
|
92 |
Â
return $class;
|
93 |
Â
}
|
94 |
+
|
95 |
Â
/**
|
96 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
97 |
+
*
|
98 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
99 |
+
*
|
100 |
Â
* @return boolean
|
101 |
Â
*/
|
102 |
Â
public function isConfirmed($shipment)
|
103 |
Â
{
|
104 |
+
/**
|
105 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
106 |
+
*/
|
107 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
108 |
Â
if ($postnlShipment->getConfirmStatus() == $postnlShipment::CONFIRM_STATUS_CONFIRMED) {
|
109 |
Â
return true;
|
110 |
Â
}
|
111 |
+
|
112 |
Â
return false;
|
113 |
Â
}
|
114 |
+
|
115 |
Â
/**
|
116 |
Â
* Check if the PostNL module is enabled. Otherwise return an empty string.
|
117 |
+
*
|
118 |
Â
* @return string | Mage_Core_Block_Template::_toHtml()
|
119 |
Â
*/
|
120 |
Â
protected function _toHtml()
|
122 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
123 |
Â
return '';
|
124 |
Â
}
|
125 |
+
|
126 |
Â
return parent::_toHtml();
|
127 |
Â
}
|
128 |
Â
}
|
@@ -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.
|
@@ -33,22 +33,22 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory extends Mage_Adminhtml_Block_Widget_Grid
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Class constructor
|
43 |
-
*
|
44 |
Â
* @return TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory
|
45 |
-
*
|
46 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid::__construct()
|
47 |
Â
*/
|
48 |
Â
public function __construct()
|
49 |
Â
{
|
50 |
Â
parent::__construct();
|
51 |
-
|
52 |
Â
/**
|
53 |
Â
* Set some base variables for this grid
|
54 |
Â
*/
|
@@ -57,44 +57,44 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
57 |
Â
$this->setDefaultSort('timestamp');
|
58 |
Â
$this->setDefaultDir('DESC');
|
59 |
Â
$this->setUseAjax(true);
|
60 |
-
|
61 |
Â
$postnlShipment = Mage::registry('current_postnl_shipment');
|
62 |
Â
$this->setPostnlShipment($postnlShipment);
|
63 |
-
|
64 |
Â
return $this;
|
65 |
Â
}
|
66 |
-
|
67 |
Â
/**
|
68 |
Â
* Get the basic collection for this grid
|
69 |
-
*
|
70 |
Â
* @return TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory
|
71 |
-
*
|
72 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid::_prepareCollection
|
73 |
Â
*/
|
74 |
Â
protected function _prepareCollection()
|
75 |
Â
{
|
76 |
Â
$postnlShipmentId = $this->getPostnlShipment()->getId();
|
77 |
-
|
78 |
Â
$collection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
|
79 |
Â
$collection->addFieldToFilter('parent_id', array('eq' => $postnlShipmentId));
|
80 |
-
|
81 |
Â
$this->setCollection($collection);
|
82 |
Â
|
83 |
Â
parent::_prepareCollection();
|
84 |
Â
return $this;
|
85 |
Â
}
|
86 |
-
|
87 |
Â
/**
|
88 |
Â
* Prepares the grid's columns for rendering
|
89 |
-
*
|
90 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns
|
91 |
-
*
|
92 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid::addColumn()
|
93 |
Â
*/
|
94 |
Â
protected function _prepareColumns()
|
95 |
Â
{
|
96 |
Â
$helper = Mage::helper('postnl');
|
97 |
-
|
98 |
Â
$this->addColumn('date',
|
99 |
Â
array(
|
100 |
Â
'header' => $helper->__('Date'),
|
@@ -105,7 +105,7 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
105 |
Â
'renderer' => 'adminhtml/widget_grid_column_renderer_date',
|
106 |
Â
'filter_time' => true,
|
107 |
Â
));
|
108 |
-
|
109 |
Â
$this->addColumn('timestamp',
|
110 |
Â
array(
|
111 |
Â
'header' => $helper->__('Time'),
|
@@ -116,14 +116,14 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
116 |
Â
'filter' => false,
|
117 |
Â
'sortable' => false,
|
118 |
Â
));
|
119 |
-
|
120 |
Â
$this->addColumn('code',
|
121 |
Â
array(
|
122 |
Â
'header' => $helper->__('Status Code'),
|
123 |
Â
'index' => 'code',
|
124 |
Â
'width' => '100px',
|
125 |
Â
));
|
126 |
-
|
127 |
Â
$this->addColumn('description',
|
128 |
Â
array(
|
129 |
Â
'header' => $helper->__('Description'),
|
@@ -134,23 +134,23 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory ext
|
|
134 |
Â
|
135 |
Â
return parent::_prepareColumns();
|
136 |
Â
}
|
137 |
-
|
138 |
Â
/**
|
139 |
-
* Gets a link to this shipment's
|
140 |
-
*
|
141 |
-
* @return string
|
142 |
Â
*/
|
143 |
Â
public function getGridHeader()
|
144 |
Â
{
|
145 |
Â
$helper = Mage::helper('postnl');
|
146 |
-
|
147 |
Â
$postnlShipment = $this->getPostnlShipment();
|
148 |
Â
$url = $postnlShipment->getBarcodeUrl();
|
149 |
-
|
150 |
Â
$urlTitle = $helper->__('Mijnpakket');
|
151 |
Â
$urlText = $helper->__('View this shipment in mijnpakket');
|
152 |
Â
$html = "<a href='{$url}' title='{$urlTitle}' target='_blank'>{$urlText}</a>";
|
153 |
-
|
154 |
Â
return $html;
|
155 |
Â
}
|
156 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory extends Mage_Adminhtml_Block_Widget_Grid
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Class constructor
|
43 |
+
*
|
44 |
Â
* @return TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory
|
45 |
+
*
|
46 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid::__construct()
|
47 |
Â
*/
|
48 |
Â
public function __construct()
|
49 |
Â
{
|
50 |
Â
parent::__construct();
|
51 |
+
|
52 |
Â
/**
|
53 |
Â
* Set some base variables for this grid
|
54 |
Â
*/
|
57 |
Â
$this->setDefaultSort('timestamp');
|
58 |
Â
$this->setDefaultDir('DESC');
|
59 |
Â
$this->setUseAjax(true);
|
60 |
+
|
61 |
Â
$postnlShipment = Mage::registry('current_postnl_shipment');
|
62 |
Â
$this->setPostnlShipment($postnlShipment);
|
63 |
+
|
64 |
Â
return $this;
|
65 |
Â
}
|
66 |
+
|
67 |
Â
/**
|
68 |
Â
* Get the basic collection for this grid
|
69 |
+
*
|
70 |
Â
* @return TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tab_StatusHistory
|
71 |
+
*
|
72 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid::_prepareCollection
|
73 |
Â
*/
|
74 |
Â
protected function _prepareCollection()
|
75 |
Â
{
|
76 |
Â
$postnlShipmentId = $this->getPostnlShipment()->getId();
|
77 |
+
|
78 |
Â
$collection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
|
79 |
Â
$collection->addFieldToFilter('parent_id', array('eq' => $postnlShipmentId));
|
80 |
+
|
81 |
Â
$this->setCollection($collection);
|
82 |
Â
|
83 |
Â
parent::_prepareCollection();
|
84 |
Â
return $this;
|
85 |
Â
}
|
86 |
+
|
87 |
Â
/**
|
88 |
Â
* Prepares the grid's columns for rendering
|
89 |
+
*
|
90 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid::_prepareColumns
|
91 |
+
*
|
92 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid::addColumn()
|
93 |
Â
*/
|
94 |
Â
protected function _prepareColumns()
|
95 |
Â
{
|
96 |
Â
$helper = Mage::helper('postnl');
|
97 |
+
|
98 |
Â
$this->addColumn('date',
|
99 |
Â
array(
|
100 |
Â
'header' => $helper->__('Date'),
|
105 |
Â
'renderer' => 'adminhtml/widget_grid_column_renderer_date',
|
106 |
Â
'filter_time' => true,
|
107 |
Â
));
|
108 |
+
|
109 |
Â
$this->addColumn('timestamp',
|
110 |
Â
array(
|
111 |
Â
'header' => $helper->__('Time'),
|
116 |
Â
'filter' => false,
|
117 |
Â
'sortable' => false,
|
118 |
Â
));
|
119 |
+
|
120 |
Â
$this->addColumn('code',
|
121 |
Â
array(
|
122 |
Â
'header' => $helper->__('Status Code'),
|
123 |
Â
'index' => 'code',
|
124 |
Â
'width' => '100px',
|
125 |
Â
));
|
126 |
+
|
127 |
Â
$this->addColumn('description',
|
128 |
Â
array(
|
129 |
Â
'header' => $helper->__('Description'),
|
134 |
Â
|
135 |
Â
return parent::_prepareColumns();
|
136 |
Â
}
|
137 |
+
|
138 |
Â
/**
|
139 |
+
* Gets a link to this shipment's MijnPakket page as the grid's header.
|
140 |
+
*
|
141 |
+
* @return string
|
142 |
Â
*/
|
143 |
Â
public function getGridHeader()
|
144 |
Â
{
|
145 |
Â
$helper = Mage::helper('postnl');
|
146 |
+
|
147 |
Â
$postnlShipment = $this->getPostnlShipment();
|
148 |
Â
$url = $postnlShipment->getBarcodeUrl();
|
149 |
+
|
150 |
Â
$urlTitle = $helper->__('Mijnpakket');
|
151 |
Â
$urlText = $helper->__('View this shipment in mijnpakket');
|
152 |
Â
$html = "<a href='{$url}' title='{$urlTitle}' target='_blank'>{$urlText}</a>";
|
153 |
+
|
154 |
Â
return $html;
|
155 |
Â
}
|
156 |
Â
}
|
@@ -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.
|
@@ -33,17 +33,16 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Constructor for the tabs container
|
43 |
-
*
|
44 |
-
* @return
|
45 |
-
|
46 |
-
* @see Mage_Adminhtml_Block_Widget_Tabs::__construct()
|
47 |
Â
*/
|
48 |
Â
public function __construct()
|
49 |
Â
{
|
@@ -52,16 +51,17 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adm
|
|
52 |
Â
$this->setDestElementId('sales_order_shipment_view');
|
53 |
Â
$this->setTitle(Mage::helper('sales')->__('Shipment View'));
|
54 |
Â
}
|
55 |
-
|
56 |
Â
/**
|
57 |
Â
* Add the main tabs to the page. Layout XML may be used to add more if desired
|
58 |
-
*
|
59 |
Â
* @return Mage_Adminhtml_Block_Widget_Tabs::_prepareLayout()
|
60 |
Â
*/
|
61 |
Â
protected function _prepareLayout()
|
62 |
Â
{
|
63 |
Â
/**
|
64 |
-
* Add the 'information' tab. this contains all default features of the shipment view page and is selected by
|
Â
|
|
65 |
Â
*/
|
66 |
Â
$this->addTab('shipment_info', array(
|
67 |
Â
'label' => Mage::helper('sales')->__('Information'),
|
@@ -69,33 +69,35 @@ class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adm
|
|
69 |
Â
->getBlock('form')
|
70 |
Â
->toHtml(),
|
71 |
Â
));
|
72 |
-
|
73 |
Â
/**
|
74 |
Â
* Get the current shipment's ID and attempt to load a corresponding postnl shipment
|
75 |
Â
*/
|
76 |
Â
$shipmentId = Mage::registry('current_shipment')->getId();
|
77 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
|
78 |
-
|
79 |
Â
/**
|
80 |
-
* Only show the status history tab if a postnl shipment entity was found for the current shipment
|
Â
|
|
81 |
Â
*/
|
82 |
-
|
Â
|
|
83 |
Â
/**
|
84 |
Â
* Add the status history tab. This is added by PostNL
|
85 |
Â
*/
|
86 |
Â
$this->addTab('shipment_status_history', array(
|
87 |
Â
'label' => Mage::helper('postnl')->__('Shipping event history'),
|
88 |
Â
'url' => $this->getUrl(
|
89 |
-
'
|
90 |
Â
array(
|
91 |
-
'_current' => true,
|
92 |
Â
'shipment_id' => $shipmentId
|
93 |
Â
)
|
94 |
Â
),
|
95 |
Â
'class' => 'ajax',
|
96 |
Â
));
|
97 |
Â
}
|
98 |
-
|
99 |
Â
return parent::_prepareLayout();
|
100 |
Â
}
|
101 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Constructor for the tabs container
|
43 |
+
*
|
44 |
+
* @return \TIG_PostNL_Block_Adminhtml_Sales_Order_Shipment_View_Tabs
|
45 |
+
@see Mage_Adminhtml_Block_Widget_Tabs::__construct()
|
Â
|
|
46 |
Â
*/
|
47 |
Â
public function __construct()
|
48 |
Â
{
|
51 |
Â
$this->setDestElementId('sales_order_shipment_view');
|
52 |
Â
$this->setTitle(Mage::helper('sales')->__('Shipment View'));
|
53 |
Â
}
|
54 |
+
|
55 |
Â
/**
|
56 |
Â
* Add the main tabs to the page. Layout XML may be used to add more if desired
|
57 |
+
*
|
58 |
Â
* @return Mage_Adminhtml_Block_Widget_Tabs::_prepareLayout()
|
59 |
Â
*/
|
60 |
Â
protected function _prepareLayout()
|
61 |
Â
{
|
62 |
Â
/**
|
63 |
+
* Add the 'information' tab. this contains all default features of the shipment view page and is selected by
|
64 |
+
* default.
|
65 |
Â
*/
|
66 |
Â
$this->addTab('shipment_info', array(
|
67 |
Â
'label' => Mage::helper('sales')->__('Information'),
|
69 |
Â
->getBlock('form')
|
70 |
Â
->toHtml(),
|
71 |
Â
));
|
72 |
+
|
73 |
Â
/**
|
74 |
Â
* Get the current shipment's ID and attempt to load a corresponding postnl shipment
|
75 |
Â
*/
|
76 |
Â
$shipmentId = Mage::registry('current_shipment')->getId();
|
77 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipmentId, 'shipment_id');
|
78 |
+
|
79 |
Â
/**
|
80 |
+
* Only show the status history tab if a postnl shipment entity was found for the current shipment and the
|
81 |
+
* current admin user is allowed to view the complete shipment status history.
|
82 |
Â
*/
|
83 |
+
$historyAllowed = Mage::helper('postnl')->checkIsPostnlActionAllowed('view_complete_status');
|
84 |
+
if ($historyAllowed && $postnlShipment->getId()) {
|
85 |
Â
/**
|
86 |
Â
* Add the status history tab. This is added by PostNL
|
87 |
Â
*/
|
88 |
Â
$this->addTab('shipment_status_history', array(
|
89 |
Â
'label' => Mage::helper('postnl')->__('Shipping event history'),
|
90 |
Â
'url' => $this->getUrl(
|
91 |
+
'postnl_admin/adminhtml_shipment/statusHistory',
|
92 |
Â
array(
|
93 |
+
'_current' => true,
|
94 |
Â
'shipment_id' => $shipmentId
|
95 |
Â
)
|
96 |
Â
),
|
97 |
Â
'class' => 'ajax',
|
98 |
Â
));
|
99 |
Â
}
|
100 |
+
|
101 |
Â
return parent::_prepareLayout();
|
102 |
Â
}
|
103 |
Â
}
|
@@ -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.
|
@@ -33,33 +33,50 @@
|
|
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)
|
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 extends Mage_Adminhtml_Block_System_Config_Form
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
-
* For Magento versions below these versions we need to execute some special backwards
|
43 |
Â
*/
|
44 |
Â
const MINIMUM_VERSION_COMPATIBILITY = '1.7.0.0';
|
45 |
Â
const MINIMUM_ENTERPRISE_VERSION_COMPATIBILITY = '1.12.0.0';
|
46 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
47 |
Â
/**
|
48 |
Â
* Creates the system > config > edit form for the PostNL section.
|
49 |
-
*
|
50 |
-
*
|
51 |
-
* for 'forwards' field dependency.
|
52 |
-
*
|
53 |
-
* Due to the way the form is initialized, each fieldset is initialized with it's fields in order. Due to this order a field
|
54 |
Â
* can only depend on a field that is in the same fieldset or in a fieldset that is already initialized. An example:
|
55 |
Â
* We have fieldset_a containing field_a. We also have fieldset_b containing field_b. If field_a depends on field_b, this
|
56 |
-
* is not possible. When field_a is initialized, fieldset_b and therefore field_b, will not yet have been initialized and
|
57 |
Â
* will not be available.
|
58 |
-
*
|
59 |
Â
* We have split the initialization of fieldsets and fields. This way Magento will first initialize all fieldsets and then
|
60 |
Â
* init all fields. So when field_a is initialized, fieldset_b is already available and the dependency will work.
|
61 |
Â
*
|
62 |
-
* @return
|
63 |
Â
*/
|
64 |
Â
public function initForm()
|
65 |
Â
{
|
@@ -91,7 +108,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
91 |
Â
}
|
92 |
Â
$this->_initGroup($form, $group, $section);
|
93 |
Â
}
|
94 |
-
|
95 |
Â
/*************************
|
96 |
Â
* This part is new
|
97 |
Â
************************/
|
@@ -99,7 +116,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
99 |
Â
if (!isset($this->_fieldsets[$group->getName()])) {
|
100 |
Â
continue;
|
101 |
Â
}
|
102 |
-
|
103 |
Â
$fieldset = $this->_fieldsets[$group->getName()];
|
104 |
Â
$this->initFields($fieldset, $group, $section);
|
105 |
Â
}
|
@@ -113,11 +130,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
113 |
Â
/**
|
114 |
Â
* Init config group
|
115 |
Â
*
|
116 |
-
* @param Varien_Data_Form
|
117 |
-
* @param Varien_Simplexml_Element
|
118 |
-
* @param Varien_Simplexml_Element
|
119 |
Â
* @param Varien_Data_Form_Element_Fieldset|null $parentElement
|
120 |
-
*
|
Â
|
|
Â
|
|
121 |
Â
* @return void
|
122 |
Â
*/
|
123 |
Â
protected function _initGroup($form, $group, $section, $parentElement = null)
|
@@ -127,7 +146,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
127 |
Â
} else {
|
128 |
Â
$fieldsetRenderer = $this->_defaultFieldsetRenderer;
|
129 |
Â
}
|
130 |
-
|
131 |
Â
$fieldsetRenderer->setForm($this)
|
132 |
Â
->setConfigData($this->_configData);
|
133 |
Â
|
@@ -141,6 +160,14 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
141 |
Â
$fieldsetConfig['expanded'] = (bool)$group->expanded;
|
142 |
Â
}
|
143 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
144 |
Â
$fieldset = new Varien_Data_Form_Element_Fieldset($fieldsetConfig);
|
145 |
Â
$fieldset->setId($section->getName() . '_' . $group->getName())
|
146 |
Â
->setRenderer($fieldsetRenderer)
|
@@ -178,16 +205,16 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
178 |
Â
}
|
179 |
Â
|
180 |
Â
/**
|
181 |
-
* Init fieldset fields. Copied from EE1.13 Mage_Adminhtml_Block_System_Config_Form::initFields to allow for
|
182 |
-
* dependencies in CE 1.6. Only made a small change to core code for backwards compatibility.
|
183 |
Â
*
|
184 |
Â
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
185 |
-
* @param Varien_Simplexml_Element
|
186 |
-
* @param Varien_Simplexml_Element
|
187 |
-
* @param string
|
188 |
-
* @param string
|
189 |
-
*
|
190 |
-
* @return
|
191 |
Â
*/
|
192 |
Â
public function initFields($fieldset, $group, $section, $fieldPrefix='', $labelPrefix='')
|
193 |
Â
{
|
@@ -240,19 +267,29 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
240 |
Â
}
|
241 |
Â
|
242 |
Â
$data = $this->_configDataObject->getConfigDataValue($path, $inherit, $this->_configData);
|
243 |
-
|
244 |
Â
/**
|
245 |
-
* Because Magento 1.6 and 1.11 retrieved config data in a different manner, we need to provide
|
246 |
-
* compatibility for those versions.
|
247 |
Â
*/
|
Â
|
|
248 |
Â
$isEnterprise = Mage::helper('postnl')->isEnterprise();
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
256 |
Â
if (isset($this->_configData[$path])) {
|
257 |
Â
$data = $this->_configData[$path];
|
258 |
Â
$inherit = false;
|
@@ -261,7 +298,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
261 |
Â
$inherit = true;
|
262 |
Â
}
|
263 |
Â
}
|
264 |
-
|
265 |
Â
if ($element->frontend_model) {
|
266 |
Â
$fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
|
267 |
Â
} else {
|
@@ -375,8 +412,8 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
375 |
Â
'scope' => $this->getScope(),
|
376 |
Â
'scope_id' => $this->getScopeId(),
|
377 |
Â
'scope_label' => $this->getScopeLabel($element),
|
378 |
-
'can_use_default_value' => $this->canUseDefaultValue(
|
379 |
-
'can_use_website_value' => $this->canUseWebsiteValue(
|
380 |
Â
));
|
381 |
Â
$this->_prepareFieldOriginalData($field, $element);
|
382 |
Â
|
@@ -384,6 +421,10 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
384 |
Â
$field->addClass($element->validate);
|
385 |
Â
}
|
386 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
387 |
Â
if (isset($element->frontend_type)
|
388 |
Â
&& 'multiselect' === (string)$element->frontend_type
|
389 |
Â
&& isset($element->can_be_empty)
|
@@ -407,7 +448,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
407 |
Â
$sourceModel->setPath($path);
|
408 |
Â
}
|
409 |
Â
if ($method) {
|
410 |
-
if ($fieldType == 'multiselect') {
|
411 |
Â
$optionArray = $sourceModel->$method();
|
412 |
Â
} else {
|
413 |
Â
$optionArray = array();
|
@@ -422,6 +463,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block
|
|
422 |
Â
}
|
423 |
Â
}
|
424 |
Â
}
|
Â
|
|
425 |
Â
return $this;
|
426 |
Â
}
|
427 |
Â
}
|
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.
|
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 |
+
* @method boolean hasFieldsetParam()
|
40 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form setFieldsetParam(string $value)
|
41 |
Â
*/
|
42 |
Â
class TIG_PostNL_Block_Adminhtml_System_Config_Form extends Mage_Adminhtml_Block_System_Config_Form
|
43 |
Â
{
|
44 |
Â
/**
|
45 |
+
* For Magento versions below these versions we need to execute some special backwards compatibility code.
|
46 |
Â
*/
|
47 |
Â
const MINIMUM_VERSION_COMPATIBILITY = '1.7.0.0';
|
48 |
Â
const MINIMUM_ENTERPRISE_VERSION_COMPATIBILITY = '1.12.0.0';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Gets the fieldset parameter from the GET superglobal if available.
|
52 |
+
*
|
53 |
+
* @return null|string
|
54 |
+
*/
|
55 |
+
public function getFieldsetParam()
|
56 |
+
{
|
57 |
+
if ($this->hasFieldsetParam()) {
|
58 |
+
return $this->getData('fieldset_param');
|
59 |
+
}
|
60 |
+
|
61 |
+
$fieldsetparam = Mage::app()->getRequest()->getParam('fieldset');
|
62 |
+
|
63 |
+
$this->setFieldsetParam($fieldsetparam);
|
64 |
+
return $fieldsetparam;
|
65 |
+
}
|
66 |
+
|
67 |
Â
/**
|
68 |
Â
* Creates the system > config > edit form for the PostNL section.
|
69 |
+
*
|
70 |
+
* Due to the way the form is initialized, each fieldset is initialized with it's fields in order. Due to this order a field
|
Â
|
|
Â
|
|
Â
|
|
71 |
Â
* can only depend on a field that is in the same fieldset or in a fieldset that is already initialized. An example:
|
72 |
Â
* We have fieldset_a containing field_a. We also have fieldset_b containing field_b. If field_a depends on field_b, this
|
73 |
+
* is not possible. When field_a is initialized, fieldset_b and therefore field_b, will not yet have been initialized and
|
74 |
Â
* will not be available.
|
75 |
+
*
|
76 |
Â
* We have split the initialization of fieldsets and fields. This way Magento will first initialize all fieldsets and then
|
77 |
Â
* init all fields. So when field_a is initialized, fieldset_b is already available and the dependency will work.
|
78 |
Â
*
|
79 |
+
* @return TIG_PostNL_Block_Adminhtml_System_Config_Form
|
80 |
Â
*/
|
81 |
Â
public function initForm()
|
82 |
Â
{
|
108 |
Â
}
|
109 |
Â
$this->_initGroup($form, $group, $section);
|
110 |
Â
}
|
111 |
+
|
112 |
Â
/*************************
|
113 |
Â
* This part is new
|
114 |
Â
************************/
|
116 |
Â
if (!isset($this->_fieldsets[$group->getName()])) {
|
117 |
Â
continue;
|
118 |
Â
}
|
119 |
+
|
120 |
Â
$fieldset = $this->_fieldsets[$group->getName()];
|
121 |
Â
$this->initFields($fieldset, $group, $section);
|
122 |
Â
}
|
130 |
Â
/**
|
131 |
Â
* Init config group
|
132 |
Â
*
|
133 |
+
* @param Varien_Data_Form $form
|
134 |
+
* @param Varien_Simplexml_Element $group
|
135 |
+
* @param Varien_Simplexml_Element $section
|
136 |
Â
* @param Varien_Data_Form_Element_Fieldset|null $parentElement
|
137 |
+
*
|
138 |
+
* @throws TIG_PostNL_Exception
|
139 |
+
*
|
140 |
Â
* @return void
|
141 |
Â
*/
|
142 |
Â
protected function _initGroup($form, $group, $section, $parentElement = null)
|
146 |
Â
} else {
|
147 |
Â
$fieldsetRenderer = $this->_defaultFieldsetRenderer;
|
148 |
Â
}
|
149 |
+
|
150 |
Â
$fieldsetRenderer->setForm($this)
|
151 |
Â
->setConfigData($this->_configData);
|
152 |
Â
|
160 |
Â
$fieldsetConfig['expanded'] = (bool)$group->expanded;
|
161 |
Â
}
|
162 |
Â
|
163 |
+
/**
|
164 |
+
* Added support for a 'fieldset' URL parameter that forces a certain fieldset to the expanded state.
|
165 |
+
*/
|
166 |
+
$fieldsetParam = $this->getFieldsetParam();
|
167 |
+
if ($fieldsetParam && $fieldsetParam == $group->getName()) {
|
168 |
+
$fieldsetConfig['expanded'] = true;
|
169 |
+
}
|
170 |
+
|
171 |
Â
$fieldset = new Varien_Data_Form_Element_Fieldset($fieldsetConfig);
|
172 |
Â
$fieldset->setId($section->getName() . '_' . $group->getName())
|
173 |
Â
->setRenderer($fieldsetRenderer)
|
205 |
Â
}
|
206 |
Â
|
207 |
Â
/**
|
208 |
+
* Init fieldset fields. Copied from EE1.13 Mage_Adminhtml_Block_System_Config_Form::initFields to allow for
|
209 |
+
* cross-fieldset dependencies in CE 1.6. Only made a small change to core code for backwards compatibility.
|
210 |
Â
*
|
211 |
Â
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
212 |
+
* @param Varien_Simplexml_Element $group
|
213 |
+
* @param Varien_Simplexml_Element $section
|
214 |
+
* @param string $fieldPrefix
|
215 |
+
* @param string $labelPrefix
|
216 |
+
*
|
217 |
+
* @return $this
|
218 |
Â
*/
|
219 |
Â
public function initFields($fieldset, $group, $section, $fieldPrefix='', $labelPrefix='')
|
220 |
Â
{
|
267 |
Â
}
|
268 |
Â
|
269 |
Â
$data = $this->_configDataObject->getConfigDataValue($path, $inherit, $this->_configData);
|
270 |
+
|
271 |
Â
/**
|
272 |
+
* Because Magento 1.6 and 1.11 retrieved config data in a different manner, we need to provide
|
273 |
+
* backwards compatibility for those versions.
|
274 |
Â
*/
|
275 |
+
$version = Mage::getVersion();
|
276 |
Â
$isEnterprise = Mage::helper('postnl')->isEnterprise();
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Get the minimum version requirement for the current Magento edition.
|
280 |
+
*/
|
281 |
+
if($isEnterprise) {
|
282 |
+
$minimumVersion = self::MINIMUM_ENTERPRISE_VERSION_COMPATIBILITY;
|
283 |
+
} else {
|
284 |
+
$minimumVersion = self::MINIMUM_VERSION_COMPATIBILITY;
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Check if the current version is below the minimum version requirement.
|
289 |
+
*/
|
290 |
+
$isBelowMinimumVersion = version_compare($version, $minimumVersion, '<');
|
291 |
+
|
292 |
+
if (!$data && $isBelowMinimumVersion === true) {
|
293 |
Â
if (isset($this->_configData[$path])) {
|
294 |
Â
$data = $this->_configData[$path];
|
295 |
Â
$inherit = false;
|
298 |
Â
$inherit = true;
|
299 |
Â
}
|
300 |
Â
}
|
301 |
+
|
302 |
Â
if ($element->frontend_model) {
|
303 |
Â
$fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
|
304 |
Â
} else {
|
412 |
Â
'scope' => $this->getScope(),
|
413 |
Â
'scope_id' => $this->getScopeId(),
|
414 |
Â
'scope_label' => $this->getScopeLabel($element),
|
415 |
+
'can_use_default_value' => $this->canUseDefaultValue($element),
|
416 |
+
'can_use_website_value' => $this->canUseWebsiteValue($element),
|
417 |
Â
));
|
418 |
Â
$this->_prepareFieldOriginalData($field, $element);
|
419 |
Â
|
421 |
Â
$field->addClass($element->validate);
|
422 |
Â
}
|
423 |
Â
|
424 |
+
if (isset($element->autocomplete)) {
|
425 |
+
$field->setAutocomplete($element->autocomplete);
|
426 |
+
}
|
427 |
+
|
428 |
Â
if (isset($element->frontend_type)
|
429 |
Â
&& 'multiselect' === (string)$element->frontend_type
|
430 |
Â
&& isset($element->can_be_empty)
|
448 |
Â
$sourceModel->setPath($path);
|
449 |
Â
}
|
450 |
Â
if ($method) {
|
451 |
+
if ($fieldType == 'multiselect' || $element->multidimensional) {
|
452 |
Â
$optionArray = $sourceModel->$method();
|
453 |
Â
} else {
|
454 |
Â
$optionArray = array();
|
463 |
Â
}
|
464 |
Â
}
|
465 |
Â
}
|
466 |
+
|
467 |
Â
return $this;
|
468 |
Â
}
|
469 |
Â
}
|
@@ -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.
|
@@ -33,8 +33,10 @@
|
|
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)
|
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_ActivateButton
|
40 |
Â
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
@@ -44,25 +46,25 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton
|
|
44 |
Â
* XML path to 'is_activated' flag
|
45 |
Â
*/
|
46 |
Â
const XML_PATH_IS_ACTIVATED = 'postnl/general/is_activated';
|
47 |
-
|
48 |
Â
/**
|
49 |
Â
* Gets the element's html. In this case: a button redirecting the user to the extensionControl controller
|
50 |
-
*
|
Â
|
|
Â
|
|
51 |
Â
* @return string
|
52 |
Â
*/
|
53 |
Â
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
54 |
Â
{
|
55 |
Â
$this->setElement($element);
|
56 |
-
|
57 |
-
$url = $this->getUrl('postnl/adminhtml_extensionControl/activate');
|
58 |
-
|
59 |
Â
$isActivated = Mage::getStoreConfig(self::XML_PATH_IS_ACTIVATED, Mage_Core_Model_App::ADMIN_STORE_ID);
|
60 |
Â
if ($isActivated === '1') {
|
61 |
Â
$label = $this->__('Finish activation');
|
62 |
Â
} else {
|
63 |
Â
$label = $this->__('Activate the extension');
|
64 |
Â
}
|
65 |
-
|
66 |
Â
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
67 |
Â
->setId($element->getHtmlId())
|
68 |
Â
->setType('button')
|
@@ -73,12 +75,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton
|
|
73 |
Â
|
74 |
Â
return $html;
|
75 |
Â
}
|
76 |
-
|
77 |
Â
/**
|
78 |
Â
* Render the element without a scope label
|
79 |
-
*
|
Â
|
|
80 |
Â
* @return string
|
81 |
-
*
|
82 |
Â
* @see parent::render()
|
83 |
Â
*/
|
84 |
Â
public function render(Varien_Data_Form_Element_Abstract $element)
|
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.
|
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 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton setElement(Varien_Data_Form_Element_Abstract $value)
|
40 |
Â
*/
|
41 |
Â
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivateButton
|
42 |
Â
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
46 |
Â
* XML path to 'is_activated' flag
|
47 |
Â
*/
|
48 |
Â
const XML_PATH_IS_ACTIVATED = 'postnl/general/is_activated';
|
49 |
+
|
50 |
Â
/**
|
51 |
Â
* Gets the element's html. In this case: a button redirecting the user to the extensionControl controller
|
52 |
+
*
|
53 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
54 |
+
*
|
55 |
Â
* @return string
|
56 |
Â
*/
|
57 |
Â
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
58 |
Â
{
|
59 |
Â
$this->setElement($element);
|
60 |
+
|
Â
|
|
Â
|
|
61 |
Â
$isActivated = Mage::getStoreConfig(self::XML_PATH_IS_ACTIVATED, Mage_Core_Model_App::ADMIN_STORE_ID);
|
62 |
Â
if ($isActivated === '1') {
|
63 |
Â
$label = $this->__('Finish activation');
|
64 |
Â
} else {
|
65 |
Â
$label = $this->__('Activate the extension');
|
66 |
Â
}
|
67 |
+
|
68 |
Â
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
69 |
Â
->setId($element->getHtmlId())
|
70 |
Â
->setType('button')
|
75 |
Â
|
76 |
Â
return $html;
|
77 |
Â
}
|
78 |
+
|
79 |
Â
/**
|
80 |
Â
* Render the element without a scope label
|
81 |
+
*
|
82 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
83 |
Â
* @return string
|
84 |
+
*
|
85 |
Â
* @see parent::render()
|
86 |
Â
*/
|
87 |
Â
public function render(Varien_Data_Form_Element_Abstract $element)
|
@@ -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.
|
@@ -33,21 +33,27 @@
|
|
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)
|
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_ActivatedFieldHeader
|
Â
|
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Template file used
|
43 |
-
*
|
44 |
Â
* @var string
|
45 |
Â
*/
|
46 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/field_header.phtml';
|
47 |
-
|
48 |
Â
/**
|
49 |
Â
* Get the element's label
|
50 |
-
*
|
51 |
Â
* @return string
|
52 |
Â
*/
|
53 |
Â
public function getLabel()
|
@@ -55,42 +61,42 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivatedFieldHeader e
|
|
55 |
Â
if (!$this->getElement()) {
|
56 |
Â
return '';
|
57 |
Â
}
|
58 |
-
|
59 |
Â
$element = $this->getElement();
|
60 |
Â
$label = $element->getLabel();
|
61 |
-
|
62 |
Â
$section = $this->getRequest()->getParam('section');
|
63 |
Â
$website = $this->getRequest()->getParam('website');
|
64 |
Â
$store = $this->getRequest()->getParam('store');
|
65 |
-
|
66 |
Â
$urlParams = array(
|
67 |
Â
'_secure' => true,
|
68 |
Â
);
|
69 |
-
|
70 |
Â
if ($section) {
|
71 |
Â
$urlParams['section'] = $section;
|
72 |
Â
}
|
73 |
-
|
74 |
Â
if ($website) {
|
75 |
Â
$urlParams['website'] = $website;
|
76 |
Â
}
|
77 |
-
|
78 |
Â
if ($store) {
|
79 |
Â
$urlParams['store'] = $store;
|
80 |
Â
}
|
81 |
-
|
82 |
-
$url = $this->getUrl('
|
83 |
-
$onclick = "confirmSetLocation('"
|
84 |
-
. $this->__("Are you sure? The PostNL extension will not function until you\'ve reactivated the extension.")
|
85 |
-
. "', '"
|
86 |
-
. $url
|
87 |
Â
. "');";
|
88 |
-
|
89 |
Â
$label = sprintf(
|
90 |
Â
$label,
|
91 |
Â
$onclick
|
92 |
Â
);
|
93 |
-
|
94 |
Â
return $label;
|
95 |
Â
}
|
96 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ActivatedFieldHeader
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
41 |
Â
{
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_activatedfieldheader';
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* Template file used
|
49 |
+
*
|
50 |
Â
* @var string
|
51 |
Â
*/
|
52 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/field_header.phtml';
|
53 |
+
|
54 |
Â
/**
|
55 |
Â
* Get the element's label
|
56 |
+
*
|
57 |
Â
* @return string
|
58 |
Â
*/
|
59 |
Â
public function getLabel()
|
61 |
Â
if (!$this->getElement()) {
|
62 |
Â
return '';
|
63 |
Â
}
|
64 |
+
|
65 |
Â
$element = $this->getElement();
|
66 |
Â
$label = $element->getLabel();
|
67 |
+
|
68 |
Â
$section = $this->getRequest()->getParam('section');
|
69 |
Â
$website = $this->getRequest()->getParam('website');
|
70 |
Â
$store = $this->getRequest()->getParam('store');
|
71 |
+
|
72 |
Â
$urlParams = array(
|
73 |
Â
'_secure' => true,
|
74 |
Â
);
|
75 |
+
|
76 |
Â
if ($section) {
|
77 |
Â
$urlParams['section'] = $section;
|
78 |
Â
}
|
79 |
+
|
80 |
Â
if ($website) {
|
81 |
Â
$urlParams['website'] = $website;
|
82 |
Â
}
|
83 |
+
|
84 |
Â
if ($store) {
|
85 |
Â
$urlParams['store'] = $store;
|
86 |
Â
}
|
87 |
+
|
88 |
+
$url = $this->getUrl('postnl_admin/adminhtml_extensionControl/showActivationFields', $urlParams);
|
89 |
+
$onclick = "confirmSetLocation('"
|
90 |
+
. $this->__("Are you sure? The PostNL extension will not function until you\'ve reactivated the extension.")
|
91 |
+
. "', '"
|
92 |
+
. $url
|
93 |
Â
. "');";
|
94 |
+
|
95 |
Â
$label = sprintf(
|
96 |
Â
$label,
|
97 |
Â
$onclick
|
98 |
Â
);
|
99 |
+
|
100 |
Â
return $label;
|
101 |
Â
}
|
102 |
Â
}
|
@@ -0,0 +1,92 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Anchor
|
40 |
+
extends Varien_Data_Form_Element_Link
|
41 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* Get the element's HTML.
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function getElementHtml()
|
49 |
+
{
|
50 |
+
$originalData = $this->getElement()->getOriginalData();
|
51 |
+
$anchorName = $originalData['anchor_name'];
|
52 |
+
|
53 |
+
$html = $this->getBeforeElementHtml();
|
54 |
+
$html .= '<a name="' . $anchorName . '"></a>';
|
55 |
+
$html .= $this->getAfterElementHtml();
|
56 |
+
|
57 |
+
return $html;
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Get the element's HTML ID
|
62 |
+
*
|
63 |
+
* @return string
|
64 |
+
*/
|
65 |
+
public function getHtmlId()
|
66 |
+
{
|
67 |
+
if (!$this->getElement()) {
|
68 |
+
return '';
|
69 |
+
}
|
70 |
+
|
71 |
+
$element = $this->getElement();
|
72 |
+
$id = $element->getHtmlId();
|
73 |
+
|
74 |
+
return $id;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Render field html
|
79 |
+
*
|
80 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
81 |
+
* @return string
|
82 |
+
*/
|
83 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
84 |
+
{
|
85 |
+
$this->setElement($element);
|
86 |
+
|
87 |
+
$this->setBeforeElementHtml('<tr id="row_' . $this->getHtmlId() . '"><td colspan="5">');
|
88 |
+
$this->setAfterElementHtml('</tr></td>');
|
89 |
+
|
90 |
+
return $this->getElementHtml();
|
91 |
+
}
|
92 |
+
}
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*
|
39 |
Â
* @method boolean hasPostnlHelper()
|
@@ -42,6 +42,11 @@
|
|
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 |
Â
*/
|
@@ -178,13 +183,12 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ConfigCheck
|
|
178 |
Â
*/
|
179 |
Â
public function isCheckoutEnabled()
|
180 |
Â
{
|
181 |
-
$
|
182 |
-
|
Â
|
|
183 |
Â
return true;
|
184 |
Â
}
|
185 |
Â
|
186 |
-
$helper = Mage::helper('postnl/checkout');
|
187 |
-
|
188 |
Â
return $helper->isCheckoutEnabled(false);
|
189 |
Â
}
|
190 |
Â
|
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 |
Â
* @method boolean hasPostnlHelper()
|
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 |
+
* @var string
|
47 |
+
*/
|
48 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_configcheck';
|
49 |
+
|
50 |
Â
/**
|
51 |
Â
* XML paths to use GlobalPack/Checkout settings
|
52 |
Â
*/
|
183 |
Â
*/
|
184 |
Â
public function isCheckoutEnabled()
|
185 |
Â
{
|
186 |
+
$helper = Mage::helper('postnl/checkout');
|
187 |
+
|
188 |
+
if (!$helper->isCheckoutActive()) {
|
189 |
Â
return true;
|
190 |
Â
}
|
191 |
Â
|
Â
|
|
Â
|
|
192 |
Â
return $helper->isCheckoutEnabled(false);
|
193 |
Â
}
|
194 |
Â
|
@@ -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,11 +36,17 @@
|
|
36 |
Â
* @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_InfoBox
|
Â
|
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Template file used
|
43 |
-
*
|
44 |
Â
* @var string
|
45 |
Â
*/
|
46 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/info_box.phtml';
|
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) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_InfoBox
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
41 |
Â
{
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_infobox';
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* Template file used
|
49 |
+
*
|
50 |
Â
* @var string
|
51 |
Â
*/
|
52 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/info_box.phtml';
|
@@ -0,0 +1,90 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_Obscure
|
40 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* Gets the element's HTML.
|
44 |
+
*
|
45 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
46 |
+
*
|
47 |
+
* @return string
|
48 |
+
*
|
49 |
+
* @see Varien_Data_Form_Element_Abstract::getElementHtml()
|
50 |
+
*/
|
51 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
52 |
+
{
|
53 |
+
$html = '<input id="'
|
54 |
+
. $element->getHtmlId()
|
55 |
+
. '" name="'
|
56 |
+
. $element->getName()
|
57 |
+
. '" value="'
|
58 |
+
. $element->getEscapedValue()
|
59 |
+
. '" '
|
60 |
+
. $element->serialize($this->getHtmlAttributes())
|
61 |
+
. '/>'
|
62 |
+
. "\n"
|
63 |
+
. $element->getAfterElementHtml();
|
64 |
+
|
65 |
+
return $html;
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Gets a list of supported HTML attributes for this element.
|
70 |
+
*
|
71 |
+
* @return array
|
72 |
+
*/
|
73 |
+
public function getHtmlAttributes()
|
74 |
+
{
|
75 |
+
$attributes = array(
|
76 |
+
'type',
|
77 |
+
'title',
|
78 |
+
'class',
|
79 |
+
'style',
|
80 |
+
'onclick',
|
81 |
+
'onchange',
|
82 |
+
'disabled',
|
83 |
+
'readonly',
|
84 |
+
'tabindex',
|
85 |
+
'autocomplete',
|
86 |
+
);
|
87 |
+
|
88 |
+
return $attributes;
|
89 |
+
}
|
90 |
+
}
|
@@ -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.
|
@@ -33,26 +33,33 @@
|
|
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)
|
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_SplitAddressCheck
|
Â
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
-
*
|
43 |
Â
*/
|
44 |
-
const
|
45 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
46 |
Â
/**
|
47 |
-
* Template file used
|
48 |
-
*
|
49 |
Â
* @var string
|
50 |
Â
*/
|
51 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/split_address_check.phtml';
|
52 |
-
|
53 |
Â
/**
|
54 |
-
* Get if the split_street field is enabled
|
55 |
-
*
|
56 |
Â
* @return boolean
|
57 |
Â
*/
|
58 |
Â
public function getIsAddressSplit()
|
@@ -63,14 +70,21 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck exte
|
|
63 |
Â
* Check if the split_street field is enabled based on the current scope
|
64 |
Â
*/
|
65 |
Â
if ($request->getParam('store')) {
|
66 |
-
$
|
Â
|
|
67 |
Â
} elseif ($request->getParam('website')) {
|
68 |
Â
$website = Mage::getModel('core/website')->load($request->getparam('website'), 'code');
|
69 |
-
$
|
Â
|
|
70 |
Â
} else {
|
71 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
72 |
Â
}
|
73 |
-
|
74 |
-
return
|
75 |
Â
}
|
76 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SplitAddressCheck
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
41 |
Â
{
|
42 |
Â
/**
|
43 |
+
* Xpaths to split street configuration options.
|
44 |
Â
*/
|
45 |
+
const XPATH_SPLIT_STREET = 'postnl/cif_address/split_street';
|
46 |
+
const XPATH_USE_POSTCODE_CHECK = 'postnl/cif_address/use_postcode_check';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_splitaddresscheck';
|
52 |
+
|
53 |
Â
/**
|
54 |
+
* Template file used.
|
55 |
+
*
|
56 |
Â
* @var string
|
57 |
Â
*/
|
58 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/split_address_check.phtml';
|
59 |
+
|
60 |
Â
/**
|
61 |
+
* Get if the split_street field or the postcode check is enabled.
|
62 |
+
*
|
63 |
Â
* @return boolean
|
64 |
Â
*/
|
65 |
Â
public function getIsAddressSplit()
|
70 |
Â
* Check if the split_street field is enabled based on the current scope
|
71 |
Â
*/
|
72 |
Â
if ($request->getParam('store')) {
|
73 |
+
$usePostcodeCheck = Mage::getStoreConfigFlag(self::XPATH_USE_POSTCODE_CHECK, $request->getparam('store'));
|
74 |
+
$splitStreet = Mage::getStoreConfigFlag(self::XPATH_SPLIT_STREET, $request->getparam('store'));
|
75 |
Â
} elseif ($request->getParam('website')) {
|
76 |
Â
$website = Mage::getModel('core/website')->load($request->getparam('website'), 'code');
|
77 |
+
$usePostcodeCheck = (bool) $website->getConfig(self::XPATH_USE_POSTCODE_CHECK, $website->getId());
|
78 |
+
$splitStreet = (bool) $website->getConfig(self::XPATH_SPLIT_STREET, $website->getId());
|
79 |
Â
} else {
|
80 |
+
$usePostcodeCheck = Mage::getStoreConfigFlag(self::XPATH_USE_POSTCODE_CHECK, Mage_Core_Model_App::ADMIN_STORE_ID);
|
81 |
+
$splitStreet = Mage::getStoreConfigFlag(self::XPATH_SPLIT_STREET, Mage_Core_Model_App::ADMIN_STORE_ID);
|
82 |
+
}
|
83 |
+
|
84 |
+
if ($usePostcodeCheck || $splitStreet) {
|
85 |
+
return true;
|
86 |
Â
}
|
87 |
+
|
88 |
+
return false;
|
89 |
Â
}
|
90 |
Â
}
|
@@ -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.
|
@@ -33,29 +33,36 @@
|
|
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)
|
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_SupportTab
|
Â
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
43 |
Â
*/
|
44 |
Â
const SYSTEM_CONFIG_EDIT_CSS_FILE = 'css/TIG/PostNL/system_config_edit_postnl.css';
|
45 |
-
|
Â
|
|
46 |
Â
/**
|
47 |
Â
* Template file used
|
48 |
-
*
|
49 |
Â
* @var string
|
50 |
Â
*/
|
51 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/support_tab.phtml';
|
52 |
-
|
53 |
Â
/**
|
54 |
-
* Add a new css file to the head. We couldn't do this from layout.xml, because it would have loaded
|
55 |
Â
* for all System > Config pages, rather than just PostNL's section.
|
56 |
-
*
|
57 |
Â
* @return Mage_Adminhtml_Block_Abstract::_prepareLayout()
|
58 |
-
*
|
59 |
Â
* @see Mage_Adminhtml_Block_Abstract::_prepareLayout()
|
60 |
Â
*/
|
61 |
Â
protected function _prepareLayout()
|
@@ -63,7 +70,32 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab extends TIG
|
|
63 |
Â
$this->getLayout()
|
64 |
Â
->getBlock('head')
|
65 |
Â
->addCss(self::SYSTEM_CONFIG_EDIT_CSS_FILE);
|
66 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
return parent::_prepareLayout();
|
68 |
Â
}
|
69 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_SupportTab
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
41 |
Â
{
|
42 |
Â
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_supporttab';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Css files loaded for PostNL's system > config section
|
49 |
Â
*/
|
50 |
Â
const SYSTEM_CONFIG_EDIT_CSS_FILE = 'css/TIG/PostNL/system_config_edit_postnl.css';
|
51 |
+
const MAGENTO_16_CSS_FILE = 'css/TIG/PostNL/system_config_edit_postnl_magento16.css';
|
52 |
+
|
53 |
Â
/**
|
54 |
Â
* Template file used
|
55 |
+
*
|
56 |
Â
* @var string
|
57 |
Â
*/
|
58 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/support_tab.phtml';
|
59 |
+
|
60 |
Â
/**
|
61 |
+
* Add a new css file to the head. We couldn't do this from layout.xml, because it would have loaded
|
62 |
Â
* for all System > Config pages, rather than just PostNL's section.
|
63 |
+
*
|
64 |
Â
* @return Mage_Adminhtml_Block_Abstract::_prepareLayout()
|
65 |
+
*
|
66 |
Â
* @see Mage_Adminhtml_Block_Abstract::_prepareLayout()
|
67 |
Â
*/
|
68 |
Â
protected function _prepareLayout()
|
70 |
Â
$this->getLayout()
|
71 |
Â
->getBlock('head')
|
72 |
Â
->addCss(self::SYSTEM_CONFIG_EDIT_CSS_FILE);
|
73 |
+
|
74 |
+
/**
|
75 |
+
* For Magento 1.6 and 1.11 we need to add another css file.
|
76 |
+
*/
|
77 |
+
$helper = Mage::helper('postnl');
|
78 |
+
$isEnterprise = $helper->isEnterprise();
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get the minimum version requirement for the current Magento edition.
|
82 |
+
*/
|
83 |
+
if($isEnterprise) {
|
84 |
+
$minimumVersion = '1.12.0.0';
|
85 |
+
} else {
|
86 |
+
$minimumVersion = '1.7.0.0';
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check if the current version is below the minimum version requirement.
|
91 |
+
*/
|
92 |
+
$isBelowMinimumVersion = version_compare(Mage::getVersion(), $minimumVersion, '<');
|
93 |
+
if ($isBelowMinimumVersion) {
|
94 |
+
$this->getLayout()
|
95 |
+
->getBlock('head')
|
96 |
+
->addCss(self::MAGENTO_16_CSS_FILE);
|
97 |
+
}
|
98 |
+
|
99 |
Â
return parent::_prepareLayout();
|
100 |
Â
}
|
101 |
Â
}
|
@@ -0,0 +1,82 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateExport
|
40 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
41 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
45 |
+
*
|
46 |
+
* @return string
|
47 |
+
*/
|
48 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
49 |
+
{
|
50 |
+
$buttonBlock = $this->getLayout()->createBlock('adminhtml/widget_button');
|
51 |
+
|
52 |
+
$params = array(
|
53 |
+
'website' => $buttonBlock->getRequest()->getParam('website')
|
54 |
+
);
|
55 |
+
|
56 |
+
$onClick = 'setLocation(\''
|
57 |
+
. Mage::helper('adminhtml')->getUrl("postnl_admin/adminhtml_config/exportTablerates", $params)
|
58 |
+
. 'conditionName/\' + $(\'carriers_postnl_condition_name\').value + \'/tablerates.csv\' )';
|
59 |
+
|
60 |
+
$data = array(
|
61 |
+
'label' => Mage::helper('postnl')->__('Export CSV'),
|
62 |
+
'onclick' => $onClick,
|
63 |
+
'id' => $element->getHtmlId(),
|
64 |
+
'type' => 'button',
|
65 |
+
'class' => 'scalable postnl-button',
|
66 |
+
);
|
67 |
+
|
68 |
+
$html = $buttonBlock->setData($data)->toHtml();
|
69 |
+
|
70 |
+
return $html;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
75 |
+
*
|
76 |
+
* @return string
|
77 |
+
*/
|
78 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
79 |
+
{
|
80 |
+
return parent::render($element);
|
81 |
+
}
|
82 |
+
}
|
@@ -0,0 +1,90 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TablerateImport
|
40 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
41 |
+
implements Varien_Data_Form_Element_Renderer_Interface
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* Get a hidden form element and some JS to support it.
|
45 |
+
*
|
46 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
47 |
+
*
|
48 |
+
* @return string
|
49 |
+
*
|
50 |
+
* @see Mage_Adminhtml_Block_System_Config_Form_Field_Import
|
51 |
+
*/
|
52 |
+
public function _getJsHtml(Varien_Data_Form_Element_Abstract $element)
|
53 |
+
{
|
54 |
+
$html = '<input id="postnl_time_condition" type="hidden" name="'.$element->getName().'" value="'.time().'" />';
|
55 |
+
|
56 |
+
$html .= "<script type='text/javascript'>
|
57 |
+
document.observe('dom:loaded', function() {
|
58 |
+
Event.observe($('carriers_postnl_condition_name'), 'change', checkConditionName.bind(this));
|
59 |
+
function checkConditionName(event)
|
60 |
+
{
|
61 |
+
var conditionNameElement = Event.element(event);
|
62 |
+
if (conditionNameElement && conditionNameElement.id) {
|
63 |
+
$('postnl_time_condition').value = '_' + conditionNameElement.value + '/' + Math.random();
|
64 |
+
}
|
65 |
+
}
|
66 |
+
});
|
67 |
+
</script>";
|
68 |
+
|
69 |
+
return $html;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Render the element.
|
74 |
+
*
|
75 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
76 |
+
*
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
80 |
+
{
|
81 |
+
$element->setType('file')
|
82 |
+
->removeClass('input-text');
|
83 |
+
|
84 |
+
$html = parent::render($element);
|
85 |
+
|
86 |
+
$html .= $this->_getJsHtml($element);
|
87 |
+
|
88 |
+
return $html;
|
89 |
+
}
|
90 |
+
}
|
@@ -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,29 @@
|
|
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 |
Â
abstract class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
40 |
-
extends
|
41 |
Â
implements Varien_Data_Form_Element_Renderer_Interface
|
42 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
43 |
Â
/**
|
44 |
Â
* Template file used
|
45 |
-
*
|
46 |
Â
* @var string
|
47 |
Â
*/
|
48 |
Â
protected $_template = '';
|
49 |
-
|
50 |
Â
/**
|
51 |
Â
* Get the element's HTML ID
|
52 |
-
*
|
53 |
Â
* @return string
|
54 |
Â
*/
|
55 |
Â
public function getHtmlId()
|
@@ -57,10 +65,10 @@ abstract class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstr
|
|
57 |
Â
if (!$this->getElement()) {
|
58 |
Â
return '';
|
59 |
Â
}
|
60 |
-
|
61 |
Â
$element = $this->getElement();
|
62 |
Â
$id = $element->getHtmlId();
|
63 |
-
|
64 |
Â
return $id;
|
65 |
Â
}
|
66 |
Â
|
@@ -73,8 +81,7 @@ abstract class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstr
|
|
73 |
Â
public function render(Varien_Data_Form_Element_Abstract $element)
|
74 |
Â
{
|
75 |
Â
$this->setElement($element);
|
76 |
-
|
77 |
Â
return $this->toHtml();
|
78 |
Â
}
|
79 |
Â
}
|
80 |
-
|
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 |
+
* @method Varien_Data_Form_Element_Abstract getElement()
|
40 |
+
* @method TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract setElement(Varien_Data_Form_Element_Abstract $value)
|
41 |
Â
*/
|
42 |
Â
abstract class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
43 |
+
extends TIG_PostNL_Block_Adminhtml_Template
|
44 |
Â
implements Varien_Data_Form_Element_Renderer_Interface
|
45 |
Â
{
|
46 |
+
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_textbox_abstract';
|
50 |
+
|
51 |
Â
/**
|
52 |
Â
* Template file used
|
53 |
+
*
|
54 |
Â
* @var string
|
55 |
Â
*/
|
56 |
Â
protected $_template = '';
|
57 |
+
|
58 |
Â
/**
|
59 |
Â
* Get the element's HTML ID
|
60 |
+
*
|
61 |
Â
* @return string
|
62 |
Â
*/
|
63 |
Â
public function getHtmlId()
|
65 |
Â
if (!$this->getElement()) {
|
66 |
Â
return '';
|
67 |
Â
}
|
68 |
+
|
69 |
Â
$element = $this->getElement();
|
70 |
Â
$id = $element->getHtmlId();
|
71 |
+
|
72 |
Â
return $id;
|
73 |
Â
}
|
74 |
Â
|
81 |
Â
public function render(Varien_Data_Form_Element_Abstract $element)
|
82 |
Â
{
|
83 |
Â
$this->setElement($element);
|
84 |
+
|
85 |
Â
return $this->toHtml();
|
86 |
Â
}
|
87 |
Â
}
|
Â
|
@@ -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.
|
@@ -33,24 +33,24 @@
|
|
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)
|
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_ValidateButton
|
40 |
Â
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
41 |
Â
implements Varien_Data_Form_Element_Renderer_Interface
|
42 |
-
{
|
43 |
Â
/**
|
44 |
Â
* Gets the element's html. In this case: a button redirecting the user to the extensionControl controller
|
45 |
-
*
|
Â
|
|
Â
|
|
46 |
Â
* @return string
|
47 |
Â
*/
|
48 |
Â
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
49 |
Â
{
|
50 |
Â
$this->setElement($element);
|
51 |
-
|
52 |
-
$url = $this->getUrl('postnl/adminhtml_extensionControl/activate');
|
53 |
-
|
54 |
Â
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
55 |
Â
->setId($element->getHtmlId())
|
56 |
Â
->setType('button')
|
@@ -61,12 +61,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
|
61 |
Â
|
62 |
Â
return $html;
|
63 |
Â
}
|
64 |
-
|
65 |
Â
/**
|
66 |
Â
* Render the element without a scope label and without the 'use default' checkbox.
|
67 |
-
*
|
Â
|
|
68 |
Â
* @return string
|
69 |
-
*
|
70 |
Â
* @see parent::render()
|
71 |
Â
*/
|
72 |
Â
public function render(Varien_Data_Form_Element_Abstract $element)
|
@@ -74,7 +75,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
|
74 |
Â
$element->unsScope()
|
75 |
Â
->unsCanUseWebsiteValue()
|
76 |
Â
->unsCanUseDefaultValue();
|
77 |
-
|
78 |
Â
return parent::render($element);
|
79 |
Â
}
|
80 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_ValidateButton
|
40 |
Â
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
41 |
Â
implements Varien_Data_Form_Element_Renderer_Interface
|
42 |
+
{
|
43 |
Â
/**
|
44 |
Â
* Gets the element's html. In this case: a button redirecting the user to the extensionControl controller
|
45 |
+
*
|
46 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
47 |
+
*
|
48 |
Â
* @return string
|
49 |
Â
*/
|
50 |
Â
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
51 |
Â
{
|
52 |
Â
$this->setElement($element);
|
53 |
+
|
Â
|
|
Â
|
|
54 |
Â
$html = $this->getLayout()->createBlock('adminhtml/widget_button')
|
55 |
Â
->setId($element->getHtmlId())
|
56 |
Â
->setType('button')
|
61 |
Â
|
62 |
Â
return $html;
|
63 |
Â
}
|
64 |
+
|
65 |
Â
/**
|
66 |
Â
* Render the element without a scope label and without the 'use default' checkbox.
|
67 |
+
*
|
68 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
69 |
Â
* @return string
|
70 |
+
*
|
71 |
Â
* @see parent::render()
|
72 |
Â
*/
|
73 |
Â
public function render(Varien_Data_Form_Element_Abstract $element)
|
75 |
Â
$element->unsScope()
|
76 |
Â
->unsCanUseWebsiteValue()
|
77 |
Â
->unsCanUseDefaultValue();
|
78 |
+
|
79 |
Â
return parent::render($element);
|
80 |
Â
}
|
81 |
Â
}
|
@@ -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,11 +36,17 @@
|
|
36 |
Â
* @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WarningBox
|
Â
|
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Template file used
|
43 |
-
*
|
44 |
Â
* @var string
|
45 |
Â
*/
|
46 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/warning_box.phtml';
|
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) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
+
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_WarningBox
|
40 |
+
extends TIG_PostNL_Block_Adminhtml_System_Config_Form_Field_TextBox_Abstract
|
41 |
Â
{
|
42 |
+
/**
|
43 |
+
* @var string
|
44 |
+
*/
|
45 |
+
protected $_eventPrefix = 'postnl_adminhtml_system_config_form_field_warningbox';
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* Template file used
|
49 |
+
*
|
50 |
Â
* @var string
|
51 |
Â
*/
|
52 |
Â
protected $_template = 'TIG/PostNL/system/config/form/field/warning_box.phtml';
|
@@ -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.
|
@@ -33,7 +33,7 @@
|
|
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)
|
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_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
@@ -42,7 +42,7 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
42 |
Â
* Return header comment part of html for fieldset
|
43 |
Â
*
|
44 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
45 |
-
*
|
46 |
Â
* @return string
|
47 |
Â
*/
|
48 |
Â
protected function _getHeaderCommentHtml($element)
|
@@ -51,13 +51,13 @@ class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminh
|
|
51 |
Â
if (!$comment) {
|
52 |
Â
return '';
|
53 |
Â
}
|
54 |
-
|
55 |
Â
$commentHtml = '<div class="box">'
|
56 |
Â
. '<p>'
|
57 |
Â
. $comment
|
58 |
Â
. '</p>'
|
59 |
Â
. '</div>';
|
60 |
-
|
61 |
Â
return $commentHtml;
|
62 |
Â
}
|
63 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
42 |
Â
* Return header comment part of html for fieldset
|
43 |
Â
*
|
44 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
45 |
+
*
|
46 |
Â
* @return string
|
47 |
Â
*/
|
48 |
Â
protected function _getHeaderCommentHtml($element)
|
51 |
Â
if (!$comment) {
|
52 |
Â
return '';
|
53 |
Â
}
|
54 |
+
|
55 |
Â
$commentHtml = '<div class="box">'
|
56 |
Â
. '<p>'
|
57 |
Â
. $comment
|
58 |
Â
. '</p>'
|
59 |
Â
. '</div>';
|
60 |
+
|
61 |
Â
return $commentHtml;
|
62 |
Â
}
|
63 |
Â
}
|
@@ -0,0 +1,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
abstract class TIG_PostNL_Block_Adminhtml_Template extends Mage_Adminhtml_Block_Abstract
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_adminhtml_template';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Renders a template block. Also throws 2 events based on the current event prefix.
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
protected function _toHtml()
|
52 |
+
{
|
53 |
+
Mage::dispatchEvent($this->_eventPrefix . '_to_html_before');
|
54 |
+
|
55 |
+
$html = parent::_toHtml();
|
56 |
+
|
57 |
+
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
58 |
+
return $html;
|
59 |
+
}
|
60 |
+
}
|
@@ -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.
|
@@ -33,10 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
41 |
Â
{
|
42 |
Â
/**
|
@@ -46,12 +46,12 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
|
46 |
Â
const COUNTRY_ID_COLUMN = 'country_id';
|
47 |
Â
const LABELS_PRINTED_COLUMN = 'labels_printed';
|
48 |
Â
const CONFIRM_STATUS_COLUMN = 'confirm_status';
|
49 |
-
|
50 |
Â
/**
|
51 |
Â
* Renders column
|
52 |
Â
*
|
53 |
Â
* @param Varien_Object $row
|
54 |
-
*
|
55 |
Â
* @return string
|
56 |
Â
*/
|
57 |
Â
public function render(Varien_Object $row)
|
@@ -60,102 +60,138 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
|
60 |
Â
if (empty($actions) || !is_array($actions)) {
|
61 |
Â
return ' ';
|
62 |
Â
}
|
63 |
-
|
64 |
Â
$actionLinks = array();
|
65 |
Â
foreach ($actions as $action) {
|
66 |
Â
/**
|
67 |
-
* Check if this action is allowed.
|
Â
|
|
Â
|
|
68 |
Â
*/
|
69 |
Â
if (!$this->_isActionAllowed($row, $action)) {
|
70 |
Â
continue;
|
71 |
Â
}
|
72 |
-
|
73 |
-
|
74 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
75 |
Â
if (is_array($action)) {
|
76 |
Â
$actionLinks[] = $this->_toLinkHtml($action, $row);
|
77 |
Â
}
|
78 |
Â
}
|
79 |
-
|
80 |
Â
$output = implode(' / ', $actionLinks);
|
81 |
-
|
82 |
Â
return $output;
|
83 |
Â
}
|
84 |
-
|
85 |
Â
/**
|
86 |
Â
* Checks if a certain action is allowed for this row
|
87 |
-
*
|
88 |
Â
* @param Mage_Sales_Model_Order_Shipment $row
|
89 |
-
* @param array
|
90 |
-
*
|
91 |
Â
* @return boolean
|
92 |
Â
*/
|
93 |
-
protected function _isActionAllowed($row,
|
94 |
Â
{
|
95 |
Â
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
96 |
-
|
97 |
Â
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
98 |
-
|
99 |
Â
/**
|
100 |
Â
* If this is a PostNL action, but this shipment was not shipped using PosTNL, skip it
|
101 |
Â
*/
|
102 |
-
if (array_key_exists('is_postnl', $action)
|
103 |
Â
&& $action['is_postnl']
|
104 |
Â
&& !in_array($shippingMethod, $postnlShippingMethods)
|
105 |
Â
) {
|
Â
|
|
106 |
Â
return false;
|
107 |
Â
}
|
108 |
-
|
Â
|
|
109 |
Â
return true;
|
110 |
Â
}
|
111 |
-
|
112 |
Â
/**
|
113 |
Â
* In some cases an action must be disabled
|
114 |
-
*
|
115 |
Â
* @param Mage_Sales_Model_Order_Shipment $row
|
116 |
-
* @param array
|
117 |
-
*
|
118 |
Â
* @return array
|
119 |
Â
*/
|
120 |
-
protected function
|
121 |
Â
{
|
122 |
-
$helper = Mage::helper('postnl');
|
123 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
124 |
-
|
125 |
-
|
126 |
-
$
|
127 |
-
$countryId = $row->getData(self::COUNTRY_ID_COLUMN);
|
128 |
Â
$confirmStatus = $row->getData(self::CONFIRM_STATUS_COLUMN);
|
129 |
-
|
130 |
Â
/**
|
131 |
-
*
|
132 |
-
|
133 |
-
|
134 |
-
return $action;
|
135 |
-
}
|
136 |
-
|
137 |
-
/**
|
138 |
-
* If the shipment is confirmed, we can't confirm it again
|
139 |
Â
*/
|
140 |
Â
if ($confirmStatus == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
141 |
-
$
|
142 |
-
$action
|
143 |
-
|
144 |
Â
return $action;
|
145 |
Â
}
|
146 |
-
|
147 |
Â
/**
|
148 |
Â
* EU shipments can only confirm after their labels have been printed
|
149 |
Â
*/
|
150 |
Â
if (in_array($countryId, $euCountries)
|
151 |
Â
&& !$row->getData(self::LABELS_PRINTED_COLUMN)
|
152 |
Â
){
|
153 |
-
$
|
154 |
-
$action
|
155 |
-
|
156 |
Â
return $action;
|
157 |
Â
}
|
158 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
159 |
Â
return $action;
|
160 |
Â
}
|
161 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Action
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
41 |
Â
{
|
42 |
Â
/**
|
46 |
Â
const COUNTRY_ID_COLUMN = 'country_id';
|
47 |
Â
const LABELS_PRINTED_COLUMN = 'labels_printed';
|
48 |
Â
const CONFIRM_STATUS_COLUMN = 'confirm_status';
|
49 |
+
|
50 |
Â
/**
|
51 |
Â
* Renders column
|
52 |
Â
*
|
53 |
Â
* @param Varien_Object $row
|
54 |
+
*
|
55 |
Â
* @return string
|
56 |
Â
*/
|
57 |
Â
public function render(Varien_Object $row)
|
60 |
Â
if (empty($actions) || !is_array($actions)) {
|
61 |
Â
return ' ';
|
62 |
Â
}
|
63 |
+
|
64 |
Â
$actionLinks = array();
|
65 |
Â
foreach ($actions as $action) {
|
66 |
Â
/**
|
67 |
+
* Check if this action is allowed.
|
68 |
+
*
|
69 |
+
* @var Mage_Sales_Model_Order_Shipment $row
|
70 |
Â
*/
|
71 |
Â
if (!$this->_isActionAllowed($row, $action)) {
|
72 |
Â
continue;
|
73 |
Â
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* The confirm action may need to be disabled.
|
77 |
+
*/
|
78 |
+
if (isset($action['code']) && $action['code'] == 'postnl_confirm') {
|
79 |
+
$action = $this->_checkDisableAction($row, $action);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* The print label action needs to use a custom onclick event.
|
84 |
+
*/
|
85 |
+
if (isset($action['code']) && $action['code'] == 'postnl_print_label') {
|
86 |
+
$printLabelUrl = $this->getUrl(
|
87 |
+
'postnl_admin/adminhtml_shipment/printLabel',
|
88 |
+
array('shipment_id' => $row->getId())
|
89 |
+
);
|
90 |
+
|
91 |
+
$action['onClick'] = "printLabel('{$printLabelUrl}')";
|
92 |
+
}
|
93 |
+
|
94 |
+
if (isset($action['code'])) {
|
95 |
+
unset($action['code']);
|
96 |
+
}
|
97 |
+
|
98 |
Â
if (is_array($action)) {
|
99 |
Â
$actionLinks[] = $this->_toLinkHtml($action, $row);
|
100 |
Â
}
|
101 |
Â
}
|
102 |
+
|
103 |
Â
$output = implode(' / ', $actionLinks);
|
104 |
+
|
105 |
Â
return $output;
|
106 |
Â
}
|
107 |
+
|
108 |
Â
/**
|
109 |
Â
* Checks if a certain action is allowed for this row
|
110 |
+
*
|
111 |
Â
* @param Mage_Sales_Model_Order_Shipment $row
|
112 |
+
* @param array &$action
|
113 |
+
*
|
114 |
Â
* @return boolean
|
115 |
Â
*/
|
116 |
+
protected function _isActionAllowed($row, &$action)
|
117 |
Â
{
|
118 |
Â
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
119 |
+
|
120 |
Â
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
121 |
+
|
122 |
Â
/**
|
123 |
Â
* If this is a PostNL action, but this shipment was not shipped using PosTNL, skip it
|
124 |
Â
*/
|
125 |
+
if (array_key_exists('is_postnl', $action)
|
126 |
Â
&& $action['is_postnl']
|
127 |
Â
&& !in_array($shippingMethod, $postnlShippingMethods)
|
128 |
Â
) {
|
129 |
+
unset($action['is_postnl']);
|
130 |
Â
return false;
|
131 |
Â
}
|
132 |
+
|
133 |
+
unset($action['is_postnl']);
|
134 |
Â
return true;
|
135 |
Â
}
|
136 |
+
|
137 |
Â
/**
|
138 |
Â
* In some cases an action must be disabled
|
139 |
+
*
|
140 |
Â
* @param Mage_Sales_Model_Order_Shipment $row
|
141 |
+
* @param array $action
|
142 |
+
*
|
143 |
Â
* @return array
|
144 |
Â
*/
|
145 |
+
protected function _checkDisableAction($row, $action)
|
146 |
Â
{
|
147 |
+
$helper = Mage::helper('postnl/cif');
|
148 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
149 |
+
|
150 |
+
$euCountries = $helper->getEuCountries();
|
151 |
+
$countryId = $row->getData(self::COUNTRY_ID_COLUMN);
|
Â
|
|
152 |
Â
$confirmStatus = $row->getData(self::CONFIRM_STATUS_COLUMN);
|
153 |
+
|
154 |
Â
/**
|
155 |
+
* If the shipment is confirmed, we can't confirm it again.
|
156 |
+
*
|
157 |
+
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
158 |
Â
*/
|
159 |
Â
if ($confirmStatus == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
160 |
+
$message = $helper->__('This shipment has already been confirmed.');
|
161 |
+
$action = $this->_disableAction($action, $message);
|
162 |
+
|
163 |
Â
return $action;
|
164 |
Â
}
|
165 |
+
|
166 |
Â
/**
|
167 |
Â
* EU shipments can only confirm after their labels have been printed
|
168 |
Â
*/
|
169 |
Â
if (in_array($countryId, $euCountries)
|
170 |
Â
&& !$row->getData(self::LABELS_PRINTED_COLUMN)
|
171 |
Â
){
|
172 |
+
$message = $helper->__("You must first print a shipping label for this shipment.");
|
173 |
+
$action = $this->_disableAction($action, $message);
|
174 |
+
|
175 |
Â
return $action;
|
176 |
Â
}
|
177 |
+
|
178 |
+
return $action;
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Disable a specified action.
|
183 |
+
*
|
184 |
+
* @param array $action
|
185 |
+
* @param string $message
|
186 |
+
*
|
187 |
+
* @return array
|
188 |
+
*/
|
189 |
+
protected function _disableAction($action, $message = '')
|
190 |
+
{
|
191 |
+
$action['style'] = 'color:gray; cursor:not-allowed;';
|
192 |
+
$action['onClick'] = 'return false;';
|
193 |
+
$action['title'] = $message;
|
194 |
+
|
195 |
Â
return $action;
|
196 |
Â
}
|
197 |
Â
}
|
@@ -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.
|
@@ -33,10 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
Â
{
|
42 |
Â
/**
|
@@ -46,14 +46,14 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
46 |
Â
const POSTCODE_COLUMN = 'postcode';
|
47 |
Â
const COUNTRY_ID_COLUMN = 'country_id';
|
48 |
Â
const CONFIRM_STATUS_COLUMN = 'confirm_status';
|
49 |
-
|
50 |
Â
/**
|
51 |
Â
* Renders the barcode column. This column will be empty for non-PostNL shipments.
|
52 |
-
* If the shipment has been confirmed, it will be displayed as a track& trace URL.
|
53 |
Â
* Otherwise the bare code will be displayed.
|
54 |
Â
*
|
55 |
Â
* @param Varien_Object $row
|
56 |
-
*
|
57 |
Â
* @return string
|
58 |
Â
*/
|
59 |
Â
public function render(Varien_Object $row)
|
@@ -66,7 +66,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
66 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
67 |
Â
return parent::render($row);
|
68 |
Â
}
|
69 |
-
|
70 |
Â
/**
|
71 |
Â
* Check if any data is available
|
72 |
Â
*/
|
@@ -75,15 +75,17 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
75 |
Â
$value = Mage::helper('postnl')->__('No barcode available.');
|
76 |
Â
return $value;
|
77 |
Â
}
|
78 |
-
|
79 |
Â
/**
|
80 |
-
* If the shipment hasn't been confirmed yet, the barcode will not be known by PostNL track & trace
|
Â
|
|
Â
|
|
81 |
Â
*/
|
82 |
Â
$postnlShipmentClassName = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
83 |
Â
if ($row->getData(self::CONFIRM_STATUS_COLUMN) != $postnlShipmentClassName::CONFIRM_STATUS_CONFIRMED) {
|
84 |
Â
return $value;
|
85 |
Â
}
|
86 |
-
|
87 |
Â
/**
|
88 |
Â
* Create a track & trace URL based on shipping destination
|
89 |
Â
*/
|
@@ -93,11 +95,11 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
|
93 |
Â
'countryCode' => $countryCode,
|
94 |
Â
'postcode' => $postcode,
|
95 |
Â
);
|
96 |
-
|
97 |
Â
$barcodeUrl = Mage::helper('postnl/carrier')->getBarcodeUrl($value, $destinationData, false, true);
|
98 |
-
|
99 |
Â
$barcodeHtml = "<a href='{$barcodeUrl}' target='_blank'>{$value}</a>";
|
100 |
-
|
101 |
Â
return $barcodeHtml;
|
102 |
Â
}
|
103 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Barcode
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
Â
{
|
42 |
Â
/**
|
46 |
Â
const POSTCODE_COLUMN = 'postcode';
|
47 |
Â
const COUNTRY_ID_COLUMN = 'country_id';
|
48 |
Â
const CONFIRM_STATUS_COLUMN = 'confirm_status';
|
49 |
+
|
50 |
Â
/**
|
51 |
Â
* Renders the barcode column. This column will be empty for non-PostNL shipments.
|
52 |
+
* If the shipment has been confirmed, it will be displayed as a track& trace URL.
|
53 |
Â
* Otherwise the bare code will be displayed.
|
54 |
Â
*
|
55 |
Â
* @param Varien_Object $row
|
56 |
+
*
|
57 |
Â
* @return string
|
58 |
Â
*/
|
59 |
Â
public function render(Varien_Object $row)
|
66 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
67 |
Â
return parent::render($row);
|
68 |
Â
}
|
69 |
+
|
70 |
Â
/**
|
71 |
Â
* Check if any data is available
|
72 |
Â
*/
|
75 |
Â
$value = Mage::helper('postnl')->__('No barcode available.');
|
76 |
Â
return $value;
|
77 |
Â
}
|
78 |
+
|
79 |
Â
/**
|
80 |
+
* If the shipment hasn't been confirmed yet, the barcode will not be known by PostNL track & trace.
|
81 |
+
*
|
82 |
+
* @var $postnlShipmentClassName TIG_PostNL_Model_Core_Shipment
|
83 |
Â
*/
|
84 |
Â
$postnlShipmentClassName = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
85 |
Â
if ($row->getData(self::CONFIRM_STATUS_COLUMN) != $postnlShipmentClassName::CONFIRM_STATUS_CONFIRMED) {
|
86 |
Â
return $value;
|
87 |
Â
}
|
88 |
+
|
89 |
Â
/**
|
90 |
Â
* Create a track & trace URL based on shipping destination
|
91 |
Â
*/
|
95 |
Â
'countryCode' => $countryCode,
|
96 |
Â
'postcode' => $postcode,
|
97 |
Â
);
|
98 |
+
|
99 |
Â
$barcodeUrl = Mage::helper('postnl/carrier')->getBarcodeUrl($value, $destinationData, false, true);
|
100 |
+
|
101 |
Â
$barcodeHtml = "<a href='{$barcodeUrl}' target='_blank'>{$value}</a>";
|
102 |
+
|
103 |
Â
return $barcodeHtml;
|
104 |
Â
}
|
105 |
Â
}
|
@@ -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.
|
@@ -33,10 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Date
|
41 |
Â
{
|
42 |
Â
/**
|
@@ -44,12 +44,12 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
|
44 |
Â
*/
|
45 |
Â
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
Â
const CONFIRM_STATUS_COLUMN = 'confirm_status';
|
47 |
-
|
48 |
Â
/**
|
49 |
Â
* Renders column.
|
50 |
Â
*
|
51 |
Â
* @param Varien_Object $row
|
52 |
-
*
|
53 |
Â
* @return string
|
54 |
Â
*/
|
55 |
Â
public function render(Varien_Object $row)
|
@@ -59,46 +59,46 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
|
59 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
60 |
Â
return parent::render($row);
|
61 |
Â
}
|
62 |
-
|
63 |
Â
$value = $row->getData($this->getColumn()->getIndex());
|
64 |
Â
$now = date('Ymd', Mage::getModel('core/date')->gmtTimestamp());
|
65 |
-
|
66 |
Â
/**
|
67 |
Â
* Check if the shipment should be confirmed today
|
68 |
Â
*/
|
69 |
Â
if ($now == date('Ymd', strtotime($value))) {
|
70 |
Â
return Mage::helper('postnl')->__('Today');
|
71 |
Â
}
|
72 |
-
|
73 |
Â
/**
|
74 |
Â
* Check if the shipment should be confirmed somewhere in the future
|
75 |
Â
*/
|
76 |
Â
if ($now < date('Ymd', strtotime($value))) {
|
77 |
Â
$confirmDate = new DateTime($value);
|
78 |
Â
$today = new DateTime($now);
|
79 |
-
|
80 |
Â
/**
|
81 |
Â
* Get the number of days until the shipment should be confirmed
|
82 |
Â
*/
|
83 |
Â
$diff = $today->diff($confirmDate)->format('%a');
|
84 |
-
|
85 |
Â
/**
|
86 |
Â
* Check if it should be confirmed tomorrow
|
87 |
Â
*/
|
88 |
Â
if ($diff == 1) {
|
89 |
Â
$renderedValue = Mage::helper('postnl')->__('Tomorrow');
|
90 |
-
|
91 |
Â
return $renderedValue;
|
92 |
Â
}
|
93 |
-
|
94 |
Â
/**
|
95 |
Â
* Render the number of days before the shipment should be confirmed
|
96 |
Â
*/
|
97 |
Â
$renderedValue = Mage::helper('postnl')->__('%s days from now', $diff);
|
98 |
-
|
99 |
Â
return $renderedValue;
|
100 |
Â
}
|
101 |
-
|
102 |
Â
/**
|
103 |
Â
* Finally, simply render the date
|
104 |
Â
*/
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmDate
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Date
|
41 |
Â
{
|
42 |
Â
/**
|
44 |
Â
*/
|
45 |
Â
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
Â
const CONFIRM_STATUS_COLUMN = 'confirm_status';
|
47 |
+
|
48 |
Â
/**
|
49 |
Â
* Renders column.
|
50 |
Â
*
|
51 |
Â
* @param Varien_Object $row
|
52 |
+
*
|
53 |
Â
* @return string
|
54 |
Â
*/
|
55 |
Â
public function render(Varien_Object $row)
|
59 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
60 |
Â
return parent::render($row);
|
61 |
Â
}
|
62 |
+
|
63 |
Â
$value = $row->getData($this->getColumn()->getIndex());
|
64 |
Â
$now = date('Ymd', Mage::getModel('core/date')->gmtTimestamp());
|
65 |
+
|
66 |
Â
/**
|
67 |
Â
* Check if the shipment should be confirmed today
|
68 |
Â
*/
|
69 |
Â
if ($now == date('Ymd', strtotime($value))) {
|
70 |
Â
return Mage::helper('postnl')->__('Today');
|
71 |
Â
}
|
72 |
+
|
73 |
Â
/**
|
74 |
Â
* Check if the shipment should be confirmed somewhere in the future
|
75 |
Â
*/
|
76 |
Â
if ($now < date('Ymd', strtotime($value))) {
|
77 |
Â
$confirmDate = new DateTime($value);
|
78 |
Â
$today = new DateTime($now);
|
79 |
+
|
80 |
Â
/**
|
81 |
Â
* Get the number of days until the shipment should be confirmed
|
82 |
Â
*/
|
83 |
Â
$diff = $today->diff($confirmDate)->format('%a');
|
84 |
+
|
85 |
Â
/**
|
86 |
Â
* Check if it should be confirmed tomorrow
|
87 |
Â
*/
|
88 |
Â
if ($diff == 1) {
|
89 |
Â
$renderedValue = Mage::helper('postnl')->__('Tomorrow');
|
90 |
+
|
91 |
Â
return $renderedValue;
|
92 |
Â
}
|
93 |
+
|
94 |
Â
/**
|
95 |
Â
* Render the number of days before the shipment should be confirmed
|
96 |
Â
*/
|
97 |
Â
$renderedValue = Mage::helper('postnl')->__('%s days from now', $diff);
|
98 |
+
|
99 |
Â
return $renderedValue;
|
100 |
Â
}
|
101 |
+
|
102 |
Â
/**
|
103 |
Â
* Finally, simply render the date
|
104 |
Â
*/
|
@@ -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,19 +36,19 @@
|
|
36 |
Â
* @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
-
{
|
42 |
Â
/**
|
43 |
Â
* Additional column names used
|
44 |
Â
*/
|
45 |
Â
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
-
|
47 |
Â
/**
|
48 |
Â
* Renders the column value as a Yes or No value
|
49 |
Â
*
|
50 |
Â
* @param Varien_Object $row
|
51 |
-
*
|
52 |
Â
* @return string
|
53 |
Â
*/
|
54 |
Â
public function render(Varien_Object $row)
|
@@ -61,7 +61,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
|
61 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
62 |
Â
return parent::render($row);
|
63 |
Â
}
|
64 |
-
|
65 |
Â
/**
|
66 |
Â
* Check if any data is available
|
67 |
Â
*/
|
@@ -69,20 +69,23 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
|
69 |
Â
if (is_null($value) || $value === '') {
|
70 |
Â
return parent::render($row);
|
71 |
Â
}
|
72 |
-
|
Â
|
|
Â
|
|
Â
|
|
73 |
Â
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
74 |
Â
if ($value == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
75 |
Â
$value = Mage::helper('postnl')->__('Confirmed');
|
76 |
Â
return $value;
|
77 |
Â
}
|
78 |
-
|
79 |
Â
if ($value == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
|
80 |
Â
$value = Mage::helper('postnl')->__('Unconfirmed');
|
81 |
Â
return $value;
|
82 |
Â
}
|
83 |
-
|
84 |
Â
$value = Mage::helper('postnl')->__('Confirmation Expired');
|
85 |
-
|
86 |
Â
return $value;
|
87 |
Â
}
|
88 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
36 |
Â
* @copyright Copyright (c) 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ConfirmStatus
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
+
{
|
42 |
Â
/**
|
43 |
Â
* Additional column names used
|
44 |
Â
*/
|
45 |
Â
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* Renders the column value as a Yes or No value
|
49 |
Â
*
|
50 |
Â
* @param Varien_Object $row
|
51 |
+
*
|
52 |
Â
* @return string
|
53 |
Â
*/
|
54 |
Â
public function render(Varien_Object $row)
|
61 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
62 |
Â
return parent::render($row);
|
63 |
Â
}
|
64 |
+
|
65 |
Â
/**
|
66 |
Â
* Check if any data is available
|
67 |
Â
*/
|
69 |
Â
if (is_null($value) || $value === '') {
|
70 |
Â
return parent::render($row);
|
71 |
Â
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
75 |
+
*/
|
76 |
Â
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
77 |
Â
if ($value == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
78 |
Â
$value = Mage::helper('postnl')->__('Confirmed');
|
79 |
Â
return $value;
|
80 |
Â
}
|
81 |
+
|
82 |
Â
if ($value == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
|
83 |
Â
$value = Mage::helper('postnl')->__('Unconfirmed');
|
84 |
Â
return $value;
|
85 |
Â
}
|
86 |
+
|
87 |
Â
$value = Mage::helper('postnl')->__('Confirmation Expired');
|
88 |
+
|
89 |
Â
return $value;
|
90 |
Â
}
|
91 |
Â
}
|
@@ -0,0 +1,80 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_DeliveryDate
|
40 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Date
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* Additional column names used
|
44 |
+
*/
|
45 |
+
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
+
const CONFIRM_DATE_COLUMN = 'confirm_date';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Renders column.
|
50 |
+
*
|
51 |
+
* @param Varien_Object $row
|
52 |
+
*
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function render(Varien_Object $row)
|
56 |
+
{
|
57 |
+
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
58 |
+
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
59 |
+
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
60 |
+
return parent::render($row);
|
61 |
+
}
|
62 |
+
|
63 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
64 |
+
|
65 |
+
/**
|
66 |
+
* If no delivery date is specified, calculate the date as being 1 day after the confirm date
|
67 |
+
*/
|
68 |
+
if (!$value) {
|
69 |
+
$confirmDate = $row->getData(self::CONFIRM_DATE_COLUMN);
|
70 |
+
$deliveryDate = date('Y-m-d H:i:s', strtotime($confirmDate . ' + 1 day'));
|
71 |
+
|
72 |
+
$row->setData($this->getColumn()->getIndex(), $deliveryDate);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Finally, simply render the date
|
77 |
+
*/
|
78 |
+
return parent::render($row);
|
79 |
+
}
|
80 |
+
}
|
@@ -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.
|
@@ -33,27 +33,34 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShipmentType
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
-
{
|
42 |
Â
/**
|
43 |
Â
* Additional column names used
|
44 |
Â
*/
|
45 |
-
const SHIPPING_METHOD_COLUMN
|
46 |
-
const IS_PAKJE_GEMAK_COLUMN
|
47 |
-
|
Â
|
|
Â
|
|
48 |
Â
/**
|
49 |
Â
* Renders the column value as a shipment type value (Domestic, EPS or GlobalPack)
|
50 |
Â
*
|
51 |
Â
* @param Varien_Object $row
|
52 |
-
*
|
53 |
Â
* @return string
|
54 |
Â
*/
|
55 |
Â
public function render(Varien_Object $row)
|
56 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
57 |
Â
/**
|
58 |
Â
* The shipment was not shipped using PostNL
|
59 |
Â
*/
|
@@ -62,70 +69,116 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShipmentType
|
|
62 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
63 |
Â
return '';
|
64 |
Â
}
|
65 |
-
|
66 |
Â
/**
|
67 |
-
* Check if any data is available
|
68 |
Â
*/
|
69 |
-
$value = $row->getData($
|
70 |
Â
if (is_null($value) || $value === '') {
|
71 |
Â
return '';
|
72 |
Â
}
|
73 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
74 |
Â
if ($row->getData(self::IS_PAKJE_GEMAK_COLUMN)) {
|
75 |
-
$
|
76 |
-
|
Â
|
|
Â
|
|
Â
|
|
77 |
Â
return $renderedValue;
|
78 |
Â
}
|
79 |
-
|
80 |
Â
/**
|
81 |
-
* Check if this order is domestic
|
82 |
Â
*/
|
83 |
Â
if ($value == 'NL') {
|
84 |
-
$
|
85 |
-
|
Â
|
|
Â
|
|
Â
|
|
86 |
Â
return $renderedValue;
|
87 |
Â
}
|
88 |
-
|
89 |
Â
/**
|
90 |
-
* Check if this order's shipping address is in an EU country
|
91 |
Â
*/
|
92 |
-
$euCountries =
|
93 |
Â
if (in_array($value, $euCountries)) {
|
94 |
-
$
|
95 |
-
|
Â
|
|
Â
|
|
Â
|
|
96 |
Â
return $renderedValue;
|
97 |
Â
}
|
98 |
-
|
99 |
Â
/**
|
100 |
-
* If none of the above, it's an international order
|
101 |
Â
*/
|
102 |
-
$
|
103 |
-
|
104 |
-
|
Â
|
|
Â
|
|
105 |
Â
return $renderedValue;
|
106 |
Â
}
|
107 |
Â
|
108 |
Â
/**
|
109 |
-
* Renders the <col> element of the column. Added check for $this->getColumn()->getDisplay() == 'none' that causes
|
110 |
-
* entire element to be hidden
|
111 |
-
*
|
112 |
Â
* @return string
|
113 |
-
*
|
114 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract::renderProperty()
|
115 |
Â
*/
|
116 |
Â
public function renderProperty()
|
117 |
Â
{
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
Â
$out = '';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
125 |
Â
$width = $this->_defaultWidth;
|
126 |
Â
|
127 |
-
if ($
|
128 |
-
$customWidth = $
|
129 |
Â
if ((null === $customWidth) || (preg_match('/^[0-9]+%?$/', $customWidth))) {
|
130 |
Â
$width = $customWidth;
|
131 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShipmentType
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
+
{
|
42 |
Â
/**
|
43 |
Â
* Additional column names used
|
44 |
Â
*/
|
45 |
+
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
+
const IS_PAKJE_GEMAK_COLUMN = 'is_pakje_gemak';
|
47 |
+
const IS_PAKKETAUTOMAAT_COLUMN = 'is_pakketautomaat';
|
48 |
+
const DELIVERY_OPTION_TYPE_COLUMN = 'delivery_option_type';
|
49 |
+
|
50 |
Â
/**
|
51 |
Â
* Renders the column value as a shipment type value (Domestic, EPS or GlobalPack)
|
52 |
Â
*
|
53 |
Â
* @param Varien_Object $row
|
54 |
+
*
|
55 |
Â
* @return string
|
56 |
Â
*/
|
57 |
Â
public function render(Varien_Object $row)
|
58 |
Â
{
|
59 |
+
/**
|
60 |
+
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
61 |
+
*/
|
62 |
+
$column = $this->getColumn();
|
63 |
+
|
64 |
Â
/**
|
65 |
Â
* The shipment was not shipped using PostNL
|
66 |
Â
*/
|
69 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
70 |
Â
return '';
|
71 |
Â
}
|
72 |
+
|
73 |
Â
/**
|
74 |
+
* Check if any data is available.
|
75 |
Â
*/
|
76 |
+
$value = $row->getData($column->getIndex());
|
77 |
Â
if (is_null($value) || $value === '') {
|
78 |
Â
return '';
|
79 |
Â
}
|
80 |
+
|
81 |
+
$helper = Mage::helper('postnl/cif');
|
82 |
+
|
83 |
+
$optionType = $row->getData(self::DELIVERY_OPTION_TYPE_COLUMN);
|
84 |
+
if ($optionType == 'Avond') {
|
85 |
+
$label = $helper->__('Domestic');
|
86 |
+
$comment = $helper->__('Evening Delivery');
|
87 |
+
|
88 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>avond</div><b>{$label}"
|
89 |
+
. "</b><br /><em>{$comment}</em>";
|
90 |
+
|
91 |
+
return $renderedValue;
|
92 |
+
}
|
93 |
+
|
94 |
+
if ($optionType == 'PGE') {
|
95 |
+
$label = $helper->__('Post Office');
|
96 |
+
$comment = $helper->__('Early Pickup');
|
97 |
+
|
98 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>pakje_gemak_express"
|
99 |
+
. "</div><b>{$label}</b><br /><em>{$comment}</em>";
|
100 |
+
|
101 |
+
return $renderedValue;
|
102 |
+
}
|
103 |
+
|
104 |
+
if ($row->getData(self::IS_PAKKETAUTOMAAT_COLUMN)) {
|
105 |
+
$label = $helper->__('Parcel Dispenser');
|
106 |
+
|
107 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>pakketautomaat</div><b>"
|
108 |
+
. "{$label}</b>";
|
109 |
+
|
110 |
+
return $renderedValue;
|
111 |
+
}
|
112 |
+
|
113 |
Â
if ($row->getData(self::IS_PAKJE_GEMAK_COLUMN)) {
|
114 |
+
$label = $helper->__('Post Office');
|
115 |
+
|
116 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>pakje_gemak</div><b>"
|
117 |
+
. "{$label}</b>";
|
118 |
+
|
119 |
Â
return $renderedValue;
|
120 |
Â
}
|
121 |
+
|
122 |
Â
/**
|
123 |
+
* Check if this order is domestic.
|
124 |
Â
*/
|
125 |
Â
if ($value == 'NL') {
|
126 |
+
$label = $helper->__('Domestic');
|
127 |
+
|
128 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>standard</div><b>"
|
129 |
+
. "{$label}</b>";
|
130 |
+
|
131 |
Â
return $renderedValue;
|
132 |
Â
}
|
133 |
+
|
134 |
Â
/**
|
135 |
+
* Check if this order's shipping address is in an EU country.
|
136 |
Â
*/
|
137 |
+
$euCountries = $helper->getEuCountries();
|
138 |
Â
if (in_array($value, $euCountries)) {
|
139 |
+
$label = $helper->__('EPS');
|
140 |
+
|
141 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>eps</div><b>{$label}"
|
142 |
+
. "</b>";
|
143 |
+
|
144 |
Â
return $renderedValue;
|
145 |
Â
}
|
146 |
+
|
147 |
Â
/**
|
148 |
+
* If none of the above apply, it's an international order.
|
149 |
Â
*/
|
150 |
+
$label = $helper->__('GlobalPack');
|
151 |
+
|
152 |
+
$renderedValue = "<div id='postnl-shipmenttype-{$row->getId()}' class='no-display'>global_pack</div><b>{$label}"
|
153 |
+
. "</b>";
|
154 |
+
|
155 |
Â
return $renderedValue;
|
156 |
Â
}
|
157 |
Â
|
158 |
Â
/**
|
159 |
+
* Renders the <col> element of the column. Added check for $this->getColumn()->getDisplay() == 'none' that causes
|
160 |
+
* the entire element to be hidden.
|
161 |
+
*
|
162 |
Â
* @return string
|
163 |
+
*
|
164 |
Â
* @see Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract::renderProperty()
|
165 |
Â
*/
|
166 |
Â
public function renderProperty()
|
167 |
Â
{
|
168 |
+
/**
|
169 |
+
* @var Mage_Adminhtml_Block_Widget_Grid_Column $column
|
170 |
+
*/
|
171 |
+
$column = $this->getColumn();
|
172 |
+
|
Â
|
|
173 |
Â
$out = '';
|
174 |
+
if ($column->hasData('display')) {
|
175 |
+
$out .= " style='display:{$column->getDisplay()};'";
|
176 |
+
}
|
177 |
+
|
178 |
Â
$width = $this->_defaultWidth;
|
179 |
Â
|
180 |
+
if ($column->hasData('width')) {
|
181 |
+
$customWidth = $column->getData('width');
|
182 |
Â
if ((null === $customWidth) || (preg_match('/^[0-9]+%?$/', $customWidth))) {
|
183 |
Â
$width = $customWidth;
|
184 |
Â
}
|
@@ -0,0 +1,123 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingDescription
|
40 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* Additional column names used
|
44 |
+
*/
|
45 |
+
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
+
const PRODUCT_CODE_COLUMN = 'product_code';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Renders the column value as a Yes or No value
|
50 |
+
*
|
51 |
+
* @param Varien_Object $row
|
52 |
+
*
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function render(Varien_Object $row)
|
56 |
+
{
|
57 |
+
/**
|
58 |
+
* The shipment was not shipped using PostNL
|
59 |
+
*/
|
60 |
+
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
61 |
+
$shippingMethod = $row->getData(self::SHIPPING_METHOD_COLUMN);
|
62 |
+
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
63 |
+
return parent::render($row);
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check if any data is available
|
68 |
+
*/
|
69 |
+
$value = $row->getData($this->getColumn()->getIndex());
|
70 |
+
if (is_null($value) || $value === '') {
|
71 |
+
return parent::render($row);
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Get this row's product code and join it to this cell.
|
76 |
+
*/
|
77 |
+
$productCode = $this->getProductCode($row);
|
78 |
+
$renderedvalue = '<strong>'
|
79 |
+
. parent::render($row)
|
80 |
+
. '</strong><br />'
|
81 |
+
. $productCode;
|
82 |
+
|
83 |
+
return $renderedvalue;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Get product_code column contents.
|
88 |
+
*
|
89 |
+
* @param Varien_Object $row
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*
|
93 |
+
* @see Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Options::render()
|
94 |
+
*/
|
95 |
+
public function getProductCode(Varien_Object $row)
|
96 |
+
{
|
97 |
+
$options = $this->getColumn()->getOptions();
|
98 |
+
$showMissingOptionValues = (bool)$this->getColumn()->getShowMissingOptionValues();
|
99 |
+
|
100 |
+
$value = '';
|
101 |
+
if (empty($options) || !is_array($options)) {
|
102 |
+
return $value;
|
103 |
+
}
|
104 |
+
|
105 |
+
$value = $row->getData(self::PRODUCT_CODE_COLUMN);
|
106 |
+
if (is_array($value)) {
|
107 |
+
$res = array();
|
108 |
+
foreach ($value as $item) {
|
109 |
+
if (isset($options[$item])) {
|
110 |
+
$res[] = $this->escapeHtml($options[$item]);
|
111 |
+
}
|
112 |
+
elseif ($showMissingOptionValues) {
|
113 |
+
$res[] = $this->escapeHtml($item);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
return implode(', ', $res);
|
117 |
+
} elseif (isset($options[$value])) {
|
118 |
+
return $this->escapeHtml($options[$value]);
|
119 |
+
}
|
120 |
+
|
121 |
+
return $this->escapeHtml($value);
|
122 |
+
}
|
123 |
+
}
|
@@ -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.
|
@@ -33,32 +33,32 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingPhase
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
-
{
|
42 |
Â
/**
|
43 |
Â
* Renders the column value as a human readable value
|
44 |
Â
*
|
45 |
Â
* @param Varien_Object $row
|
46 |
-
*
|
47 |
Â
* @return string
|
48 |
Â
*/
|
49 |
Â
public function render(Varien_Object $row)
|
50 |
Â
{
|
51 |
Â
$value = $row->getData($this->getColumn()->getIndex());
|
52 |
-
|
53 |
Â
if (empty($value)) {
|
54 |
Â
return '';
|
55 |
Â
}
|
56 |
-
|
57 |
Â
$shippingPhases = Mage::helper('postnl/cif')->getShippingPhases();
|
58 |
Â
if (array_key_exists($value, $shippingPhases)) {
|
59 |
Â
$value = $shippingPhases[$value];
|
60 |
Â
}
|
61 |
-
|
62 |
Â
return Mage::helper('postnl')->__($value);
|
63 |
Â
}
|
64 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_ShippingPhase
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
+
{
|
42 |
Â
/**
|
43 |
Â
* Renders the column value as a human readable value
|
44 |
Â
*
|
45 |
Â
* @param Varien_Object $row
|
46 |
+
*
|
47 |
Â
* @return string
|
48 |
Â
*/
|
49 |
Â
public function render(Varien_Object $row)
|
50 |
Â
{
|
51 |
Â
$value = $row->getData($this->getColumn()->getIndex());
|
52 |
+
|
53 |
Â
if (empty($value)) {
|
54 |
Â
return '';
|
55 |
Â
}
|
56 |
+
|
57 |
Â
$shippingPhases = Mage::helper('postnl/cif')->getShippingPhases();
|
58 |
Â
if (array_key_exists($value, $shippingPhases)) {
|
59 |
Â
$value = $shippingPhases[$value];
|
60 |
Â
}
|
61 |
+
|
62 |
Â
return Mage::helper('postnl')->__($value);
|
63 |
Â
}
|
64 |
Â
}
|
@@ -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.
|
@@ -33,12 +33,12 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
41 |
-
{
|
42 |
Â
/**
|
43 |
Â
* Date format string
|
44 |
Â
*/
|
@@ -47,7 +47,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
|
47 |
Â
/**
|
48 |
Â
* Retrieve datetime format
|
49 |
Â
*
|
50 |
-
* @return
|
51 |
Â
*/
|
52 |
Â
protected function _getFormat()
|
53 |
Â
{
|
@@ -72,21 +72,25 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
|
72 |
Â
* Renders grid column
|
73 |
Â
*
|
74 |
Â
* @param Varien_Object $row
|
Â
|
|
75 |
Â
* @return string
|
76 |
Â
*/
|
77 |
Â
public function render(Varien_Object $row)
|
78 |
Â
{
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
}
|
90 |
-
return $
|
91 |
Â
}
|
92 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Time
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
41 |
+
{
|
42 |
Â
/**
|
43 |
Â
* Date format string
|
44 |
Â
*/
|
47 |
Â
/**
|
48 |
Â
* Retrieve datetime format
|
49 |
Â
*
|
50 |
+
* @return string
|
51 |
Â
*/
|
52 |
Â
protected function _getFormat()
|
53 |
Â
{
|
72 |
Â
* Renders grid column
|
73 |
Â
*
|
74 |
Â
* @param Varien_Object $row
|
75 |
+
*
|
76 |
Â
* @return string
|
77 |
Â
*/
|
78 |
Â
public function render(Varien_Object $row)
|
79 |
Â
{
|
80 |
+
$data = $this->_getValue($row);
|
81 |
+
if (!$data) {
|
82 |
+
return $this->getColumn()->getDefault();
|
83 |
+
}
|
84 |
+
|
85 |
+
$format = $this->_getFormat();
|
86 |
+
try {
|
87 |
+
$data = Mage::app()->getLocale()
|
88 |
+
->date($data, Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($format);
|
89 |
+
} catch (Exception $e) {
|
90 |
+
Mage::helper('postnl')->logException($e);
|
91 |
+
|
92 |
+
return $this->getColumn()->getDefault();
|
93 |
Â
}
|
94 |
+
return $data;
|
95 |
Â
}
|
96 |
Â
}
|
@@ -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.
|
@@ -33,24 +33,24 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Translate
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
-
{
|
42 |
Â
/**
|
43 |
-
* Translate the column's value before rendering it
|
44 |
Â
*
|
45 |
Â
* @param Varien_Object $row
|
46 |
-
*
|
47 |
Â
* @return string
|
48 |
Â
*/
|
49 |
Â
public function render(Varien_Object $row)
|
50 |
Â
{
|
51 |
Â
$helper = Mage::helper('postnl');
|
52 |
Â
$value = $row->getData($this->getColumn()->getIndex());
|
53 |
-
|
54 |
Â
return $helper->__($value);
|
55 |
Â
}
|
56 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_Translate
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
+
{
|
42 |
Â
/**
|
43 |
+
* Translate the column's value before rendering it.
|
44 |
Â
*
|
45 |
Â
* @param Varien_Object $row
|
46 |
+
*
|
47 |
Â
* @return string
|
48 |
Â
*/
|
49 |
Â
public function render(Varien_Object $row)
|
50 |
Â
{
|
51 |
Â
$helper = Mage::helper('postnl');
|
52 |
Â
$value = $row->getData($this->getColumn()->getIndex());
|
53 |
+
|
54 |
Â
return $helper->__($value);
|
55 |
Â
}
|
56 |
Â
}
|
@@ -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.
|
@@ -33,22 +33,22 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
-
{
|
42 |
Â
/**
|
43 |
Â
* Additional column names used
|
44 |
Â
*/
|
45 |
Â
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
-
|
47 |
Â
/**
|
48 |
Â
* Renders the column value as a Yes or No value
|
49 |
Â
*
|
50 |
Â
* @param Varien_Object $row
|
51 |
-
*
|
52 |
Â
* @return string
|
53 |
Â
*/
|
54 |
Â
public function render(Varien_Object $row)
|
@@ -61,7 +61,7 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
|
61 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
62 |
Â
return parent::render($row);
|
63 |
Â
}
|
64 |
-
|
65 |
Â
/**
|
66 |
Â
* Check if any data is available
|
67 |
Â
*/
|
@@ -69,14 +69,14 @@ class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
|
69 |
Â
if (is_null($value) || $value === '') {
|
70 |
Â
return parent::render($row);
|
71 |
Â
}
|
72 |
-
|
73 |
Â
if ($value == 0) {
|
74 |
Â
$value = Mage::helper('postnl')->__('No');
|
75 |
Â
return $value;
|
76 |
Â
}
|
77 |
-
|
78 |
Â
$value = Mage::helper('postnl')->__('Yes');
|
79 |
-
|
80 |
Â
return $value;
|
81 |
Â
}
|
82 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Column_Renderer_YesNo
|
40 |
Â
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Text
|
41 |
+
{
|
42 |
Â
/**
|
43 |
Â
* Additional column names used
|
44 |
Â
*/
|
45 |
Â
const SHIPPING_METHOD_COLUMN = 'shipping_method';
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* Renders the column value as a Yes or No value
|
49 |
Â
*
|
50 |
Â
* @param Varien_Object $row
|
51 |
+
*
|
52 |
Â
* @return string
|
53 |
Â
*/
|
54 |
Â
public function render(Varien_Object $row)
|
61 |
Â
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
62 |
Â
return parent::render($row);
|
63 |
Â
}
|
64 |
+
|
65 |
Â
/**
|
66 |
Â
* Check if any data is available
|
67 |
Â
*/
|
69 |
Â
if (is_null($value) || $value === '') {
|
70 |
Â
return parent::render($row);
|
71 |
Â
}
|
72 |
+
|
73 |
Â
if ($value == 0) {
|
74 |
Â
$value = Mage::helper('postnl')->__('No');
|
75 |
Â
return $value;
|
76 |
Â
}
|
77 |
+
|
78 |
Â
$value = Mage::helper('postnl')->__('Yes');
|
79 |
+
|
80 |
Â
return $value;
|
81 |
Â
}
|
82 |
Â
}
|
@@ -0,0 +1,51 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
* Observer to edit the sales > shipments grid
|
40 |
+
*
|
41 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid setCollection(Varien_Data_Collection $value)
|
42 |
+
* @method Varien_Data_Collection getCollection()
|
43 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid setBlock(Mage_Core_Block_Abstract $value)
|
44 |
+
*/
|
45 |
+
class TIG_PostNL_Block_Adminhtml_Widget_Grid_Massaction_LabelStartPos extends Mage_Adminhtml_Block_Abstract
|
46 |
+
{
|
47 |
+
/**
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_template = 'TIG/PostNL/widget/grid/massaction/label_start_pos.phtml';
|
51 |
+
}
|
@@ -0,0 +1,86 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
* @method boolean hasIsOldMagento()
|
40 |
+
* @method TIG_PostNL_Block_Adminhtml_WindowsTheme setIsOldMagento()
|
41 |
+
*/
|
42 |
+
class TIG_PostNL_Block_Adminhtml_WindowsTheme extends TIG_PostNL_Block_Adminhtml_Template
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* For Magento versions below these versions we need to execute some special backwards compatibility code.
|
46 |
+
*/
|
47 |
+
const MINIMUM_VERSION_COMPATIBILITY = '1.7.0.0';
|
48 |
+
const MINIMUM_ENTERPRISE_VERSION_COMPATIBILITY = '1.12.0.0';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
protected $_eventPrefix = 'postnl_adminhtml_windowstheme';
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Checks whether the current version of Magento is an old version (C.E. 1.6 or E.E. 1.11).
|
57 |
+
*
|
58 |
+
* @return boolean
|
59 |
+
*/
|
60 |
+
public function getIsOldMagento()
|
61 |
+
{
|
62 |
+
if ($this->hasIsOldMagento()) {
|
63 |
+
return $this->_getData('is_old_magento');
|
64 |
+
}
|
65 |
+
|
66 |
+
$version = Mage::getVersion();
|
67 |
+
$isEnterprise = Mage::helper('postnl')->isEnterprise();
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Get the minimum version requirement for the current Magento edition.
|
71 |
+
*/
|
72 |
+
if($isEnterprise) {
|
73 |
+
$minimumVersion = self::MINIMUM_ENTERPRISE_VERSION_COMPATIBILITY;
|
74 |
+
} else {
|
75 |
+
$minimumVersion = self::MINIMUM_VERSION_COMPATIBILITY;
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Check if the current version is below the minimum version requirement.
|
80 |
+
*/
|
81 |
+
$isOldVersion = version_compare($version, $minimumVersion, '<');
|
82 |
+
|
83 |
+
$this->setIsOldMagento($isOldVersion);
|
84 |
+
return $isOldVersion;
|
85 |
+
}
|
86 |
+
}
|
@@ -33,34 +33,44 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
43 |
Â
*/
|
44 |
Â
const CHECKOUT_BUTTON_TEST_BASE_URL = 'https://tppcb-sandbox.e-id.nl/Button/Checkout';
|
45 |
Â
const CHECKOUT_BUTTON_LIVE_BASE_URL = 'https://checkout.postnl.nl/Button/Checkout';
|
46 |
Â
|
47 |
Â
/**
|
48 |
-
*
|
49 |
Â
*/
|
50 |
-
const
|
51 |
Â
|
52 |
Â
/**
|
53 |
-
*
|
54 |
Â
*/
|
55 |
-
const
|
56 |
Â
|
57 |
Â
/**
|
58 |
-
*
|
59 |
Â
*/
|
60 |
-
const
|
61 |
Â
|
62 |
Â
/**
|
63 |
-
* Gets the checkout URL
|
64 |
Â
*
|
65 |
Â
* @return string
|
66 |
Â
*/
|
@@ -72,7 +82,26 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends Mage_Core_Block_Templa
|
|
72 |
Â
}
|
73 |
Â
|
74 |
Â
/**
|
75 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
*
|
77 |
Â
* @return boolean
|
78 |
Â
*/
|
@@ -86,7 +115,7 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends Mage_Core_Block_Templa
|
|
86 |
Â
}
|
87 |
Â
|
88 |
Â
/**
|
89 |
-
* Check if the button should be displayed
|
90 |
Â
*
|
91 |
Â
* @return boolean
|
92 |
Â
*/
|
@@ -124,7 +153,7 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends Mage_Core_Block_Templa
|
|
124 |
Â
}
|
125 |
Â
|
126 |
Â
/**
|
127 |
-
* Gets this webshop's public ID
|
128 |
Â
*
|
129 |
Â
* @return string
|
130 |
Â
*/
|
@@ -134,14 +163,14 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends Mage_Core_Block_Templa
|
|
134 |
Â
return $this->getData('public_webshop_id');
|
135 |
Â
}
|
136 |
Â
|
137 |
-
$webshopId = Mage::getStoreConfig(self::
|
138 |
Â
|
139 |
Â
$this->setPublicWebshopId($webshopId);
|
140 |
Â
return $webshopId;
|
141 |
Â
}
|
142 |
Â
|
143 |
Â
/**
|
144 |
-
* Gets the checkout button src attribute
|
145 |
Â
*
|
146 |
Â
* @param boolean $forceDisabled
|
147 |
Â
*
|
@@ -170,13 +199,13 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends Mage_Core_Block_Templa
|
|
170 |
Â
}
|
171 |
Â
|
172 |
Â
/**
|
173 |
-
* Gets the URL of a CMS page containing instructions on how to use PostNL Checkout
|
174 |
Â
*
|
175 |
Â
* @return boolean|string
|
176 |
Â
*/
|
177 |
Â
public function getInstructionUrl()
|
178 |
Â
{
|
179 |
-
$instructionPage = Mage::getStoreConfig(self::
|
180 |
Â
if (!$instructionPage) {
|
181 |
Â
return false;
|
182 |
Â
}
|
@@ -186,7 +215,7 @@ class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends Mage_Core_Block_Templa
|
|
186 |
Â
}
|
187 |
Â
|
188 |
Â
/**
|
189 |
-
* Returns the block's html. Checks if the 'use_postnl_checkout' param is set.
|
190 |
Â
*
|
191 |
Â
* @return string
|
192 |
Â
*/
|
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 |
+
* @method boolean hasPublicWebshopId()
|
40 |
+
* @method TIG_PostNL_Block_Checkout_Cart_CheckoutLink setPublicWebshopId(string $value)
|
41 |
+
* @method boolean hasDoLoginCheck()
|
42 |
+
* @method TIG_PostNL_Block_Checkout_Cart_CheckoutLink setDoLoginCheck(boolean $value)
|
43 |
Â
*/
|
44 |
+
class TIG_PostNL_Block_Checkout_Cart_CheckoutLink extends TIG_PostNL_Block_Core_Template
|
45 |
Â
{
|
46 |
Â
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $_eventPrefix = 'postnl_checkout_cart_checkoutlink';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Base URLs of the checkout button.
|
53 |
Â
*/
|
54 |
Â
const CHECKOUT_BUTTON_TEST_BASE_URL = 'https://tppcb-sandbox.e-id.nl/Button/Checkout';
|
55 |
Â
const CHECKOUT_BUTTON_LIVE_BASE_URL = 'https://checkout.postnl.nl/Button/Checkout';
|
56 |
Â
|
57 |
Â
/**
|
58 |
+
* Xpath to public webshop ID setting.
|
59 |
Â
*/
|
60 |
+
const XPATH_PUBLIC_WEBSHOP_ID = 'postnl/cif/public_webshop_id';
|
61 |
Â
|
62 |
Â
/**
|
63 |
+
* Xpath to the 'instruction_cms_page' setting.
|
64 |
Â
*/
|
65 |
+
const XPATH_INSTRUCTION_CMS_PAGE = 'postnl/checkout/instruction_cms_page';
|
66 |
Â
|
67 |
Â
/**
|
68 |
+
* Xpath to 'show exclusively for mijnpakket users' setting.
|
69 |
Â
*/
|
70 |
+
const XPATH_SHOW_EXCLUSIVELY_FOR_MIJNPAKKET_USERS = 'postnl/checkout/show_exclusively_for_mijnpakket_users';
|
71 |
Â
|
72 |
Â
/**
|
73 |
+
* Gets the checkout URL.
|
74 |
Â
*
|
75 |
Â
* @return string
|
76 |
Â
*/
|
82 |
Â
}
|
83 |
Â
|
84 |
Â
/**
|
85 |
+
* Returns whether or not we need to check if the current customer is logged in with mijnpakket before showing
|
86 |
+
* PostNL Checkout.
|
87 |
+
*
|
88 |
+
* @return bool
|
89 |
+
*/
|
90 |
+
public function getDoLoginCheck()
|
91 |
+
{
|
92 |
+
if ($this->hasDoLoginCheck()) {
|
93 |
+
return $this->_getData('do_login_check');
|
94 |
+
}
|
95 |
+
|
96 |
+
$storeId = Mage::app()->getStore()->getId();
|
97 |
+
$doLoginCheck = Mage::getStoreConfigFlag(self::XPATH_SHOW_EXCLUSIVELY_FOR_MIJNPAKKET_USERS, $storeId);
|
98 |
+
|
99 |
+
$this->setDoLoginCheck($doLoginCheck);
|
100 |
+
return $doLoginCheck;
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Check if the button should be disabled.
|
105 |
Â
*
|
106 |
Â
* @return boolean
|
107 |
Â
*/
|
115 |
Â
}
|
116 |
Â
|
117 |
Â
/**
|
118 |
+
* Check if the button should be displayed.
|
119 |
Â
*
|
120 |
Â
* @return boolean
|
121 |
Â
*/
|
153 |
Â
}
|
154 |
Â
|
155 |
Â
/**
|
156 |
+
* Gets this webshop's public ID.
|
157 |
Â
*
|
158 |
Â
* @return string
|
159 |
Â
*/
|
163 |
Â
return $this->getData('public_webshop_id');
|
164 |
Â
}
|
165 |
Â
|
166 |
+
$webshopId = Mage::getStoreConfig(self::XPATH_PUBLIC_WEBSHOP_ID, Mage::app()->getStore()->getId());
|
167 |
Â
|
168 |
Â
$this->setPublicWebshopId($webshopId);
|
169 |
Â
return $webshopId;
|
170 |
Â
}
|
171 |
Â
|
172 |
Â
/**
|
173 |
+
* Gets the checkout button src attribute.
|
174 |
Â
*
|
175 |
Â
* @param boolean $forceDisabled
|
176 |
Â
*
|
199 |
Â
}
|
200 |
Â
|
201 |
Â
/**
|
202 |
+
* Gets the URL of a CMS page containing instructions on how to use PostNL Checkout.
|
203 |
Â
*
|
204 |
Â
* @return boolean|string
|
205 |
Â
*/
|
206 |
Â
public function getInstructionUrl()
|
207 |
Â
{
|
208 |
+
$instructionPage = Mage::getStoreConfig(self::XPATH_INSTRUCTION_CMS_PAGE, Mage::app()->getStore()->getId());
|
209 |
Â
if (!$instructionPage) {
|
210 |
Â
return false;
|
211 |
Â
}
|
215 |
Â
}
|
216 |
Â
|
217 |
Â
/**
|
218 |
+
* Returns the block's html. Checks if the 'use_postnl_checkout' param is set. Otherwise returns an empty string.
|
219 |
Â
*
|
220 |
Â
* @return string
|
221 |
Â
*/
|
@@ -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.
|
@@ -33,144 +33,188 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Checkout_Cart_Js extends
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* XML path for webshop ID setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_PUBLIC_WEBSHOP_ID = 'postnl/cif/public_webshop_id';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* XML path of show_summary_page setting
|
48 |
Â
*/
|
49 |
Â
const XML_PATH_SHOW_SUMMARY_PAGE = 'postnl/checkout/show_summary_page';
|
50 |
-
|
51 |
Â
/**
|
52 |
Â
* URLs of the primary PostNL Checkout JS files for test and live mode
|
53 |
Â
*/
|
54 |
-
const TEST_CHECKOUT_JS_URL
|
55 |
-
const LIVE_CHECKOUT_JS_URL
|
56 |
-
|
Â
|
|
Â
|
|
57 |
Â
/**
|
58 |
Â
* Possible Checkout environments
|
59 |
Â
*/
|
60 |
Â
const TEST_ENVIRONMENT = 'PostNL_OP_Checkout.environment_sandbox';
|
61 |
Â
const LIVE_ENVIRONMENT = 'PostNL_OP_Checkout.environment_production';
|
62 |
-
|
63 |
Â
/**
|
64 |
Â
* Gets the current store's webshop ID
|
65 |
-
*
|
66 |
Â
* @return string
|
67 |
Â
*/
|
68 |
Â
public function getWebshopId()
|
69 |
Â
{
|
70 |
-
if ($this->
|
71 |
-
return $this->
|
72 |
Â
}
|
73 |
-
|
74 |
Â
$storeId = Mage::app()->getStore()->getId();
|
75 |
-
|
76 |
Â
$webshopId = Mage::getStoreConfig(self::XML_PATH_PUBLIC_WEBSHOP_ID, $storeId);
|
77 |
-
|
78 |
Â
$this->setWebshopId($webshopId);
|
79 |
Â
return $webshopId;
|
80 |
Â
}
|
81 |
-
|
82 |
Â
/**
|
83 |
Â
* Gets the correct checkout js URL depending on whether PostNL Checkout is set to test or live mode
|
84 |
-
*
|
85 |
Â
* @return string
|
86 |
Â
*/
|
87 |
Â
public function getCheckoutJsUrl()
|
88 |
Â
{
|
89 |
-
if ($this->
|
90 |
-
return $this->
|
91 |
Â
}
|
92 |
-
|
93 |
Â
$storeId = Mage::app()->getStore()->getId();
|
94 |
-
|
95 |
Â
if (Mage::helper('postnl/checkout')->isTestMode($storeId)) {
|
96 |
Â
$url = self::TEST_CHECKOUT_JS_URL;
|
97 |
-
|
98 |
Â
$this->setCheckoutJsUrl($url);
|
99 |
Â
return $url;
|
100 |
Â
}
|
101 |
-
|
102 |
Â
$url = self::LIVE_CHECKOUT_JS_URL;
|
103 |
-
|
104 |
Â
$this->setCheckoutJsUrl($url);
|
105 |
Â
return $url;
|
106 |
Â
}
|
107 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
108 |
Â
/**
|
109 |
Â
* Gets the current PostNL Checkout environment value
|
110 |
-
*
|
111 |
Â
* @return string
|
112 |
Â
*/
|
113 |
Â
public function getEnvironment()
|
114 |
Â
{
|
115 |
-
if ($this->
|
116 |
-
return $this->
|
117 |
Â
}
|
118 |
-
|
119 |
Â
$storeId = Mage::app()->getStore()->getId();
|
120 |
-
|
121 |
Â
if (Mage::helper('postnl/checkout')->isTestMode($storeId)) {
|
122 |
Â
$environment = self::TEST_ENVIRONMENT;
|
123 |
-
|
124 |
Â
$this->setEnvironment($environment);
|
125 |
Â
return $environment;
|
126 |
Â
}
|
127 |
-
|
128 |
Â
$environment = self::LIVE_ENVIRONMENT;
|
129 |
-
|
130 |
Â
$this->setEnvironment($environment);
|
131 |
Â
return $environment;
|
132 |
Â
}
|
133 |
-
|
134 |
Â
/**
|
135 |
Â
* Gets a URL to which the user will be redirected after finishing the order in the PostNL overlay.
|
136 |
-
*
|
137 |
Â
* @return string
|
138 |
Â
*/
|
139 |
Â
public function getContinueUrl()
|
140 |
Â
{
|
141 |
-
if ($this->
|
142 |
-
return $this->
|
143 |
Â
}
|
144 |
-
|
145 |
Â
$storeId = Mage::app()->getStore()->getId();
|
146 |
Â
$showConfirmPage = Mage::getStoreConfigFlag(self::XML_PATH_SHOW_SUMMARY_PAGE, $storeId);
|
147 |
Â
if ($showConfirmPage) {
|
148 |
Â
$url = $this->getUrl('postnl/checkout/summary');
|
149 |
-
|
150 |
Â
$this->setContinueUrl($url);
|
151 |
Â
return $url;
|
152 |
Â
}
|
153 |
-
|
154 |
Â
$url = $this->getUrl('postnl/checkout/finishCheckout');
|
155 |
-
|
156 |
Â
$this->setContinueUrl($url);
|
157 |
Â
return $url;
|
158 |
Â
}
|
159 |
-
|
160 |
Â
/**
|
161 |
Â
* Returns the block's html. Checks if the 'use_postnl_checkout' param is set. If not, returns and empty string
|
162 |
-
*
|
163 |
Â
* @return string
|
164 |
Â
*/
|
165 |
Â
protected function _toHtml()
|
166 |
Â
{
|
167 |
Â
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
168 |
-
|
169 |
Â
$canUseCheckout = Mage::helper('postnl/checkout')->canUsePostnlCheckout($quote);
|
170 |
Â
if (!$canUseCheckout) {
|
171 |
Â
return '';
|
172 |
Â
}
|
173 |
-
|
174 |
Â
return parent::_toHtml();
|
175 |
Â
}
|
176 |
Â
}
|
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.
|
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 |
+
* @method boolean hasWebshopId()
|
40 |
+
* @method TIG_PostNL_Block_Checkout_Cart_Js setWebshopId(string $value)
|
41 |
+
* @method boolean hasCheckoutJsUrl()
|
42 |
+
* @method TIG_PostNL_Block_Checkout_Cart_Js setCheckoutJsUrl(string $value)
|
43 |
+
* @method boolean hasCheckoutPremiumJsUrl()
|
44 |
+
* @method TIG_PostNL_Block_Checkout_Cart_Js setCheckoutPremiumJsUrl(string $value)
|
45 |
+
* @method boolean hasEnvironment()
|
46 |
+
* @method TIG_PostNL_Block_Checkout_Cart_Js setEnvironment(string $value)
|
47 |
+
* @method boolean hasContinueUrl()
|
48 |
+
* @method TIG_PostNL_Block_Checkout_Cart_Js setContinueUrl(string $value)
|
49 |
Â
*/
|
50 |
+
class TIG_PostNL_Block_Checkout_Cart_Js extends TIG_PostNL_Block_Core_Template
|
51 |
Â
{
|
52 |
+
/**
|
53 |
+
* @var string
|
54 |
+
*/
|
55 |
+
protected $_eventPrefix = 'postnl_checkout_cart_js';
|
56 |
+
|
57 |
Â
/**
|
58 |
Â
* XML path for webshop ID setting
|
59 |
Â
*/
|
60 |
Â
const XML_PATH_PUBLIC_WEBSHOP_ID = 'postnl/cif/public_webshop_id';
|
61 |
+
|
62 |
Â
/**
|
63 |
Â
* XML path of show_summary_page setting
|
64 |
Â
*/
|
65 |
Â
const XML_PATH_SHOW_SUMMARY_PAGE = 'postnl/checkout/show_summary_page';
|
66 |
+
|
67 |
Â
/**
|
68 |
Â
* URLs of the primary PostNL Checkout JS files for test and live mode
|
69 |
Â
*/
|
70 |
+
const TEST_CHECKOUT_JS_URL = 'https://tppwscheckout-sandbox.e-id.nl/Checkout2/Scripts/Checkout.js';
|
71 |
+
const LIVE_CHECKOUT_JS_URL = 'https://mijnpakket.postnl.nl/Checkout2/Scripts/Checkout.js';
|
72 |
+
const TEST_CHECKOUT_PREMIUM_JS_URL = 'https://tppwscheckout-sandbox.e-id.nl/Checkout2/CheckoutPremium.js';
|
73 |
+
const LIVE_CHECKOUT_PREMIUM_JS_URL = 'https://mijnpakket.postnl.nl/Checkout2/CheckoutPremium.js';
|
74 |
+
|
75 |
Â
/**
|
76 |
Â
* Possible Checkout environments
|
77 |
Â
*/
|
78 |
Â
const TEST_ENVIRONMENT = 'PostNL_OP_Checkout.environment_sandbox';
|
79 |
Â
const LIVE_ENVIRONMENT = 'PostNL_OP_Checkout.environment_production';
|
80 |
+
|
81 |
Â
/**
|
82 |
Â
* Gets the current store's webshop ID
|
83 |
+
*
|
84 |
Â
* @return string
|
85 |
Â
*/
|
86 |
Â
public function getWebshopId()
|
87 |
Â
{
|
88 |
+
if ($this->hasWebshopId()) {
|
89 |
+
return $this->_getData('webshop_id');
|
90 |
Â
}
|
91 |
+
|
92 |
Â
$storeId = Mage::app()->getStore()->getId();
|
93 |
+
|
94 |
Â
$webshopId = Mage::getStoreConfig(self::XML_PATH_PUBLIC_WEBSHOP_ID, $storeId);
|
95 |
+
|
96 |
Â
$this->setWebshopId($webshopId);
|
97 |
Â
return $webshopId;
|
98 |
Â
}
|
99 |
+
|
100 |
Â
/**
|
101 |
Â
* Gets the correct checkout js URL depending on whether PostNL Checkout is set to test or live mode
|
102 |
+
*
|
103 |
Â
* @return string
|
104 |
Â
*/
|
105 |
Â
public function getCheckoutJsUrl()
|
106 |
Â
{
|
107 |
+
if ($this->hasCheckoutJsUrl()) {
|
108 |
+
return $this->_getData('checkout_js_url');
|
109 |
Â
}
|
110 |
+
|
111 |
Â
$storeId = Mage::app()->getStore()->getId();
|
112 |
+
|
113 |
Â
if (Mage::helper('postnl/checkout')->isTestMode($storeId)) {
|
114 |
Â
$url = self::TEST_CHECKOUT_JS_URL;
|
115 |
+
|
116 |
Â
$this->setCheckoutJsUrl($url);
|
117 |
Â
return $url;
|
118 |
Â
}
|
119 |
+
|
120 |
Â
$url = self::LIVE_CHECKOUT_JS_URL;
|
121 |
+
|
122 |
Â
$this->setCheckoutJsUrl($url);
|
123 |
Â
return $url;
|
124 |
Â
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Gets the correct checkout premium js URL depending on whether PostNL Checkout is set to test or live mode
|
128 |
+
*
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
public function getCheckoutPremiumJsUrl()
|
132 |
+
{
|
133 |
+
if ($this->hasCheckoutPremiumJsUrl()) {
|
134 |
+
return $this->_getData('checkout_premium_js_url');
|
135 |
+
}
|
136 |
+
|
137 |
+
$storeId = Mage::app()->getStore()->getId();
|
138 |
+
|
139 |
+
if (Mage::helper('postnl/checkout')->isTestMode($storeId)) {
|
140 |
+
$url = self::TEST_CHECKOUT_PREMIUM_JS_URL;
|
141 |
+
|
142 |
+
$this->setCheckoutPremiumJsUrl($url);
|
143 |
+
return $url;
|
144 |
+
}
|
145 |
+
|
146 |
+
$url = self::LIVE_CHECKOUT_PREMIUM_JS_URL;
|
147 |
+
|
148 |
+
$this->setCheckoutPremiumJsUrl($url);
|
149 |
+
return $url;
|
150 |
+
}
|
151 |
+
|
152 |
Â
/**
|
153 |
Â
* Gets the current PostNL Checkout environment value
|
154 |
+
*
|
155 |
Â
* @return string
|
156 |
Â
*/
|
157 |
Â
public function getEnvironment()
|
158 |
Â
{
|
159 |
+
if ($this->hasEnvironment()) {
|
160 |
+
return $this->_getData('environment');
|
161 |
Â
}
|
162 |
+
|
163 |
Â
$storeId = Mage::app()->getStore()->getId();
|
164 |
+
|
165 |
Â
if (Mage::helper('postnl/checkout')->isTestMode($storeId)) {
|
166 |
Â
$environment = self::TEST_ENVIRONMENT;
|
167 |
+
|
168 |
Â
$this->setEnvironment($environment);
|
169 |
Â
return $environment;
|
170 |
Â
}
|
171 |
+
|
172 |
Â
$environment = self::LIVE_ENVIRONMENT;
|
173 |
+
|
174 |
Â
$this->setEnvironment($environment);
|
175 |
Â
return $environment;
|
176 |
Â
}
|
177 |
+
|
178 |
Â
/**
|
179 |
Â
* Gets a URL to which the user will be redirected after finishing the order in the PostNL overlay.
|
180 |
+
*
|
181 |
Â
* @return string
|
182 |
Â
*/
|
183 |
Â
public function getContinueUrl()
|
184 |
Â
{
|
185 |
+
if ($this->hasContinueUrl()) {
|
186 |
+
return $this->_getData('continue_url');
|
187 |
Â
}
|
188 |
+
|
189 |
Â
$storeId = Mage::app()->getStore()->getId();
|
190 |
Â
$showConfirmPage = Mage::getStoreConfigFlag(self::XML_PATH_SHOW_SUMMARY_PAGE, $storeId);
|
191 |
Â
if ($showConfirmPage) {
|
192 |
Â
$url = $this->getUrl('postnl/checkout/summary');
|
193 |
+
|
194 |
Â
$this->setContinueUrl($url);
|
195 |
Â
return $url;
|
196 |
Â
}
|
197 |
+
|
198 |
Â
$url = $this->getUrl('postnl/checkout/finishCheckout');
|
199 |
+
|
200 |
Â
$this->setContinueUrl($url);
|
201 |
Â
return $url;
|
202 |
Â
}
|
203 |
+
|
204 |
Â
/**
|
205 |
Â
* Returns the block's html. Checks if the 'use_postnl_checkout' param is set. If not, returns and empty string
|
206 |
+
*
|
207 |
Â
* @return string
|
208 |
Â
*/
|
209 |
Â
protected function _toHtml()
|
210 |
Â
{
|
211 |
Â
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
212 |
+
|
213 |
Â
$canUseCheckout = Mage::helper('postnl/checkout')->canUsePostnlCheckout($quote);
|
214 |
Â
if (!$canUseCheckout) {
|
215 |
Â
return '';
|
216 |
Â
}
|
217 |
+
|
218 |
Â
return parent::_toHtml();
|
219 |
Â
}
|
220 |
Â
}
|
@@ -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.
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
@@ -42,7 +42,7 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
42 |
Â
* PakjeGemak address type
|
43 |
Â
*/
|
44 |
Â
const PAKJE_GEMAK_ADDRESS_TYPE = 'pakje_gemak';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* Get active or custom quote
|
48 |
Â
*
|
@@ -53,49 +53,49 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
53 |
Â
if ($this->hasQuote()) {
|
54 |
Â
return $this->getData('quote');
|
55 |
Â
}
|
56 |
-
|
57 |
Â
$quote = Mage::registry('current_quote');
|
58 |
-
|
59 |
Â
$this->setQuote($quote);
|
60 |
Â
return $quote;
|
61 |
Â
}
|
62 |
-
|
63 |
Â
/**
|
64 |
Â
* Get all visible items in the quote
|
65 |
-
*
|
66 |
Â
* @return array
|
67 |
Â
*/
|
68 |
Â
public function getItems()
|
69 |
Â
{
|
70 |
Â
$quote = $this->getQuote();
|
71 |
-
|
72 |
Â
return $quote->getAllVisibleItems();
|
73 |
Â
}
|
74 |
-
|
75 |
Â
/**
|
76 |
Â
* Gets an optional pakje_gemak address from the quote
|
77 |
-
*
|
78 |
Â
* @return boolean | Mage_Sales_Model_Quote_Address
|
79 |
Â
*/
|
80 |
Â
public function getPakjeGemakAddress()
|
81 |
Â
{
|
82 |
Â
$quote = $this->getQuote();
|
83 |
-
|
84 |
Â
$addresses = $quote->getAddressesCollection();
|
85 |
-
|
86 |
Â
foreach ($addresses as $address) {
|
87 |
Â
if ($address->getAddressType() == self::PAKJE_GEMAK_ADDRESS_TYPE) {
|
88 |
Â
$address = Mage::getModel('sales/quote_address')->load($address->getId());
|
89 |
Â
return $address;
|
90 |
Â
}
|
91 |
Â
}
|
92 |
-
|
93 |
Â
return false;
|
94 |
Â
}
|
95 |
-
|
96 |
Â
/**
|
97 |
Â
* Gets the shipping address's shipping description
|
98 |
-
*
|
99 |
Â
* @return string
|
100 |
Â
*/
|
101 |
Â
public function getShippingDescription()
|
@@ -105,13 +105,13 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
105 |
Â
if ($address->hasShippingDescription()) {
|
106 |
Â
return $address->getShippingDescription();
|
107 |
Â
}
|
108 |
-
|
109 |
Â
$method = $address->getShippingMethod();
|
110 |
Â
|
111 |
Â
if (!$method) {
|
112 |
Â
return '';
|
113 |
Â
}
|
114 |
-
|
115 |
Â
$shippingDescription = '';
|
116 |
Â
foreach ($address->getAllShippingRates() as $rate) {
|
117 |
Â
if ($rate->getCode() == $method) {
|
@@ -120,44 +120,51 @@ class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
|
120 |
Â
break;
|
121 |
Â
}
|
122 |
Â
}
|
123 |
-
|
124 |
Â
return $shippingDescription;
|
125 |
Â
}
|
126 |
-
|
Â
|
|
Â
|
|
Â
|
|
127 |
Â
public function getPaymentOption()
|
128 |
Â
{
|
129 |
Â
$paymentData = Mage::registry('postnl_payment_data');
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
130 |
Â
$methodCode = $paymentData['method'];
|
131 |
Â
$optionValue = $paymentData['option'];
|
132 |
-
|
133 |
Â
if (!$optionValue) {
|
134 |
Â
return false;
|
135 |
Â
}
|
136 |
-
|
137 |
Â
$optionConversionArray = Mage::helper('postnl/checkout')->getOptionConversionArray();
|
138 |
Â
if (!array_key_exists($methodCode, $optionConversionArray)) {
|
139 |
Â
return $optionValue;
|
140 |
Â
}
|
141 |
-
|
142 |
Â
$methodArray = $optionConversionArray[$methodCode];
|
143 |
Â
if (!array_key_exists($optionValue, $methodArray)) {
|
144 |
Â
return $optionValue;
|
145 |
Â
}
|
146 |
-
|
147 |
Â
$convertedOption = $methodArray[$optionValue];
|
148 |
Â
return $convertedOption;
|
149 |
Â
}
|
150 |
-
|
151 |
Â
/**
|
152 |
Â
* Gets the PostNL order associated with the current quote
|
153 |
-
*
|
154 |
-
* @return
|
155 |
Â
*/
|
156 |
Â
public function getPostnlOrder()
|
157 |
Â
{
|
158 |
Â
$quote = $this->getQuote();
|
159 |
-
$postnlOrder = Mage::getModel('
|
160 |
-
|
161 |
Â
return $postnlOrder;
|
162 |
Â
}
|
163 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Block_Checkout_Summary extends Mage_Sales_Block_Items_Abstract
|
42 |
Â
* PakjeGemak address type
|
43 |
Â
*/
|
44 |
Â
const PAKJE_GEMAK_ADDRESS_TYPE = 'pakje_gemak';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Get active or custom quote
|
48 |
Â
*
|
53 |
Â
if ($this->hasQuote()) {
|
54 |
Â
return $this->getData('quote');
|
55 |
Â
}
|
56 |
+
|
57 |
Â
$quote = Mage::registry('current_quote');
|
58 |
+
|
59 |
Â
$this->setQuote($quote);
|
60 |
Â
return $quote;
|
61 |
Â
}
|
62 |
+
|
63 |
Â
/**
|
64 |
Â
* Get all visible items in the quote
|
65 |
+
*
|
66 |
Â
* @return array
|
67 |
Â
*/
|
68 |
Â
public function getItems()
|
69 |
Â
{
|
70 |
Â
$quote = $this->getQuote();
|
71 |
+
|
72 |
Â
return $quote->getAllVisibleItems();
|
73 |
Â
}
|
74 |
+
|
75 |
Â
/**
|
76 |
Â
* Gets an optional pakje_gemak address from the quote
|
77 |
+
*
|
78 |
Â
* @return boolean | Mage_Sales_Model_Quote_Address
|
79 |
Â
*/
|
80 |
Â
public function getPakjeGemakAddress()
|
81 |
Â
{
|
82 |
Â
$quote = $this->getQuote();
|
83 |
+
|
84 |
Â
$addresses = $quote->getAddressesCollection();
|
85 |
+
|
86 |
Â
foreach ($addresses as $address) {
|
87 |
Â
if ($address->getAddressType() == self::PAKJE_GEMAK_ADDRESS_TYPE) {
|
88 |
Â
$address = Mage::getModel('sales/quote_address')->load($address->getId());
|
89 |
Â
return $address;
|
90 |
Â
}
|
91 |
Â
}
|
92 |
+
|
93 |
Â
return false;
|
94 |
Â
}
|
95 |
+
|
96 |
Â
/**
|
97 |
Â
* Gets the shipping address's shipping description
|
98 |
+
*
|
99 |
Â
* @return string
|
100 |
Â
*/
|
101 |
Â
public function getShippingDescription()
|
105 |
Â
if ($address->hasShippingDescription()) {
|
106 |
Â
return $address->getShippingDescription();
|
107 |
Â
}
|
108 |
+
|
109 |
Â
$method = $address->getShippingMethod();
|
110 |
Â
|
111 |
Â
if (!$method) {
|
112 |
Â
return '';
|
113 |
Â
}
|
114 |
+
|
115 |
Â
$shippingDescription = '';
|
116 |
Â
foreach ($address->getAllShippingRates() as $rate) {
|
117 |
Â
if ($rate->getCode() == $method) {
|
120 |
Â
break;
|
121 |
Â
}
|
122 |
Â
}
|
123 |
+
|
124 |
Â
return $shippingDescription;
|
125 |
Â
}
|
126 |
+
|
127 |
+
/**
|
128 |
+
* @return boolean|string
|
129 |
+
*/
|
130 |
Â
public function getPaymentOption()
|
131 |
Â
{
|
132 |
Â
$paymentData = Mage::registry('postnl_payment_data');
|
133 |
+
if (!isset($paymentData['method']) || !isset($paymentData['option'])) {
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
|
137 |
Â
$methodCode = $paymentData['method'];
|
138 |
Â
$optionValue = $paymentData['option'];
|
139 |
+
|
140 |
Â
if (!$optionValue) {
|
141 |
Â
return false;
|
142 |
Â
}
|
143 |
+
|
144 |
Â
$optionConversionArray = Mage::helper('postnl/checkout')->getOptionConversionArray();
|
145 |
Â
if (!array_key_exists($methodCode, $optionConversionArray)) {
|
146 |
Â
return $optionValue;
|
147 |
Â
}
|
148 |
+
|
149 |
Â
$methodArray = $optionConversionArray[$methodCode];
|
150 |
Â
if (!array_key_exists($optionValue, $methodArray)) {
|
151 |
Â
return $optionValue;
|
152 |
Â
}
|
153 |
+
|
154 |
Â
$convertedOption = $methodArray[$optionValue];
|
155 |
Â
return $convertedOption;
|
156 |
Â
}
|
157 |
+
|
158 |
Â
/**
|
159 |
Â
* Gets the PostNL order associated with the current quote
|
160 |
+
*
|
161 |
+
* @return TIG_PostNL_Model_Core_Order
|
162 |
Â
*/
|
163 |
Â
public function getPostnlOrder()
|
164 |
Â
{
|
165 |
Â
$quote = $this->getQuote();
|
166 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($quote->getId(), 'quote_id');
|
167 |
+
|
168 |
Â
return $postnlOrder;
|
169 |
Â
}
|
170 |
Â
}
|
@@ -0,0 +1,215 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Block_Core_JsTranslate extends TIG_PostNL_Block_Core_Template
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_core_jstemplate';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Translate file name
|
48 |
+
*/
|
49 |
+
const JAVASCRIPT_TRANSLATE_CONFIG_FILENAME = 'jstranslator.xml';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The template file used by this block.
|
53 |
+
*
|
54 |
+
* @var string app/design/frontend/base/default/template/TIG/PostNL/page/html/js_translate.phtml
|
55 |
+
*/
|
56 |
+
protected $_template = 'TIG/PostNL/core/page/html/js_translate.phtml';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Array of JS translations
|
60 |
+
*
|
61 |
+
* @var array|null
|
62 |
+
*/
|
63 |
+
protected $_translateData = null;
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Translate config
|
67 |
+
*
|
68 |
+
* @var Varien_Simplexml_Config|null
|
69 |
+
*/
|
70 |
+
protected $_config = null;
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @param array|null $translateData
|
74 |
+
*
|
75 |
+
* @return $this
|
76 |
+
*/
|
77 |
+
public function setTranslateData($translateData)
|
78 |
+
{
|
79 |
+
$this->_translateData = $translateData;
|
80 |
+
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* @return array|null
|
86 |
+
*/
|
87 |
+
public function getTranslateData()
|
88 |
+
{
|
89 |
+
return $this->_translateData;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* @param null|Varien_Simplexml_Config $config
|
94 |
+
*
|
95 |
+
* @return TIG_PostNL_Block_Core_JsTranslate
|
96 |
+
*/
|
97 |
+
public function setConfig($config)
|
98 |
+
{
|
99 |
+
$this->_config = $config;
|
100 |
+
|
101 |
+
return $this;
|
102 |
+
}
|
103 |
+
|
104 |
+
/**
|
105 |
+
* @return null|Varien_Simplexml_Config
|
106 |
+
*/
|
107 |
+
public function getConfig()
|
108 |
+
{
|
109 |
+
return $this->_config;
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Get JS translations for PostNL JS files.
|
114 |
+
*
|
115 |
+
* @return string
|
116 |
+
*/
|
117 |
+
public function getPostnlTranslateData()
|
118 |
+
{
|
119 |
+
$messages = $this->_getTranslateData();
|
120 |
+
|
121 |
+
$json = Mage::helper('core')->jsonEncode($messages);
|
122 |
+
return $json;
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Get JS translations from jstranslate.xml files. These files are only supported since Magento 1.7, so we made
|
127 |
+
* this block to provide forwards compatibility to Magento 1.6.
|
128 |
+
*
|
129 |
+
* Because Magento 1.6 doesn't have a cache entry for these xml files, we don't use caching.
|
130 |
+
*
|
131 |
+
* @return array
|
132 |
+
*/
|
133 |
+
protected function _getTranslateData()
|
134 |
+
{
|
135 |
+
if ($this->getTranslateData() !== null) {
|
136 |
+
return $this->getTranslateData();
|
137 |
+
}
|
138 |
+
|
139 |
+
$translateData = array();
|
140 |
+
$messages = $this->_getXmlConfig()->getXpath('*/message');
|
141 |
+
|
142 |
+
if (empty($messages)) {
|
143 |
+
$this->setTranslateData($translateData);
|
144 |
+
|
145 |
+
return $translateData;
|
146 |
+
}
|
147 |
+
|
148 |
+
$helper = Mage::helper('postnl');
|
149 |
+
|
150 |
+
/**
|
151 |
+
* @var Varien_Simplexml_Element $message
|
152 |
+
*/
|
153 |
+
foreach ($messages as $message) {
|
154 |
+
$messageText = (string) $message;
|
155 |
+
$module = $message->getParent()->getAttribute("module");
|
156 |
+
|
157 |
+
/**
|
158 |
+
* We only want to parse PostNL's translations.
|
159 |
+
*/
|
160 |
+
if (!$module || $module != 'postnl') {
|
161 |
+
continue;
|
162 |
+
}
|
163 |
+
$translateData[$messageText] = $helper->__($messageText);
|
164 |
+
}
|
165 |
+
|
166 |
+
foreach ($translateData as $key => $value) {
|
167 |
+
if ($key == $value) {
|
168 |
+
unset($translateData[$key]);
|
169 |
+
}
|
170 |
+
}
|
171 |
+
|
172 |
+
$this->setTranslateData($translateData);
|
173 |
+
|
174 |
+
return $translateData;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Load config from files and try to cache it
|
179 |
+
*
|
180 |
+
* @return Varien_Simplexml_Config
|
181 |
+
*/
|
182 |
+
protected function _getXmlConfig()
|
183 |
+
{
|
184 |
+
if ($this->getConfig() !== null)
|
185 |
+
return $this->getConfig();
|
186 |
+
|
187 |
+
$xmlConfig = new Varien_Simplexml_Config();
|
188 |
+
$xmlConfig->loadString('<?xml version="1.0"?><jstranslator></jstranslator>');
|
189 |
+
Mage::getConfig()->loadModulesConfiguration(self::JAVASCRIPT_TRANSLATE_CONFIG_FILENAME, $xmlConfig);
|
190 |
+
|
191 |
+
$this->setConfig($xmlConfig);
|
192 |
+
|
193 |
+
return $xmlConfig;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Check if the current Magento version is below 1.7 or 1.12 for Magento community and enterprise, respectively. If
|
198 |
+
* so, render the template. If not, return an empty string.
|
199 |
+
*
|
200 |
+
* @return string
|
201 |
+
*/
|
202 |
+
protected function _toHtml()
|
203 |
+
{
|
204 |
+
$helper = Mage::helper('postnl');
|
205 |
+
if (!$helper->isEnterprise() && version_compare(Mage::getVersion(), '1.7.0.0', '>=')) {
|
206 |
+
return '';
|
207 |
+
}
|
208 |
+
|
209 |
+
if ($helper->isEnterprise() && version_compare(Mage::getVersion(), '1.12.0.0', '>=')) {
|
210 |
+
return '';
|
211 |
+
}
|
212 |
+
|
213 |
+
return parent::_toHtml();
|
214 |
+
}
|
215 |
+
}
|
@@ -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.
|
@@ -33,67 +33,75 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Block_Core_ShippingStatus extends
|
40 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
/**
|
42 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
43 |
-
*
|
44 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
45 |
-
*
|
46 |
Â
* @return boolean
|
47 |
Â
*/
|
48 |
Â
public function isConfirmed($shipment)
|
49 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
50 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
51 |
Â
if ($postnlShipment->getConfirmStatus() == $postnlShipment::CONFIRM_STATUS_CONFIRMED) {
|
52 |
Â
return true;
|
53 |
Â
}
|
54 |
-
|
55 |
Â
return false;
|
56 |
Â
}
|
57 |
-
|
58 |
Â
/**
|
59 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
60 |
-
*
|
61 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
62 |
-
*
|
63 |
Â
* @return string
|
64 |
Â
*/
|
65 |
Â
public function getConfirmedAt($shipment)
|
66 |
Â
{
|
67 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
68 |
-
|
69 |
Â
$confirmedAt = Mage::helper('core')->formatDate($postnlShipment->getConfirmedAt(), 'medium', false);
|
70 |
-
|
71 |
Â
return $confirmedAt;
|
72 |
Â
}
|
73 |
-
|
74 |
Â
/**
|
75 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
76 |
-
*
|
77 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
78 |
-
*
|
79 |
Â
* @return boolean
|
80 |
Â
*/
|
81 |
Â
public function getTrackingUrl($shipment)
|
82 |
Â
{
|
83 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
84 |
-
|
85 |
Â
$barcodeUrl = $postnlShipment->getBarcodeUrl(true);
|
86 |
-
|
87 |
Â
$trackingUrl = "<a href={$barcodeUrl} title='mijnpakket' target='_blank'>"
|
88 |
Â
. $this->__('here')
|
89 |
Â
. '</a>';
|
90 |
-
|
91 |
Â
return $trackingUrl;
|
92 |
Â
}
|
93 |
-
|
94 |
Â
/**
|
95 |
Â
* Check if the PostNL module is enabled. Otherwise return an empty string.
|
96 |
-
*
|
97 |
Â
* @return string | Mage_Core_Block_Template::_toHtml()
|
98 |
Â
*/
|
99 |
Â
protected function _toHtml()
|
@@ -101,7 +109,7 @@ class TIG_PostNL_Block_Core_ShippingStatus extends Mage_Core_Block_Template
|
|
101 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
102 |
Â
return '';
|
103 |
Â
}
|
104 |
-
|
105 |
Â
return parent::_toHtml();
|
106 |
Â
}
|
107 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Block_Core_ShippingStatus extends TIG_PostNL_Block_Core_Template
|
40 |
Â
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_core_shippingstatus';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
48 |
+
*
|
49 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
50 |
+
*
|
51 |
Â
* @return boolean
|
52 |
Â
*/
|
53 |
Â
public function isConfirmed($shipment)
|
54 |
Â
{
|
55 |
+
/**
|
56 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
57 |
+
*/
|
58 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
59 |
Â
if ($postnlShipment->getConfirmStatus() == $postnlShipment::CONFIRM_STATUS_CONFIRMED) {
|
60 |
Â
return true;
|
61 |
Â
}
|
62 |
+
|
63 |
Â
return false;
|
64 |
Â
}
|
65 |
+
|
66 |
Â
/**
|
67 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
68 |
+
*
|
69 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
70 |
+
*
|
71 |
Â
* @return string
|
72 |
Â
*/
|
73 |
Â
public function getConfirmedAt($shipment)
|
74 |
Â
{
|
75 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
76 |
+
|
77 |
Â
$confirmedAt = Mage::helper('core')->formatDate($postnlShipment->getConfirmedAt(), 'medium', false);
|
78 |
+
|
79 |
Â
return $confirmedAt;
|
80 |
Â
}
|
81 |
+
|
82 |
Â
/**
|
83 |
Â
* Checks if a given shipment has been confirmed with PostNL
|
84 |
+
*
|
85 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
86 |
+
*
|
87 |
Â
* @return boolean
|
88 |
Â
*/
|
89 |
Â
public function getTrackingUrl($shipment)
|
90 |
Â
{
|
91 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
92 |
+
|
93 |
Â
$barcodeUrl = $postnlShipment->getBarcodeUrl(true);
|
94 |
+
|
95 |
Â
$trackingUrl = "<a href={$barcodeUrl} title='mijnpakket' target='_blank'>"
|
96 |
Â
. $this->__('here')
|
97 |
Â
. '</a>';
|
98 |
+
|
99 |
Â
return $trackingUrl;
|
100 |
Â
}
|
101 |
+
|
102 |
Â
/**
|
103 |
Â
* Check if the PostNL module is enabled. Otherwise return an empty string.
|
104 |
+
*
|
105 |
Â
* @return string | Mage_Core_Block_Template::_toHtml()
|
106 |
Â
*/
|
107 |
Â
protected function _toHtml()
|
109 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
110 |
Â
return '';
|
111 |
Â
}
|
112 |
+
|
113 |
Â
return parent::_toHtml();
|
114 |
Â
}
|
115 |
Â
}
|
@@ -0,0 +1,60 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
abstract class TIG_PostNL_Block_Core_Template extends Mage_Core_Block_Template
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_core_template';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Renders a template block. Also throws 2 events based on the current event prefix.
|
48 |
+
*
|
49 |
+
* @return string
|
50 |
+
*/
|
51 |
+
protected function _toHtml()
|
52 |
+
{
|
53 |
+
Mage::dispatchEvent($this->_eventPrefix . '_to_html_before');
|
54 |
+
|
55 |
+
$html = parent::_toHtml();
|
56 |
+
|
57 |
+
Mage::dispatchEvent($this->_eventPrefix . '_to_html_after');
|
58 |
+
return $html;
|
59 |
+
}
|
60 |
+
}
|
@@ -0,0 +1,124 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasPhoneNumber()
|
40 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber setPhoneNumber(string $phoneNumber)
|
41 |
+
* @method boolean hasShippingAddress()
|
42 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber setShippingAddress(Mage_Sales_Model_Quote_Address $address)
|
43 |
+
* @method boolean hasQuote()
|
44 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber setQuote(Mage_Sales_Model_Quote $quote)
|
45 |
+
*/
|
46 |
+
class TIG_PostNL_Block_DeliveryOptions_Checkout_AddPhoneNumber extends TIG_PostNL_Block_DeliveryOptions_Template
|
47 |
+
{
|
48 |
+
/**
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
protected $_eventPrefix = 'postnl_deliveryoptions_checkout_addphonenumber';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var string
|
55 |
+
*/
|
56 |
+
protected $_template = 'TIG/PostNL/delivery_options/addphonenumber.phtml';
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Gets a phone number.
|
60 |
+
*
|
61 |
+
* @return string
|
62 |
+
*/
|
63 |
+
public function getPhoneNumber()
|
64 |
+
{
|
65 |
+
if ($this->hasPhoneNumber()) {
|
66 |
+
return $this->_getData('phone_number');
|
67 |
+
}
|
68 |
+
|
69 |
+
$shippingAddress = $this->getShippingAddress();
|
70 |
+
$phoneNumber = $shippingAddress->getTelephone();
|
71 |
+
|
72 |
+
/**
|
73 |
+
* OSC often replaces missing required fields by a single dash. We want to avoid this behaviour.
|
74 |
+
*/
|
75 |
+
if ($phoneNumber == '-') {
|
76 |
+
$phoneNumber = '';
|
77 |
+
}
|
78 |
+
|
79 |
+
$this->setPhoneNumber($phoneNumber);
|
80 |
+
return $phoneNumber;
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Gets a shipping address object.
|
85 |
+
*
|
86 |
+
* @return Mage_Sales_Model_Quote_Address
|
87 |
+
*/
|
88 |
+
public function getShippingAddress()
|
89 |
+
{
|
90 |
+
if ($this->hasShippingAddress()) {
|
91 |
+
return $this->_getData('shipping_address');
|
92 |
+
}
|
93 |
+
|
94 |
+
$quote = $this->getQuote();
|
95 |
+
if (!$quote) {
|
96 |
+
$shippingAddress = Mage::getModel('sales/quote_address');
|
97 |
+
|
98 |
+
$this->setShippingAddress($shippingAddress);
|
99 |
+
return $shippingAddress;
|
100 |
+
}
|
101 |
+
|
102 |
+
$shippingAddress = $quote->getShippingAddress();
|
103 |
+
|
104 |
+
$this->setShippingAddress($shippingAddress);
|
105 |
+
return $shippingAddress;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Get the current quote.
|
110 |
+
*
|
111 |
+
* @return Mage_Sales_Model_Quote
|
112 |
+
*/
|
113 |
+
public function getQuote()
|
114 |
+
{
|
115 |
+
if ($this->hasQuote()) {
|
116 |
+
return $this->_getData('quote');
|
117 |
+
}
|
118 |
+
|
119 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
120 |
+
|
121 |
+
$this->setQuote($quote);
|
122 |
+
return $quote;
|
123 |
+
}
|
124 |
+
}
|
@@ -0,0 +1,560 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method string getMethodName()
|
40 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions setStreetnameField(int $value)
|
41 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions setHousenumberField(int $value)
|
42 |
+
* @method boolean hasTaxDisplayType()
|
43 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions setTaxDisplayType(int $value)
|
44 |
+
*/
|
45 |
+
class TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions extends TIG_PostNL_Block_DeliveryOptions_Template
|
46 |
+
{
|
47 |
+
/**
|
48 |
+
* @var string
|
49 |
+
*/
|
50 |
+
protected $_eventPrefix = 'postnl_deliveryoptions_checkout_deliveryoptions';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Xpath to 'allow_streetview' setting.
|
54 |
+
*/
|
55 |
+
const XPATH_ALLOW_STREETVIEW = 'postnl/delivery_options/allow_streetview';
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Currently selected shipping address.
|
59 |
+
*
|
60 |
+
* @var Mage_Sales_Model_Quote_Address|null
|
61 |
+
*/
|
62 |
+
protected $_shippingAddress = null;
|
63 |
+
|
64 |
+
/**
|
65 |
+
* The earliest possible delivery date.
|
66 |
+
*
|
67 |
+
* @var null|string
|
68 |
+
*/
|
69 |
+
protected $_deliveryDate = null;
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Set the currently selected shipping address.
|
73 |
+
*
|
74 |
+
* @param Mage_Sales_Model_Quote_Address|null $shippingAddress
|
75 |
+
*
|
76 |
+
* @return TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions
|
77 |
+
*/
|
78 |
+
public function setShippingAddress($shippingAddress)
|
79 |
+
{
|
80 |
+
$this->_shippingAddress = $shippingAddress;
|
81 |
+
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Gets the current quote.
|
87 |
+
*
|
88 |
+
* @return Mage_Sales_Model_Quote
|
89 |
+
*/
|
90 |
+
public function getQuote()
|
91 |
+
{
|
92 |
+
if ($this->hasData('quote')) {
|
93 |
+
return $this->_getData('quote');
|
94 |
+
}
|
95 |
+
|
96 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
97 |
+
|
98 |
+
$this->setData('quote', $quote);
|
99 |
+
return $quote;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Get the currently selected shipping address.
|
104 |
+
*
|
105 |
+
* @return Mage_Sales_Model_Quote_Address|null
|
106 |
+
*/
|
107 |
+
public function getShippingAddress()
|
108 |
+
{
|
109 |
+
$shippingAddress = $this->_shippingAddress;
|
110 |
+
if ($shippingAddress !== null) {
|
111 |
+
return $shippingAddress;
|
112 |
+
}
|
113 |
+
|
114 |
+
$shippingAddress = $this->_getShippingAddress();
|
115 |
+
|
116 |
+
if (!$shippingAddress) {
|
117 |
+
$shippingAddress = Mage::getModel('sales/quote_address');
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->setShippingAddress($shippingAddress);
|
121 |
+
return $shippingAddress;
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* Gets a shipping address from the current quote or from the customer if the customer is logged in.
|
126 |
+
*
|
127 |
+
* @return Mage_Customer_Model_Address|Mage_Sales_Model_Quote_Address
|
128 |
+
*/
|
129 |
+
protected function _getShippingAddress()
|
130 |
+
{
|
131 |
+
$quote = $this->getQuote();
|
132 |
+
$shippingAddress = $quote->getShippingAddress();
|
133 |
+
|
134 |
+
/**
|
135 |
+
* If we have billing data, the customer may still be entering their address, so we shouldn't do anything else
|
136 |
+
* for now.
|
137 |
+
*/
|
138 |
+
if (Mage::app()->getRequest()->getPost('billing')) {
|
139 |
+
return $shippingAddress;
|
140 |
+
}
|
141 |
+
|
142 |
+
$customerHelper = Mage::helper('customer');
|
143 |
+
|
144 |
+
/**
|
145 |
+
* OneStepCheckout sometimes stores a partial shipping address in the quote. This hack is meant to detect this
|
146 |
+
* and retrieve the full address from the customer's account if available. This is only done if we have no
|
147 |
+
* billing data in the $_POST superglobal to prevent conflicts with customers still entering their address.
|
148 |
+
*/
|
149 |
+
if (
|
150 |
+
(
|
151 |
+
!$shippingAddress->getPostcode()
|
152 |
+
|| $shippingAddress->getPostcode() == '-'
|
153 |
+
|| !$shippingAddress->getStreetFull()
|
154 |
+
)
|
155 |
+
&& $shippingAddress->getId()
|
156 |
+
&& $shippingAddress->getCustomerAddressId()
|
157 |
+
&& $customerHelper->isLoggedIn()
|
158 |
+
) {
|
159 |
+
$shippingAddress = $quote->getCustomer()->getAddressById($shippingAddress->getCustomerAddressId());
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* If we still don't have a full address, get the customer's default shipping address if available.
|
164 |
+
*/
|
165 |
+
if (
|
166 |
+
(
|
167 |
+
!$shippingAddress->getPostcode()
|
168 |
+
|| $shippingAddress->getPostcode() == '-'
|
169 |
+
|| !$shippingAddress->getStreetFull()
|
170 |
+
)
|
171 |
+
&& $customerHelper->isLoggedIn()
|
172 |
+
&& $customerHelper->customerHasAddresses()
|
173 |
+
) {
|
174 |
+
$shippingAddress = Mage::getSingleton('customer/session')->getCustomer()->getDefaultShippingAddress();
|
175 |
+
}
|
176 |
+
|
177 |
+
return $shippingAddress;
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Get the currently selected shipping address's postcode.
|
182 |
+
*
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
public function getPostcode()
|
186 |
+
{
|
187 |
+
$postcode = $this->getShippingAddress()->getPostcode();
|
188 |
+
|
189 |
+
$postcode = str_replace(' ', '', strtoupper($postcode));
|
190 |
+
|
191 |
+
return $postcode;
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Get the earliest possible delivery date.
|
196 |
+
*
|
197 |
+
* @return null|string
|
198 |
+
*/
|
199 |
+
public function getDeliveryDate()
|
200 |
+
{
|
201 |
+
$deliveryDate = $this->_deliveryDate;
|
202 |
+
|
203 |
+
if ($deliveryDate !== null) {
|
204 |
+
return $deliveryDate;
|
205 |
+
}
|
206 |
+
|
207 |
+
$quote = $this->getQuote();
|
208 |
+
$postcode = $this->getPostcode();
|
209 |
+
|
210 |
+
try {
|
211 |
+
$deliveryDate = $this->_getDeliveryDate($postcode, $quote);
|
212 |
+
} catch (Exception $e) {
|
213 |
+
Mage::helper('postnl')->logException($e);
|
214 |
+
|
215 |
+
$tomorrow = strtotime('tomorrow', Mage::getModel('core/date')->timestamp());
|
216 |
+
$deliveryDate = date('d-m-Y', $tomorrow);
|
217 |
+
}
|
218 |
+
|
219 |
+
$this->setDeliveryDate($deliveryDate);
|
220 |
+
return $deliveryDate;
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Set the earliest possible delivery date.
|
225 |
+
*
|
226 |
+
* @param string $deliveryDate
|
227 |
+
*
|
228 |
+
* @return TIG_PostNL_Block_DeliveryOptions_Checkout_DeliveryOptions
|
229 |
+
*/
|
230 |
+
public function setDeliveryDate($deliveryDate)
|
231 |
+
{
|
232 |
+
$this->_deliveryDate = $deliveryDate;
|
233 |
+
|
234 |
+
return $this;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Get the fee charged for evening timeframes.
|
239 |
+
*
|
240 |
+
* @param boolean $formatted
|
241 |
+
* @param boolean $includingTax
|
242 |
+
*
|
243 |
+
* @return float
|
244 |
+
*/
|
245 |
+
public function getEveningFee($formatted = false, $includingTax = true)
|
246 |
+
{
|
247 |
+
return Mage::helper('postnl/deliveryOptions')->getEveningFee($formatted, $includingTax);
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Get the fee charged for PakjeGemak Express.
|
252 |
+
*
|
253 |
+
* @param boolean $formatted
|
254 |
+
* @param boolean $includingTax
|
255 |
+
*
|
256 |
+
* @return float
|
257 |
+
*/
|
258 |
+
public function getExpressFee($formatted = false, $includingTax = true)
|
259 |
+
{
|
260 |
+
return Mage::helper('postnl/deliveryOptions')->getExpressFee($formatted, $includingTax);
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Get either the evening or express fee as a float or int.
|
265 |
+
*
|
266 |
+
* @param string $type
|
267 |
+
* @param boolean $includingTax
|
268 |
+
*
|
269 |
+
* @return float|int
|
270 |
+
*/
|
271 |
+
public function getFee($type, $includingTax = false) {
|
272 |
+
switch ($type) {
|
273 |
+
case 'evening':
|
274 |
+
$fee = $this->getEveningFee(false, $includingTax);
|
275 |
+
break;
|
276 |
+
case 'express':
|
277 |
+
$fee = $this->getExpressFee(false, $includingTax);
|
278 |
+
break;
|
279 |
+
default:
|
280 |
+
return 0;
|
281 |
+
}
|
282 |
+
|
283 |
+
/**
|
284 |
+
* If no fee is entered or an invalid value was entered, return an empty string.
|
285 |
+
*/
|
286 |
+
if (!$fee || $fee > 2 || $fee < 0) {
|
287 |
+
return 0;
|
288 |
+
}
|
289 |
+
|
290 |
+
return $fee;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Get either the evening or the express fee as a currency value.
|
295 |
+
*
|
296 |
+
* @param string $type
|
297 |
+
* @param boolean $includingTax
|
298 |
+
*
|
299 |
+
* @return string
|
300 |
+
*/
|
301 |
+
public function getFeeText($type, $includingTax = false)
|
302 |
+
{
|
303 |
+
switch ($type) {
|
304 |
+
case 'evening':
|
305 |
+
$feeText = $this->getEveningFee(true, $includingTax);
|
306 |
+
break;
|
307 |
+
case 'express':
|
308 |
+
$feeText = $this->getExpressFee(true, $includingTax);
|
309 |
+
break;
|
310 |
+
default:
|
311 |
+
return 0;
|
312 |
+
}
|
313 |
+
|
314 |
+
return $feeText;
|
315 |
+
}
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Get the field used for the address's streetname.
|
319 |
+
*
|
320 |
+
* @return int
|
321 |
+
*/
|
322 |
+
public function getStreetnameField()
|
323 |
+
{
|
324 |
+
if ($this->hasData('streetname_field')) {
|
325 |
+
return $this->_getData('streetname_field');
|
326 |
+
}
|
327 |
+
|
328 |
+
$streetnameField = Mage::helper('postnl/addressValidation')->getStreetnameField();
|
329 |
+
|
330 |
+
$this->setStreetnameField($streetnameField);
|
331 |
+
return $streetnameField;
|
332 |
+
}
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Get the field used for the address's housenumber.
|
336 |
+
*
|
337 |
+
* @return int
|
338 |
+
*/
|
339 |
+
public function getHousenumberField()
|
340 |
+
{
|
341 |
+
if ($this->hasData('housenumber_field')) {
|
342 |
+
return $this->_getData('housenumber_field');
|
343 |
+
}
|
344 |
+
|
345 |
+
$housenumberField = Mage::helper('postnl/addressValidation')->getHousenumberField();
|
346 |
+
|
347 |
+
$this->setHousenumberField($housenumberField);
|
348 |
+
return $housenumberField;
|
349 |
+
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Gets an array containing the selected shipping address's streetname, housenumber and housenumber extension.
|
353 |
+
*
|
354 |
+
* @return array
|
355 |
+
*/
|
356 |
+
public function getStreetData()
|
357 |
+
{
|
358 |
+
$storeId = Mage::app()->getStore()->getId();
|
359 |
+
$address = $this->getShippingAddress();
|
360 |
+
|
361 |
+
try {
|
362 |
+
$streetData = Mage::helper('postnl/cif')->getStreetData($storeId, $address, false);
|
363 |
+
} catch (Exception $e) {
|
364 |
+
Mage::helper('postnl')->logException($e);
|
365 |
+
|
366 |
+
$streetData = array(
|
367 |
+
'streetname' => '',
|
368 |
+
'housenumber' => '',
|
369 |
+
'housenumberExtension' => '',
|
370 |
+
'fullStreet' => '',
|
371 |
+
);
|
372 |
+
}
|
373 |
+
return $streetData;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Gets tax display type.
|
378 |
+
*
|
379 |
+
* @return int
|
380 |
+
*/
|
381 |
+
public function getTaxDisplayType()
|
382 |
+
{
|
383 |
+
if ($this->hasTaxDisplayType()) {
|
384 |
+
return $this->_getData('tax_display_type');
|
385 |
+
}
|
386 |
+
|
387 |
+
$taxDisplayType = Mage::getSingleton('tax/config')->getShippingPriceDisplayType();
|
388 |
+
|
389 |
+
$this->setTaxDisplayType($taxDisplayType);
|
390 |
+
return $taxDisplayType;
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Checks whether PakjeGemak locations are allowed.
|
395 |
+
*
|
396 |
+
* @return boolean
|
397 |
+
*/
|
398 |
+
public function canUsePakjeGemak()
|
399 |
+
{
|
400 |
+
$storeId = Mage::app()->getStore()->getId();
|
401 |
+
|
402 |
+
$canUsePakjeGemak = Mage::helper('postnl/deliveryOptions')->canUsePakjeGemak($storeId);
|
403 |
+
return $canUsePakjeGemak;
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Checks whether PakjeGemak Express locations are allowed.
|
408 |
+
*
|
409 |
+
* @return boolean
|
410 |
+
*/
|
411 |
+
public function canUsePakjeGemakExpress()
|
412 |
+
{
|
413 |
+
$storeId = Mage::app()->getStore()->getId();
|
414 |
+
|
415 |
+
$canUsePakjeGemakExpress = Mage::helper('postnl/deliveryOptions')->canUsePakjeGemakExpress($storeId);
|
416 |
+
return $canUsePakjeGemakExpress;
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Checks whether Pakket Automaat locations are allowed.
|
421 |
+
*
|
422 |
+
* @return boolean
|
423 |
+
*/
|
424 |
+
public function canUsePakketAutomaat()
|
425 |
+
{
|
426 |
+
$storeId = Mage::app()->getStore()->getId();
|
427 |
+
|
428 |
+
$canUsePakketAutomaat = Mage::helper('postnl/deliveryOptions')->canUsePakketAutomaat($storeId);
|
429 |
+
return $canUsePakketAutomaat;
|
430 |
+
}
|
431 |
+
|
432 |
+
/**
|
433 |
+
* Checks whether timeframes are allowed.
|
434 |
+
*
|
435 |
+
* @return boolean
|
436 |
+
*/
|
437 |
+
public function canUseTimeframes()
|
438 |
+
{
|
439 |
+
$storeId = Mage::app()->getStore()->getId();
|
440 |
+
|
441 |
+
$canUsePakketAutomaat = Mage::helper('postnl/deliveryOptions')->canUseTimeframes($storeId);
|
442 |
+
return $canUsePakketAutomaat;
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Checks whether evening timeframes are allowed.
|
447 |
+
*
|
448 |
+
* @return boolean
|
449 |
+
*/
|
450 |
+
public function canUseEveningTimeframes()
|
451 |
+
{
|
452 |
+
$storeId = Mage::app()->getStore()->getId();
|
453 |
+
|
454 |
+
$canUsePakketAutomaat = Mage::helper('postnl/deliveryOptions')->canUseEveningTimeframes($storeId);
|
455 |
+
return $canUsePakketAutomaat;
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Checks whether google streetview is allowed.
|
460 |
+
*
|
461 |
+
* @return boolean
|
462 |
+
*/
|
463 |
+
public function canUseStreetView()
|
464 |
+
{
|
465 |
+
$storeId = Mage::app()->getStore()->getId();
|
466 |
+
|
467 |
+
$streetviewAllowed = Mage::getStoreConfigFlag(self::XPATH_ALLOW_STREETVIEW, $storeId);
|
468 |
+
return $streetviewAllowed;
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* Checks whether the current theme uses cufon.
|
473 |
+
*
|
474 |
+
* @return boolean
|
475 |
+
*/
|
476 |
+
public function getUseCufon()
|
477 |
+
{
|
478 |
+
/**
|
479 |
+
* @var Varien_Simplexml_Element $theme
|
480 |
+
*/
|
481 |
+
$theme = $this->getCurrentTheme();
|
482 |
+
if (!$theme) {
|
483 |
+
return false;
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* @var Varien_Simplexml_Element $files
|
488 |
+
*/
|
489 |
+
$useCufon = (string) $theme->use_cufon;
|
490 |
+
if (!$useCufon) {
|
491 |
+
return false;
|
492 |
+
}
|
493 |
+
|
494 |
+
if ($useCufon === '1' || strcasecmp($useCufon, 'true') === 0) {
|
495 |
+
return true;
|
496 |
+
}
|
497 |
+
|
498 |
+
return false;
|
499 |
+
}
|
500 |
+
|
501 |
+
/**
|
502 |
+
* Checks if debug mode is allowed. Debug mode is enabled if the PostNl extension's debug mode is set to 'full'.
|
503 |
+
*
|
504 |
+
* @return bool
|
505 |
+
*/
|
506 |
+
public function isDebugEnabled()
|
507 |
+
{
|
508 |
+
$helper = Mage::helper('postnl');
|
509 |
+
$debugMode = $helper->getDebugMode();
|
510 |
+
|
511 |
+
if ($debugMode > 1) {
|
512 |
+
return true;
|
513 |
+
}
|
514 |
+
|
515 |
+
return false;
|
516 |
+
}
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Checks if delivery options are allowed for the current quote.
|
520 |
+
*
|
521 |
+
* @return bool
|
522 |
+
*/
|
523 |
+
public function canUseDeliveryOptions()
|
524 |
+
{
|
525 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
526 |
+
return $helper->canUseDeliveryOptions($this->getQuote());
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* get the first possible delivery date from PostNL.
|
531 |
+
*
|
532 |
+
* @param string $postcode
|
533 |
+
* @param Mage_Sales_Model_Quote $quote
|
534 |
+
*
|
535 |
+
* @throws TIG_PostNL_Exception
|
536 |
+
*
|
537 |
+
* @return string
|
538 |
+
*/
|
539 |
+
protected function _getDeliveryDate($postcode, Mage_Sales_Model_Quote $quote) {
|
540 |
+
$postcode = str_replace(' ', '', strtoupper($postcode));
|
541 |
+
|
542 |
+
$validator = new Zend_Validate_PostCode('nl_NL');
|
543 |
+
if (!$validator->isValid($postcode)) {
|
544 |
+
throw new TIG_PostNL_Exception(
|
545 |
+
$this->__(
|
546 |
+
'Invalid postcode supplied for GetDeliveryDate request: %s Postcodes may only contain 4 numbers '
|
547 |
+
. 'and 2 letters.',
|
548 |
+
$postcode
|
549 |
+
),
|
550 |
+
'POSTNL-0131'
|
551 |
+
);
|
552 |
+
}
|
553 |
+
|
554 |
+
$cif = Mage::getModel('postnl_deliveryoptions/cif');
|
555 |
+
$response = $cif->setStoreId(Mage::app()->getStore()->getId())
|
556 |
+
->getDeliveryDate($postcode, $quote);
|
557 |
+
|
558 |
+
return $response;
|
559 |
+
}
|
560 |
+
}
|
@@ -0,0 +1,70 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasApiKey()
|
40 |
+
* @method TIG_PostNL_Block_DeliveryOptions_Js setApiKey()
|
41 |
+
*/
|
42 |
+
class TIG_PostNL_Block_DeliveryOptions_Js extends TIG_PostNL_Block_DeliveryOptions_Template
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* @var string
|
46 |
+
*/
|
47 |
+
protected $_eventPrefix = 'postnl_deliveryoptions_js';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @var string
|
51 |
+
*/
|
52 |
+
protected $_template = 'TIG/PostNL/delivery_options/js.phtml';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Get the configured Google maps API key.
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getApiKey()
|
60 |
+
{
|
61 |
+
if ($this->hasApiKey()) {
|
62 |
+
return $this->_getData('api_key');
|
63 |
+
}
|
64 |
+
|
65 |
+
$apiKey = Mage::getStoreConfig('postnl/google_maps/api_key', Mage::app()->getStore()->getId());
|
66 |
+
|
67 |
+
$this->setApiKey($apiKey);
|
68 |
+
return $apiKey;
|
69 |
+
}
|
70 |
+
}
|
@@ -0,0 +1,123 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
abstract class TIG_PostNL_Block_DeliveryOptions_Template extends TIG_PostNL_Block_Core_Template
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* @var string
|
43 |
+
*/
|
44 |
+
protected $_eventPrefix = 'postnl_deliveryoptions_template';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Xpath to the current theme setting.
|
48 |
+
*/
|
49 |
+
const XPATH_THEME = 'postnl/delivery_options/theme';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var null|boolean|Varien_Simplexml_Element
|
53 |
+
*/
|
54 |
+
protected $_currentTheme = null;
|
55 |
+
|
56 |
+
/**
|
57 |
+
* @var null|boolean
|
58 |
+
*/
|
59 |
+
protected $_canUseDeliveryOptions = null;
|
60 |
+
|
61 |
+
/**
|
62 |
+
* Gets the current theme.
|
63 |
+
*
|
64 |
+
* @return bool|null|Varien_Simplexml_Element
|
65 |
+
*/
|
66 |
+
public function getCurrentTheme()
|
67 |
+
{
|
68 |
+
if ($this->_currentTheme !== null) {
|
69 |
+
return $this->_currentTheme;
|
70 |
+
}
|
71 |
+
|
72 |
+
$currentTheme = Mage::getStoreConfig(self::XPATH_THEME, Mage::app()->getStore()->getId());
|
73 |
+
|
74 |
+
$config = Mage::getConfig()->getNode('tig/delivery_options/themes');
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @var Varien_Simplexml_Element $theme
|
78 |
+
*/
|
79 |
+
$theme = $config->$currentTheme;
|
80 |
+
|
81 |
+
if (!$theme) {
|
82 |
+
$this->_currentTheme = false;
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
$this->_currentTheme = $theme;
|
87 |
+
return $theme;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Check if PostNL delivery options are available for the current quote.
|
92 |
+
*
|
93 |
+
* @return boolean
|
94 |
+
*/
|
95 |
+
public function canUseDeliveryOptions()
|
96 |
+
{
|
97 |
+
if ($this->_canUseDeliveryOptions !== null) {
|
98 |
+
return $this->_canUseDeliveryOptions;
|
99 |
+
}
|
100 |
+
|
101 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
102 |
+
|
103 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
104 |
+
$canUseDeliveryOptions = $helper->canUseDeliveryOptions($quote, false);
|
105 |
+
|
106 |
+
$this->_canUseDeliveryOptions = $canUseDeliveryOptions;
|
107 |
+
return $canUseDeliveryOptions;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Render the template if allowed.
|
112 |
+
*
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
protected function _toHtml()
|
116 |
+
{
|
117 |
+
if (!$this->canUseDeliveryOptions()) {
|
118 |
+
return '';
|
119 |
+
}
|
120 |
+
|
121 |
+
return parent::_toHtml();
|
122 |
+
}
|
123 |
+
}
|
@@ -0,0 +1,120 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasIsOsc()
|
40 |
+
*/
|
41 |
+
class TIG_PostNL_Block_DeliveryOptions_Theme extends TIG_PostNL_Block_DeliveryOptions_Template
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* @var string
|
45 |
+
*/
|
46 |
+
protected $_eventPrefix = 'postnl_deliveryoptions_theme';
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
protected $_template = 'TIG/PostNL/delivery_options/theme.phtml';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Gets whether the current checkout page is OneStepCheckout.
|
55 |
+
*
|
56 |
+
* @return boolean|mixed
|
57 |
+
*/
|
58 |
+
public function getIsOsc()
|
59 |
+
{
|
60 |
+
if (!$this->hasIsOsc()) {
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
return $this->_getData('is_osc');
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Gets a css file path for the current theme.
|
69 |
+
*
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getThemeCssFile()
|
73 |
+
{
|
74 |
+
/**
|
75 |
+
* @var Varien_Simplexml_Element $theme
|
76 |
+
*/
|
77 |
+
$theme = $this->getCurrentTheme();
|
78 |
+
if (!$theme) {
|
79 |
+
return '';
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @var Varien_Simplexml_Element $files
|
84 |
+
*/
|
85 |
+
$files = $theme->files;
|
86 |
+
if (!$files) {
|
87 |
+
return '';
|
88 |
+
}
|
89 |
+
|
90 |
+
if ($this->getIsOsc()) {
|
91 |
+
$file = (string) $files->onestepcheckout;
|
92 |
+
} else {
|
93 |
+
$file = (string) $files->onepage;
|
94 |
+
}
|
95 |
+
|
96 |
+
return $file;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Check if PostNL delivery options are available for the current quote.
|
101 |
+
*
|
102 |
+
* @return string
|
103 |
+
*/
|
104 |
+
protected function _toHtml()
|
105 |
+
{
|
106 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
107 |
+
|
108 |
+
$helper = Mage::helper('postnl/deliveryOptions');
|
109 |
+
|
110 |
+
if (!$helper->canUseDeliveryOptions($quote, false)) {
|
111 |
+
return '';
|
112 |
+
}
|
113 |
+
|
114 |
+
if (!$this->getThemeCssFile()) {
|
115 |
+
return '';
|
116 |
+
}
|
117 |
+
|
118 |
+
return parent::_toHtml();
|
119 |
+
}
|
120 |
+
}
|
@@ -0,0 +1,355 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasCanShowNotification()
|
40 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setCanShowNotification(bool $value)
|
41 |
+
* @method boolean hasCanShowCreateAccountLink()
|
42 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setCanShowCreateAccountLink(bool $value)
|
43 |
+
* @method boolean hasCanShowAppLink()
|
44 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setCanShowAppLink(bool $value)
|
45 |
+
* @method boolean hasPublicWebshopId()
|
46 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setPublicWebshopId(string $value)
|
47 |
+
* @method boolean hasOrder()
|
48 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setOrder(mixed $value)
|
49 |
+
* @method boolean hasShippingAddress()
|
50 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setShippingAddress(mixed $value)
|
51 |
+
* @method boolean hasCreateAccountUrl()
|
52 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setCreateAccountUrl(string $value)
|
53 |
+
* @method boolean hasCreateAccountBaseUrl()
|
54 |
+
* @method TIG_PostNL_Block_Mijnpakket_AccountNotification setCreateAccountBaseUrl(string $value)
|
55 |
+
*/
|
56 |
+
class TIG_PostNL_Block_Mijnpakket_AccountNotification extends TIG_PostNL_Block_Core_Template
|
57 |
+
{
|
58 |
+
/**
|
59 |
+
* @var string
|
60 |
+
*/
|
61 |
+
protected $_eventPrefix = 'postnl_mijnpakket_accountnotification';
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Base URL to create a new MijnPakket account.
|
65 |
+
*/
|
66 |
+
const CREATE_ACCOUNT_BASE_URL = 'https://mijnpakket.postnl.nl/Register/RegisterFromWebshop?';
|
67 |
+
|
68 |
+
/**
|
69 |
+
* The webshop's public webshop ID is used to secure communications with PostNL's servers.
|
70 |
+
*/
|
71 |
+
const XPATH_PUBLIC_WEBSHOP_ID = 'postnl/cif/public_webshop_id';
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Xpaths determining various options regarding the MijnPakket notification.
|
75 |
+
*/
|
76 |
+
const XPATH_MIJNPAKKET_NOTIFICATION = 'postnl/delivery_options/mijnpakket_notification';
|
77 |
+
const XPATH_SHOW_CREATE_MIJNPAKKET_ACCOUNT_LINK = 'postnl/delivery_options/show_create_mijnpakket_account_link';
|
78 |
+
const XPATH_SHOW_MIJNPAKKET_APP_LINK = 'postnl/delivery_options/show_mijnpakket_app_link';
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @var string
|
82 |
+
*/
|
83 |
+
protected $_template = 'TIG/PostNL/mijnpakket/account_notification.phtml';
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Checks if showing the MijnPakket notification is allowed.
|
87 |
+
*
|
88 |
+
* @return bool|mixed
|
89 |
+
*/
|
90 |
+
public function getCanShowNotification()
|
91 |
+
{
|
92 |
+
if ($this->hasCanShowNotification()) {
|
93 |
+
return $this->_getData('can_show_notification');
|
94 |
+
}
|
95 |
+
|
96 |
+
if (!Mage::helper('postnl/deliveryOptions')->canUseDeliveryOptions()) {
|
97 |
+
$this->setCanShowNotification(false);
|
98 |
+
return false;
|
99 |
+
}
|
100 |
+
|
101 |
+
$storeId = Mage::app()->getStore()->getId();
|
102 |
+
$canShowNotification = Mage::getStoreConfigFlag(self::XPATH_MIJNPAKKET_NOTIFICATION, $storeId);
|
103 |
+
|
104 |
+
$this->setCanShowNotification($canShowNotification);
|
105 |
+
return $canShowNotification;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Checks if showing the MijnPakket create account link is allowed.
|
110 |
+
*
|
111 |
+
* @return bool|mixed
|
112 |
+
*/
|
113 |
+
public function getCanShowCreateAccountLink()
|
114 |
+
{
|
115 |
+
if ($this->hasCanShowCreateAccountLink()) {
|
116 |
+
return $this->_getData('can_show_create_account_link');
|
117 |
+
}
|
118 |
+
|
119 |
+
$storeId = Mage::app()->getStore()->getId();
|
120 |
+
$canShowLink = Mage::getStoreConfigFlag(self::XPATH_SHOW_CREATE_MIJNPAKKET_ACCOUNT_LINK, $storeId);
|
121 |
+
|
122 |
+
$this->setCanShowCreateAccountLink($canShowLink);
|
123 |
+
return $canShowLink;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Checks if showing the MijnPakket app link is allowed.
|
128 |
+
*
|
129 |
+
* @return bool|mixed
|
130 |
+
*/
|
131 |
+
public function getCanShowAppLink()
|
132 |
+
{
|
133 |
+
if ($this->hasCanShowAppLink()) {
|
134 |
+
return $this->_getData('can_show_app_link');
|
135 |
+
}
|
136 |
+
|
137 |
+
$storeId = Mage::app()->getStore()->getId();
|
138 |
+
$canShowLink = Mage::getStoreConfigFlag(self::XPATH_SHOW_MIJNPAKKET_APP_LINK, $storeId);
|
139 |
+
|
140 |
+
$this->setCanShowAppLink($canShowLink);
|
141 |
+
return $canShowLink;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Get the current public webshop ID.
|
146 |
+
*
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
+
public function getPublicWebshopId()
|
150 |
+
{
|
151 |
+
if ($this->hasPublicWebshopId()) {
|
152 |
+
return $this->_getData('public_webshop_id');
|
153 |
+
}
|
154 |
+
|
155 |
+
$publicWebshopId = Mage::getStoreConfig(self::XPATH_PUBLIC_WEBSHOP_ID, Mage::app()->getStore()->getId());
|
156 |
+
|
157 |
+
$this->setPublicWebshopId($publicWebshopId);
|
158 |
+
return $publicWebshopId;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Gets the last placed order.
|
163 |
+
*
|
164 |
+
* @return Mage_Sales_Model_Order|boolean
|
165 |
+
*/
|
166 |
+
public function getOrder()
|
167 |
+
{
|
168 |
+
if ($this->hasOrder()) {
|
169 |
+
return $this->_getData('order');
|
170 |
+
}
|
171 |
+
|
172 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
173 |
+
if (!$orderId) {
|
174 |
+
return false;
|
175 |
+
}
|
176 |
+
|
177 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
178 |
+
|
179 |
+
$this->setOrder($order);
|
180 |
+
return $order;
|
181 |
+
}
|
182 |
+
|
183 |
+
/**
|
184 |
+
* Gets the shipping address of the last placed order.
|
185 |
+
*
|
186 |
+
* @return Mage_Sales_Model_Order_Address|boolean
|
187 |
+
*/
|
188 |
+
public function getShippingAddress()
|
189 |
+
{
|
190 |
+
if ($this->hasShippingAddress()) {
|
191 |
+
return $this->_getData('shipping_address');
|
192 |
+
}
|
193 |
+
|
194 |
+
$order = $this->getOrder();
|
195 |
+
if (!$order) {
|
196 |
+
$this->setShippingAddress(false);
|
197 |
+
return false;
|
198 |
+
}
|
199 |
+
|
200 |
+
$shippingAddress = $order->getShippingAddress();
|
201 |
+
if (!$shippingAddress) {
|
202 |
+
$this->setShippingAddress(false);
|
203 |
+
return false;
|
204 |
+
}
|
205 |
+
|
206 |
+
$this->setShippingAddress($shippingAddress);
|
207 |
+
return $shippingAddress;
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Gets the base create MijnPakket account URL.
|
212 |
+
*
|
213 |
+
* @return string
|
214 |
+
*/
|
215 |
+
public function getCreateAccountBaseUrl()
|
216 |
+
{
|
217 |
+
if ($this->hasCreateAccountBaseUrl()) {
|
218 |
+
return $this->_getData('create_account_base_url');
|
219 |
+
}
|
220 |
+
|
221 |
+
$baseUrl = self::CREATE_ACCOUNT_BASE_URL;
|
222 |
+
|
223 |
+
$this->setCreateAccountBaseUrl($baseUrl);
|
224 |
+
return $baseUrl;
|
225 |
+
}
|
226 |
+
|
227 |
+
/**
|
228 |
+
* Form the create MijnPakket account url based on the hardcoded base URL and a dynamic set of parameters.
|
229 |
+
*
|
230 |
+
* @return string
|
231 |
+
*/
|
232 |
+
public function getCreateAccountUrl()
|
233 |
+
{
|
234 |
+
if ($this->hasCreateAccountUrl()) {
|
235 |
+
return $this->_getData('create_account_url');
|
236 |
+
}
|
237 |
+
|
238 |
+
$baseUrl = $this->getCreateAccountBaseUrl();
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Add the optional params to the base url.
|
242 |
+
*/
|
243 |
+
$urlParams = $this->_getUrlParams();
|
244 |
+
$queryString = http_build_query($urlParams);
|
245 |
+
|
246 |
+
$createAccountUrl = $baseUrl . $queryString;
|
247 |
+
|
248 |
+
$this->setCreateAccountUrl($createAccountUrl);
|
249 |
+
return $createAccountUrl;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Gets all the URL parameters to create a MijnPakket account. While alle parameters are optional, the more we add,
|
254 |
+
* the less the customer will have to add manually later on.
|
255 |
+
*
|
256 |
+
* @return array
|
257 |
+
*/
|
258 |
+
protected function _getUrlParams()
|
259 |
+
{
|
260 |
+
/**
|
261 |
+
* get the webshop's public ID. This should be the only parameter that is always available.
|
262 |
+
*/
|
263 |
+
$publicWebshopId = $this->getPublicWebshopId();
|
264 |
+
|
265 |
+
/**
|
266 |
+
* If no order or shipping address is available, return just the public webshop ID.
|
267 |
+
*/
|
268 |
+
$order = $this->getOrder();
|
269 |
+
$shippingAddress = $this->getShippingAddress();
|
270 |
+
if (!$order || !$shippingAddress) {
|
271 |
+
return array('webshopPublicId' => $publicWebshopId);
|
272 |
+
}
|
273 |
+
|
274 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Get the basic order parameters.
|
278 |
+
*/
|
279 |
+
$firstname = $shippingAddress->getFirstname();
|
280 |
+
$params = array(
|
281 |
+
'webshopPublicId' => $publicWebshopId,
|
282 |
+
'initials' => $helper->getInitials($firstname),
|
283 |
+
'firstName' => $firstname,
|
284 |
+
'middleName' => $shippingAddress->getMiddlename(),
|
285 |
+
'lastName' => $shippingAddress->getLastname(),
|
286 |
+
'email' => $shippingAddress->getEmail(),
|
287 |
+
'postalCode' => $shippingAddress->getPostcode(),
|
288 |
+
'business' => 'P',
|
289 |
+
);
|
290 |
+
|
291 |
+
/**
|
292 |
+
* If this address hads a VAT ID, it's probably a B2B client.
|
293 |
+
*/
|
294 |
+
$vat = $shippingAddress->getVatId();
|
295 |
+
if ($vat) {
|
296 |
+
$params['business'] = 'Z';
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Optionally add the dob.
|
301 |
+
*/
|
302 |
+
$dob = $shippingAddress->getDob();
|
303 |
+
if ($dob) {
|
304 |
+
$dob = date('d-m-Y', strtotime($dob));
|
305 |
+
$params['birthDate'] = $dob;
|
306 |
+
}
|
307 |
+
|
308 |
+
/**
|
309 |
+
* If we have a mobile phonenumber for this address, add that as well.
|
310 |
+
*
|
311 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
312 |
+
*/
|
313 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($order->getId(), 'order_id');
|
314 |
+
if ($postnlOrder->getId() && $postnlOrder->getMobilePhoneNumber()) {
|
315 |
+
$params['mobileNumber'] = $postnlOrder->getMobilePhoneNumber();
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Get the split address data of this order.
|
320 |
+
*/
|
321 |
+
$streetData = false;
|
322 |
+
try {
|
323 |
+
$streetData = Mage::helper('postnl/cif')->getStreetData($order->getStoreId(), $shippingAddress, false);
|
324 |
+
} catch (Exception $e) {
|
325 |
+
Mage::helper('postnl')->logException($e);
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* If we have split address data, add the housenumber and housenumber extension.
|
330 |
+
*/
|
331 |
+
if ($streetData && isset($streetData['housenumber'])) {
|
332 |
+
$params['houseNumber'] = $streetData['housenumber'];
|
333 |
+
|
334 |
+
if (isset($streetData['housenumberExtension']) && !empty($streetData['housenumberExtension'])) {
|
335 |
+
$params['houseNumberSuffix'] = $streetData['housenumberExtension'];
|
336 |
+
}
|
337 |
+
}
|
338 |
+
|
339 |
+
return $params;
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Check if MijnPakket notification can be shown before rendering the template.
|
344 |
+
*
|
345 |
+
* @return string
|
346 |
+
*/
|
347 |
+
protected function _toHtml()
|
348 |
+
{
|
349 |
+
if (!$this->getCanShowNotification()) {
|
350 |
+
return '';
|
351 |
+
}
|
352 |
+
|
353 |
+
return parent::_toHtml();
|
354 |
+
}
|
355 |
+
}
|
@@ -0,0 +1,143 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasIsTestMode()
|
40 |
+
* @method TIG_PostNL_Block_Mijnpakket_Js setIsTestMode(boolean $value)
|
41 |
+
* @method boolean hasBaseUrl()
|
42 |
+
* @method TIG_PostNL_Block_Mijnpakket_Js setBaseUrl(string $value)
|
43 |
+
*/
|
44 |
+
class TIG_PostNL_Block_Mijnpakket_Js extends TIG_PostNL_Block_Core_Template
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $_eventPrefix = 'postnl_mijnpakket_js';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var string
|
53 |
+
*/
|
54 |
+
protected $_template = 'TIG/PostNL/mijnpakket/js.phtml';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Available URl's for PostNL's login API.
|
58 |
+
*/
|
59 |
+
const LIVE_BASE_URL = 'https://mijnpakket.postnl.nl/';
|
60 |
+
const TEST_BASE_URL = 'https://tppwscheckout-sandbox.e-id.nl/';
|
61 |
+
const LOGIN_JS_PATH = 'Checkout2/Login.js';
|
62 |
+
const CHECKOUT_PREMIUM_JS_PATH = 'Checkout2/CheckoutPremium.js';
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return boolean
|
66 |
+
*/
|
67 |
+
public function getIsTestMode()
|
68 |
+
{
|
69 |
+
if ($this->hasIsTestMode()) {
|
70 |
+
return $this->_getData('is_test_mode');
|
71 |
+
}
|
72 |
+
|
73 |
+
$isTestMode = Mage::helper('postnl/mijnpakket')->isTestMode();
|
74 |
+
|
75 |
+
$this->setIsTestMode($isTestMode);
|
76 |
+
return $isTestMode;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Gets the current base URL based on whether the extension is set to test mode.
|
81 |
+
*
|
82 |
+
* @return string
|
83 |
+
*/
|
84 |
+
public function getBaseUrl()
|
85 |
+
{
|
86 |
+
if ($this->hasBaseUrl()) {
|
87 |
+
return $this->_getData('base_url');
|
88 |
+
}
|
89 |
+
|
90 |
+
$isTestMode = $this->getIsTestMode();
|
91 |
+
if ($isTestMode) {
|
92 |
+
$baseUrl = self::TEST_BASE_URL;
|
93 |
+
} else {
|
94 |
+
$baseUrl = self::LIVE_BASE_URL;
|
95 |
+
}
|
96 |
+
|
97 |
+
$this->setBaseUrl($baseUrl);
|
98 |
+
return $baseUrl;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* gets the Mijnpakket Login JS URL for either live or test mode.
|
103 |
+
*
|
104 |
+
* @return string
|
105 |
+
*/
|
106 |
+
public function getLoginJsUrl()
|
107 |
+
{
|
108 |
+
$baseUrl = $this->getBaseUrl();
|
109 |
+
|
110 |
+
$url = $baseUrl . self::LOGIN_JS_PATH;
|
111 |
+
|
112 |
+
return $url;
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Get the Checkout premium JS URL which is used to check if the customer has a MijnPakket account.
|
117 |
+
*
|
118 |
+
* @return string
|
119 |
+
*/
|
120 |
+
public function getCheckoutPremiumJsUrl()
|
121 |
+
{
|
122 |
+
$baseUrl = $this->getBaseUrl();
|
123 |
+
|
124 |
+
$url = $baseUrl . self::CHECKOUT_PREMIUM_JS_PATH;
|
125 |
+
|
126 |
+
return $url;
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Check if the current customer may login using Mijnpakket.
|
131 |
+
*
|
132 |
+
* @return string
|
133 |
+
*/
|
134 |
+
protected function _tohtml()
|
135 |
+
{
|
136 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
137 |
+
if (!$helper->canLoginWithMijnpakket()) {
|
138 |
+
return '';
|
139 |
+
}
|
140 |
+
|
141 |
+
return parent::_toHtml();
|
142 |
+
}
|
143 |
+
}
|
@@ -0,0 +1,216 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasIsTestMode()
|
40 |
+
* @method TIG_PostNL_Block_Mijnpakket_LoginButton setIsTestMode(boolean $value)
|
41 |
+
* @method boolean hasBaseUrl()
|
42 |
+
* @method TIG_PostNL_Block_Mijnpakket_LoginButton setBaseUrl(string $value)
|
43 |
+
* @method boolean hasPublicWebshopId()
|
44 |
+
* @method TIG_PostNL_Block_Mijnpakket_LoginButton setPublicWebshopId(string $value)
|
45 |
+
* @method boolean hasSavedMijnpakketData()
|
46 |
+
* @method TIG_PostNL_Block_Mijnpakket_LoginButton setSavedMijnpakketData(string $value)
|
47 |
+
* @method boolean hasButtonUrl()
|
48 |
+
* @method TIG_PostNL_Block_Mijnpakket_LoginButton setButtonUrl(string $value)
|
49 |
+
* @method boolean hasDisabledButtonUrl()
|
50 |
+
* @method TIG_PostNL_Block_Mijnpakket_LoginButton setDisabledButtonUrl(string $value)
|
51 |
+
*/
|
52 |
+
class TIG_PostNL_Block_Mijnpakket_LoginButton extends TIG_PostNL_Block_Core_Template
|
53 |
+
{
|
54 |
+
/**
|
55 |
+
* @var string
|
56 |
+
*/
|
57 |
+
protected $_eventPrefix = 'postnl_mijnpakket_loginbutton';
|
58 |
+
|
59 |
+
/**
|
60 |
+
* The webshop's public webshop ID is used to secure communications with PostNL's servers.
|
61 |
+
*/
|
62 |
+
const XPATH_PUBLIC_WEBSHOP_ID = 'postnl/cif/public_webshop_id';
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Available URl's for PostNL's login buttons.
|
66 |
+
*/
|
67 |
+
const LIVE_BASE_URL = 'https://checkout.postnl.nl/';
|
68 |
+
const TEST_BASE_URL = 'https://tppcb-sandbox.e-id.nl/';
|
69 |
+
const BUTTON_URL_PATH = 'Button/PremiumLogin';
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @var string
|
73 |
+
*/
|
74 |
+
protected $_template = 'TIG/PostNL/mijnpakket/login_button.phtml';
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @return boolean
|
78 |
+
*/
|
79 |
+
public function getIsTestMode()
|
80 |
+
{
|
81 |
+
if ($this->hasIsTestMode()) {
|
82 |
+
return $this->_getData('is_test_mode');
|
83 |
+
}
|
84 |
+
|
85 |
+
$isTestMode = Mage::helper('postnl/mijnpakket')->isTestMode();
|
86 |
+
|
87 |
+
$this->setIsTestMode($isTestMode);
|
88 |
+
return $isTestMode;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Gets the current base URL based on whether the extension is set to test mode.
|
93 |
+
*
|
94 |
+
* @return string
|
95 |
+
*/
|
96 |
+
public function getBaseUrl()
|
97 |
+
{
|
98 |
+
if ($this->hasBaseUrl()) {
|
99 |
+
return $this->_getData('base_url');
|
100 |
+
}
|
101 |
+
|
102 |
+
$isTestMode = $this->getIsTestMode();
|
103 |
+
if ($isTestMode) {
|
104 |
+
$baseUrl = self::TEST_BASE_URL;
|
105 |
+
} else {
|
106 |
+
$baseUrl = self::LIVE_BASE_URL;
|
107 |
+
}
|
108 |
+
|
109 |
+
$this->setBaseUrl($baseUrl);
|
110 |
+
return $baseUrl;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get the current public webshop ID.
|
115 |
+
*
|
116 |
+
* @return string
|
117 |
+
*/
|
118 |
+
public function getPublicWebshopId()
|
119 |
+
{
|
120 |
+
if ($this->hasPublicWebshopId()) {
|
121 |
+
return $this->_getData('public_webshop_id');
|
122 |
+
}
|
123 |
+
|
124 |
+
$publicWebshopId = Mage::getStoreConfig(self::XPATH_PUBLIC_WEBSHOP_ID, Mage::app()->getStore()->getId());
|
125 |
+
|
126 |
+
$this->setPublicWebshopId($publicWebshopId);
|
127 |
+
return $publicWebshopId;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Get saved MijnPakket data if available.
|
132 |
+
*
|
133 |
+
* @return array|null
|
134 |
+
*/
|
135 |
+
public function getSavedMijnpakketData()
|
136 |
+
{
|
137 |
+
if ($this->hasSavedMijnpakketData()) {
|
138 |
+
return $this->_getData('saved_mijnpakket_data');
|
139 |
+
}
|
140 |
+
|
141 |
+
$data = Mage::getSingleton('checkout/session')->getPostnlMijnpakketData();
|
142 |
+
|
143 |
+
$this->setSavedMijnpakketData($data);
|
144 |
+
return $data;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Gets the button URL.
|
149 |
+
*
|
150 |
+
* @return string
|
151 |
+
*/
|
152 |
+
public function getButtonUrl()
|
153 |
+
{
|
154 |
+
if ($this->hasButtonUrl()) {
|
155 |
+
return $this->_getData('button_url');
|
156 |
+
}
|
157 |
+
|
158 |
+
$baseUrl = $this->getBaseUrl();
|
159 |
+
$url = $baseUrl . self::BUTTON_URL_PATH;
|
160 |
+
|
161 |
+
$url .= '?publicId=' . $this->getPublicWebshopId();
|
162 |
+
|
163 |
+
$this->setButtonUrl($url);
|
164 |
+
return $url;
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Gets the URL for the disabled button.
|
169 |
+
*
|
170 |
+
* @return string
|
171 |
+
*/
|
172 |
+
public function getDisabledButtonUrl()
|
173 |
+
{
|
174 |
+
if ($this->hasDisabledButtonUrl()) {
|
175 |
+
return $this->_getData('disabled_button_url');
|
176 |
+
}
|
177 |
+
|
178 |
+
$buttonUrl = $this->getButtonUrl();
|
179 |
+
$buttonUrl .= '&disabled=true';
|
180 |
+
|
181 |
+
$this->setDisabledButtonUrl($buttonUrl);
|
182 |
+
return $buttonUrl;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Checks if debug mode is allowed. Debug mode is enabled if the PostNl extension's debug mode is set to 'full'.
|
187 |
+
*
|
188 |
+
* @return bool
|
189 |
+
*/
|
190 |
+
public function isDebugEnabled()
|
191 |
+
{
|
192 |
+
$helper = Mage::helper('postnl');
|
193 |
+
$debugMode = $helper->getDebugMode();
|
194 |
+
|
195 |
+
if ($debugMode > 1) {
|
196 |
+
return true;
|
197 |
+
}
|
198 |
+
|
199 |
+
return false;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Check if the current customer may login using MijnPakket.
|
204 |
+
*
|
205 |
+
* @return string
|
206 |
+
*/
|
207 |
+
protected function _tohtml()
|
208 |
+
{
|
209 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
210 |
+
if (!$helper->canLoginWithMijnpakket()) {
|
211 |
+
return '';
|
212 |
+
}
|
213 |
+
|
214 |
+
return parent::_toHtml();
|
215 |
+
}
|
216 |
+
}
|
@@ -0,0 +1,70 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasIsTestMode()
|
40 |
+
* @method TIG_PostNL_Block_Mijnpakket_Js setIsTestMode(boolean $value)
|
41 |
+
* @method boolean hasBaseUrl()
|
42 |
+
* @method TIG_PostNL_Block_Mijnpakket_Js setBaseUrl(string $value)
|
43 |
+
*/
|
44 |
+
class TIG_PostNL_Block_Mijnpakket_OrderSuccessJs extends TIG_PostNL_Block_Checkout_Cart_Js
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* @var string
|
48 |
+
*/
|
49 |
+
protected $_eventPrefix = 'postnl_mijnpakket_ordersuccessjs';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @var string
|
53 |
+
*/
|
54 |
+
protected $_template = 'TIG/PostNL/mijnpakket/order_success_js.phtml';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Check if the current customer may login using Mijnpakket.
|
58 |
+
*
|
59 |
+
* @return string
|
60 |
+
*/
|
61 |
+
protected function _tohtml()
|
62 |
+
{
|
63 |
+
$helper = Mage::helper('postnl/mijnpakket');
|
64 |
+
if (!$helper->canLoginWithMijnpakket()) {
|
65 |
+
return '';
|
66 |
+
}
|
67 |
+
|
68 |
+
return TIG_PostNL_Block_Core_Template::_toHtml();
|
69 |
+
}
|
70 |
+
}
|
@@ -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.
|
@@ -33,34 +33,32 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
|
40 |
Â
/**
|
41 |
-
* General exception class for TIG_PostNL
|
42 |
-
*
|
43 |
Â
* @see Mage_Core_Exception
|
44 |
Â
*/
|
45 |
Â
class TIG_PostNL_Exception extends Mage_Core_Exception
|
46 |
Â
{
|
47 |
Â
/**
|
48 |
-
* Our codes are
|
49 |
-
*
|
50 |
-
* @param string
|
51 |
-
* @param mixed
|
52 |
Â
* @param Exception|null $previous
|
53 |
-
*
|
54 |
-
* @return void
|
55 |
-
*
|
56 |
Â
* @see Exception::__construct()
|
57 |
-
*
|
58 |
Â
* @link http://www.php.net/manual/en/exception.construct.php
|
59 |
Â
*/
|
60 |
Â
public function __construct($message, $code = 0, Exception $previous = null)
|
61 |
Â
{
|
62 |
Â
parent::__construct($message, 0, $previous);
|
63 |
-
|
64 |
Â
/**
|
65 |
Â
* Replace the code with the actual, non-integer code
|
66 |
Â
*/
|
@@ -69,40 +67,40 @@ class TIG_PostNL_Exception extends Mage_Core_Exception
|
|
69 |
Â
$this->code = $code;
|
70 |
Â
}
|
71 |
Â
}
|
72 |
-
|
73 |
Â
/**
|
74 |
Â
* Custom __toString method that includes the error code, if preset.
|
75 |
-
*
|
76 |
Â
* @return string
|
77 |
-
*
|
78 |
Â
* @see Exception::__toString()
|
79 |
-
*
|
80 |
Â
* @link http://www.php.net/manual/en/exception.tostring.php
|
81 |
Â
*/
|
82 |
Â
public function __toString()
|
83 |
Â
{
|
84 |
-
$string = "exception '"
|
85 |
-
. __CLASS__
|
86 |
-
. "' with message '"
|
87 |
Â
. $this->getMessage()
|
88 |
Â
. "'";
|
89 |
-
|
90 |
Â
$code = $this->getCode();
|
91 |
Â
if ($code !== 0 && !empty($code)) {
|
92 |
-
$string .= " and code: '"
|
93 |
-
. $this->getCode()
|
94 |
Â
. "'";
|
95 |
Â
}
|
96 |
-
|
97 |
-
$string .= " in "
|
98 |
-
. $this->getFile()
|
99 |
-
. ':'
|
100 |
-
. $this->getLine()
|
101 |
-
. PHP_EOL
|
102 |
Â
. 'Stack trace:'
|
103 |
Â
. PHP_EOL
|
104 |
Â
. $this->getTraceAsString();
|
105 |
-
|
106 |
Â
return $string;
|
107 |
Â
}
|
108 |
Â
}
|
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.
|
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 |
+
* General exception class for TIG_PostNL extension
|
42 |
+
*
|
43 |
Â
* @see Mage_Core_Exception
|
44 |
Â
*/
|
45 |
Â
class TIG_PostNL_Exception extends Mage_Core_Exception
|
46 |
Â
{
|
47 |
Â
/**
|
48 |
+
* Our error codes are strings, however the core Exception class only accepts integers, so we need to overload it.
|
49 |
+
*
|
50 |
+
* @param string $message
|
51 |
+
* @param mixed $code
|
52 |
Â
* @param Exception|null $previous
|
53 |
+
*
|
Â
|
|
Â
|
|
54 |
Â
* @see Exception::__construct()
|
55 |
+
*
|
56 |
Â
* @link http://www.php.net/manual/en/exception.construct.php
|
57 |
Â
*/
|
58 |
Â
public function __construct($message, $code = 0, Exception $previous = null)
|
59 |
Â
{
|
60 |
Â
parent::__construct($message, 0, $previous);
|
61 |
+
|
62 |
Â
/**
|
63 |
Â
* Replace the code with the actual, non-integer code
|
64 |
Â
*/
|
67 |
Â
$this->code = $code;
|
68 |
Â
}
|
69 |
Â
}
|
70 |
+
|
71 |
Â
/**
|
72 |
Â
* Custom __toString method that includes the error code, if preset.
|
73 |
+
*
|
74 |
Â
* @return string
|
75 |
+
*
|
76 |
Â
* @see Exception::__toString()
|
77 |
+
*
|
78 |
Â
* @link http://www.php.net/manual/en/exception.tostring.php
|
79 |
Â
*/
|
80 |
Â
public function __toString()
|
81 |
Â
{
|
82 |
+
$string = "exception '"
|
83 |
+
. __CLASS__
|
84 |
+
. "' with message '"
|
85 |
Â
. $this->getMessage()
|
86 |
Â
. "'";
|
87 |
+
|
88 |
Â
$code = $this->getCode();
|
89 |
Â
if ($code !== 0 && !empty($code)) {
|
90 |
+
$string .= " and code: '"
|
91 |
+
. $this->getCode()
|
92 |
Â
. "'";
|
93 |
Â
}
|
94 |
+
|
95 |
+
$string .= " in "
|
96 |
+
. $this->getFile()
|
97 |
+
. ':'
|
98 |
+
. $this->getLine()
|
99 |
+
. PHP_EOL
|
100 |
Â
. 'Stack trace:'
|
101 |
Â
. PHP_EOL
|
102 |
Â
. $this->getTraceAsString();
|
103 |
+
|
104 |
Â
return $string;
|
105 |
Â
}
|
106 |
Â
}
|
@@ -0,0 +1,400 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Helper_AddressValidation extends TIG_PostNL_Helper_Data
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* XML path to use_postcode_check setting
|
43 |
+
*/
|
44 |
+
const XML_PATH_USE_POSTCODE_CHECK = 'postnl/cif_address/use_postcode_check';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Constants containing XML paths to cif address configuration options
|
48 |
+
*/
|
49 |
+
const XML_PATH_SPLIT_STREET = 'postnl/cif_address/split_street';
|
50 |
+
const XML_PATH_STREETNAME_FIELD = 'postnl/cif_address/streetname_field';
|
51 |
+
const XML_PATH_HOUSENUMBER_FIELD = 'postnl/cif_address/housenr_field';
|
52 |
+
const XML_PATH_SPLIT_HOUSENUMBER = 'postnl/cif_address/split_housenr';
|
53 |
+
const XML_PATH_HOUSENUMBER_EXTENSION_FIELD = 'postnl/cif_address/housenr_extension_field';
|
54 |
+
|
55 |
+
/**
|
56 |
+
* XML paths to flags that dtermine which environment allows the postcode check functionality
|
57 |
+
*/
|
58 |
+
const XML_PATH_POSTCODE_CHECK_IN_CHECKOUT = 'postnl/cif_address/postcode_check_in_checkout';
|
59 |
+
const XML_PATH_POSTCODE_CHECK_IN_ADDRESSBOOK = 'postnl/cif_address/postcode_check_in_addressbook';
|
60 |
+
|
61 |
+
/**
|
62 |
+
* XML paths that control some features of postcode check
|
63 |
+
*/
|
64 |
+
const XML_PATH_POSTCODE_CHECK_MAX_ATTEMPTS = 'postnl/cif_address/postcode_check_max_attempts';
|
65 |
+
const XML_PATH_POSTCODE_CHECK_TIMEOUT = 'postnl/cif_address/postcode_check_timeout';
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Xpath to OSC street fields sort order.
|
69 |
+
*/
|
70 |
+
const XPATH_STREET_FIELD_SORT_ORDER = 'onestepcheckout/sortordering_fields/street';
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Log filename to log all cendris exceptions
|
74 |
+
*/
|
75 |
+
const CENDRIS_EXCEPTION_LOG_FILE = 'TIG_PostNL_Cendris_Exception.log';
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Log filename to log cendris calls
|
79 |
+
*/
|
80 |
+
const CENDRIS_DEBUG_LOG_FILE = 'TIG_PostNL_Cendris_Debug.log';
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @var null|string|int
|
84 |
+
*/
|
85 |
+
protected $_oscStreetFieldSortOrder = null;
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Gets the current street field sort order for OSC.
|
89 |
+
*
|
90 |
+
* @return int|string
|
91 |
+
*/
|
92 |
+
public function getOscStreetFieldSortOrder()
|
93 |
+
{
|
94 |
+
if ($this->_oscStreetFieldSortOrder !== null) {
|
95 |
+
return $this->_oscStreetFieldSortOrder;
|
96 |
+
}
|
97 |
+
|
98 |
+
$storeId = Mage::app()->getStore()->getId();
|
99 |
+
$streetFieldOrder = Mage::getStoreConfig(self::XPATH_STREET_FIELD_SORT_ORDER, $storeId);
|
100 |
+
|
101 |
+
$this->_oscStreetFieldSortOrder = $streetFieldOrder;
|
102 |
+
return $streetFieldOrder;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Checks whether the given store uses split address lines.
|
107 |
+
*
|
108 |
+
* @param int|null $storeId
|
109 |
+
*
|
110 |
+
* @return boolean
|
111 |
+
*/
|
112 |
+
public function useSplitStreet($storeId = null)
|
113 |
+
{
|
114 |
+
if (is_null($storeId)) {
|
115 |
+
$storeId = Mage::app()->getStore()->getId();
|
116 |
+
}
|
117 |
+
|
118 |
+
if ($this->isPostcodeCheckEnabled($storeId)) {
|
119 |
+
return true;
|
120 |
+
}
|
121 |
+
|
122 |
+
$useSplitStreet = Mage::getStoreConfigFlag(self::XML_PATH_SPLIT_STREET, $storeId);
|
123 |
+
return $useSplitStreet;
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Checks whether the given store uses split housenumber values.
|
128 |
+
*
|
129 |
+
* @param int|null $storeId
|
130 |
+
*
|
131 |
+
* @return boolean
|
132 |
+
*/
|
133 |
+
public function useSplitHousenumber($storeId = null)
|
134 |
+
{
|
135 |
+
if (is_null($storeId)) {
|
136 |
+
$storeId = Mage::app()->getStore()->getId();
|
137 |
+
}
|
138 |
+
|
139 |
+
if ($this->isPostcodeCheckEnabled($storeId)) {
|
140 |
+
return true;
|
141 |
+
}
|
142 |
+
|
143 |
+
$useSplitStreet = Mage::getStoreConfigFlag(self::XML_PATH_SPLIT_HOUSENUMBER, $storeId);
|
144 |
+
return $useSplitStreet;
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Gets the address field number used for the streetname field.
|
149 |
+
*
|
150 |
+
* @param int|null $storeId
|
151 |
+
*
|
152 |
+
* @return int
|
153 |
+
*/
|
154 |
+
public function getStreetnameField($storeId = null)
|
155 |
+
{
|
156 |
+
if (is_null($storeId)) {
|
157 |
+
$storeId = Mage::app()->getStore()->getId();
|
158 |
+
}
|
159 |
+
|
160 |
+
if ($this->isPostcodeCheckEnabled($storeId)) {
|
161 |
+
return 1;
|
162 |
+
}
|
163 |
+
|
164 |
+
$streetnameField = (int) Mage::getStoreConfig(self::XML_PATH_STREETNAME_FIELD, $storeId);
|
165 |
+
return $streetnameField;
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* Gets the address field number used for the housenumber field.
|
170 |
+
*
|
171 |
+
* @param int|null $storeId
|
172 |
+
*
|
173 |
+
* @return int
|
174 |
+
*/
|
175 |
+
|
176 |
+
public function getHousenumberField($storeId = null)
|
177 |
+
{
|
178 |
+
if (is_null($storeId)) {
|
179 |
+
$storeId = Mage::app()->getStore()->getId();
|
180 |
+
}
|
181 |
+
|
182 |
+
if ($this->isPostcodeCheckEnabled($storeId)) {
|
183 |
+
return 2;
|
184 |
+
}
|
185 |
+
|
186 |
+
$housenumberField = (int) Mage::getStoreConfig(self::XML_PATH_HOUSENUMBER_FIELD, $storeId);
|
187 |
+
return $housenumberField;
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Gets the address field number used for the housenumber extension field.
|
192 |
+
*
|
193 |
+
* @param int|null $storeId
|
194 |
+
*
|
195 |
+
* @return int
|
196 |
+
*/
|
197 |
+
public function getHousenumberExtensionField($storeId = null)
|
198 |
+
{
|
199 |
+
if (is_null($storeId)) {
|
200 |
+
$storeId = Mage::app()->getStore()->getId();
|
201 |
+
}
|
202 |
+
|
203 |
+
if ($this->isPostcodeCheckEnabled($storeId)) {
|
204 |
+
return 3;
|
205 |
+
}
|
206 |
+
|
207 |
+
$housenumberExtensionField = (int) Mage::getStoreConfig(self::XML_PATH_HOUSENUMBER_EXTENSION_FIELD, $storeId);
|
208 |
+
return $housenumberExtensionField;
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Gets the number of seconds before postcode check times out.
|
213 |
+
*
|
214 |
+
* @param int|null $storeId
|
215 |
+
*
|
216 |
+
* @return int
|
217 |
+
*/
|
218 |
+
public function getPostcodeCheckTimeoutDelay($storeId = null)
|
219 |
+
{
|
220 |
+
if (is_null($storeId)) {
|
221 |
+
$storeId = Mage::app()->getStore()->getId();
|
222 |
+
}
|
223 |
+
|
224 |
+
$timeout = (int) Mage::getStoreConfig(self::XML_PATH_POSTCODE_CHECK_TIMEOUT, $storeId);
|
225 |
+
return $timeout;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Gets the number of times a customer may attempt to enter their postcode and housenumber before postcode check disables
|
230 |
+
* itself.
|
231 |
+
*
|
232 |
+
* @param int|null $storeId
|
233 |
+
*
|
234 |
+
* @return string|int
|
235 |
+
*/
|
236 |
+
public function getPostcodeCheckMaxAttempts($storeId = null)
|
237 |
+
{
|
238 |
+
if (is_null($storeId)) {
|
239 |
+
$storeId = Mage::app()->getStore()->getId();
|
240 |
+
}
|
241 |
+
|
242 |
+
$maxAttempts = (int) Mage::getStoreConfig(self::XML_PATH_POSTCODE_CHECK_MAX_ATTEMPTS, $storeId);
|
243 |
+
if (!$maxAttempts) {
|
244 |
+
return 'false';
|
245 |
+
}
|
246 |
+
|
247 |
+
return $maxAttempts;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Wrapper for the getAttributeValidationClass method to prevent errors in Magento 1.6.
|
252 |
+
*
|
253 |
+
* @param $attribute
|
254 |
+
*
|
255 |
+
* @return string
|
256 |
+
*/
|
257 |
+
public function getAttributeValidationClass($attribute)
|
258 |
+
{
|
259 |
+
$addressHelper = Mage::helper('customer/address');
|
260 |
+
if (is_callable(array($addressHelper, 'getAttributeValidationClass'))) {
|
261 |
+
return $addressHelper->getAttributeValidationClass($attribute);
|
262 |
+
}
|
263 |
+
|
264 |
+
return '';
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Check if the Postcode Check is active.
|
269 |
+
*
|
270 |
+
* @param int|null $storeId
|
271 |
+
*
|
272 |
+
* @return boolean
|
273 |
+
*/
|
274 |
+
public function isPostcodeCheckActive($storeId = null)
|
275 |
+
{
|
276 |
+
if (is_null($storeId)) {
|
277 |
+
$storeId = Mage::app()->getStore()->getId();
|
278 |
+
}
|
279 |
+
|
280 |
+
$usePostcodeCheck = Mage::getStoreConfigFlag(self::XML_PATH_USE_POSTCODE_CHECK, $storeId);
|
281 |
+
return $usePostcodeCheck;
|
282 |
+
}
|
283 |
+
|
284 |
+
/**
|
285 |
+
* Checks if the Postcode Check is enabled and ready for use.
|
286 |
+
*
|
287 |
+
* @param int|null $storeId
|
288 |
+
*
|
289 |
+
* @param bool $environment
|
290 |
+
*
|
291 |
+
* @return boolean
|
292 |
+
*/
|
293 |
+
public function isPostcodeCheckEnabled($storeId = null, $environment = false)
|
294 |
+
{
|
295 |
+
if (is_null($storeId)) {
|
296 |
+
$storeId = Mage::app()->getStore()->getId();
|
297 |
+
}
|
298 |
+
|
299 |
+
$isPostnlEnabled = $this->isEnabled($storeId, false);
|
300 |
+
if (!$isPostnlEnabled) {
|
301 |
+
return false;
|
302 |
+
}
|
303 |
+
|
304 |
+
$isPostcodeCheckActive = $this->isPostcodeCheckActive($storeId);
|
305 |
+
if (!$isPostcodeCheckActive) {
|
306 |
+
return false;
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Check to see if the postcode check functionality is allowed for the specified environment.
|
311 |
+
*/
|
312 |
+
$environmentAllowed = false;
|
313 |
+
switch ($environment) {
|
314 |
+
case 'checkout':
|
315 |
+
$environmentAllowed = Mage::getStoreConfigFlag(self::XML_PATH_POSTCODE_CHECK_IN_CHECKOUT, $storeId);
|
316 |
+
break;
|
317 |
+
case 'addressbook':
|
318 |
+
$environmentAllowed = Mage::getStoreConfigFlag(self::XML_PATH_POSTCODE_CHECK_IN_ADDRESSBOOK, $storeId);
|
319 |
+
break;
|
320 |
+
case false:
|
321 |
+
$environmentAllowed = true;
|
322 |
+
break;
|
323 |
+
//no default
|
324 |
+
}
|
325 |
+
|
326 |
+
return $environmentAllowed;
|
327 |
+
}
|
328 |
+
|
329 |
+
/**
|
330 |
+
* Logs a cendris request and response for debug purposes.
|
331 |
+
*
|
332 |
+
* @param Zend_Soap_Client $client
|
333 |
+
*
|
334 |
+
* @return TIG_PostNL_Helper_Webservices
|
335 |
+
*
|
336 |
+
* @see Mage::log()
|
337 |
+
*/
|
338 |
+
public function logCendrisCall(Zend_Soap_Client $client)
|
339 |
+
{
|
340 |
+
if (!$this->isLoggingEnabled()) {
|
341 |
+
return $this;
|
342 |
+
}
|
343 |
+
|
344 |
+
$this->createLogDir();
|
345 |
+
|
346 |
+
$requestXml = $this->formatXml($client->getLastRequest());
|
347 |
+
$responseXML = $this->formatXml($client->getLastResponse());
|
348 |
+
|
349 |
+
$logMessage = 'Request sent:'
|
350 |
+
. PHP_EOL
|
351 |
+
. $requestXml
|
352 |
+
. PHP_EOL
|
353 |
+
. 'Response received:'
|
354 |
+
. PHP_EOL
|
355 |
+
. $responseXML;
|
356 |
+
|
357 |
+
$file = self::POSTNL_LOG_DIRECTORY . DS . self::CENDRIS_DEBUG_LOG_FILE;
|
358 |
+
$this->log($logMessage, Zend_Log::DEBUG, $file);
|
359 |
+
|
360 |
+
return $this;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Logs a cendris exception in the database and/or a log file
|
365 |
+
*
|
366 |
+
* @param Mage_Core_Exception|TIG_PostNL_Exception|SoapFault $exception
|
367 |
+
* @param Zend_Soap_Client|boolean $client
|
368 |
+
*
|
369 |
+
* @return TIG_PostNL_Helper_Webservices
|
370 |
+
*
|
371 |
+
* @see Mage::logException()
|
372 |
+
*/
|
373 |
+
public function logCendrisException($exception, $client = false)
|
374 |
+
{
|
375 |
+
if (!$this->isExceptionLoggingEnabled()) {
|
376 |
+
return $this;
|
377 |
+
}
|
378 |
+
|
379 |
+
$logMessage = PHP_EOL . $exception->__toString();
|
380 |
+
|
381 |
+
if ($client && $client instanceof Zend_Soap_Client) {
|
382 |
+
$requestXml = $this->formatXml($client->getLastRequest());
|
383 |
+
$responseXML = $this->formatXml($client->getLastResponse());
|
384 |
+
|
385 |
+
$logMessage .= PHP_EOL
|
386 |
+
. 'Request sent:'
|
387 |
+
. PHP_EOL
|
388 |
+
. $requestXml
|
389 |
+
. PHP_EOL
|
390 |
+
. 'Response received:'
|
391 |
+
. PHP_EOL
|
392 |
+
. $responseXML;
|
393 |
+
}
|
394 |
+
|
395 |
+
$file = self::POSTNL_LOG_DIRECTORY . DS . self::CENDRIS_EXCEPTION_LOG_FILE;
|
396 |
+
$this->log($logMessage, Zend_Log::ERR, $file, false, true);
|
397 |
+
|
398 |
+
return $this;
|
399 |
+
}
|
400 |
+
}
|
@@ -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,13 +42,13 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
42 |
Â
* Shipping carrier code used by PostNL
|
43 |
Â
*/
|
44 |
Â
const POSTNL_CARRIER = 'postnl';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* PostNL shipping methods
|
48 |
Â
*/
|
49 |
Â
const POSTNL_FLATRATE_METHOD = 'flatrate';
|
50 |
Â
const POSTNL_TABLERATE_METHOD = 'tablerate';
|
51 |
-
|
52 |
Â
/**
|
53 |
Â
* Localised track and trace base URL's
|
54 |
Â
*/
|
@@ -57,15 +57,15 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
57 |
Â
const POSTNL_TRACK_AND_TRACE_DE_BASE_URL = 'http://parcels-de.tntpost.com/de/mytrackandtrace/TrackAndTrace.aspx?';
|
58 |
Â
const POSTNL_TRACK_AND_TRACE_FR_BASE_URL = 'http://parcels-fr.tntpost.com/fr/mytrackandtrace/TrackAndTrace.aspx?';
|
59 |
Â
const POSTNL_TRACK_AND_TRACE_INT_BASE_URL = 'http://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?';
|
60 |
-
|
61 |
Â
/**
|
62 |
Â
* XML path to rate type setting
|
63 |
Â
*/
|
64 |
Â
const XML_PATH_RATE_TYPE = 'carriers/postnl/rate_type';
|
65 |
-
|
66 |
Â
/**
|
67 |
Â
* Array of possible PostNL shipping methods
|
68 |
-
*
|
69 |
Â
* @var array
|
70 |
Â
*/
|
71 |
Â
protected $_postnlShippingMethods = array(
|
@@ -73,10 +73,10 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
73 |
Â
'postnl_flatrate',
|
74 |
Â
'postnl_tablerate',
|
75 |
Â
);
|
76 |
-
|
77 |
Â
/**
|
78 |
Â
* Gets an array of possible PostNL shipping methods
|
79 |
-
*
|
80 |
Â
* @return array
|
81 |
Â
*/
|
82 |
Â
public function getPostnlShippingMethods()
|
@@ -84,24 +84,27 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
84 |
Â
$shippingMethods = $this->_postnlShippingMethods;
|
85 |
Â
return $shippingMethods;
|
86 |
Â
}
|
87 |
-
|
88 |
Â
/**
|
89 |
Â
* Alias for getCurrentPostnlShippingMethod()
|
90 |
-
*
|
91 |
Â
* @return string
|
92 |
-
*
|
93 |
Â
* @see TIG_PostNL_Helper_Carrier::getCurrentPostnlShippingMethod()
|
94 |
-
*
|
95 |
Â
* @deprecated
|
96 |
Â
*/
|
97 |
Â
public function getPostnlShippingMethod()
|
98 |
Â
{
|
99 |
Â
return $this->getCurrentPostnlShippingMethod();
|
100 |
Â
}
|
101 |
-
|
102 |
Â
/**
|
103 |
Â
* Returns the PostNL shipping method
|
104 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
105 |
Â
* @return string
|
106 |
Â
*/
|
107 |
Â
public function getCurrentPostnlShippingMethod($storeId = null)
|
@@ -109,13 +112,13 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
109 |
Â
if (Mage::registry('current_postnl_shipping_method') !== null) {
|
110 |
Â
return Mage::registry('current_postnl_shipping_method');
|
111 |
Â
}
|
112 |
-
|
113 |
Â
if (is_null($storeId)) {
|
114 |
Â
$storeId = Mage::app()->getStore()->getId();
|
115 |
Â
}
|
116 |
-
|
117 |
Â
$rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, $storeId);
|
118 |
-
|
119 |
Â
$carrier = self::POSTNL_CARRIER;
|
120 |
Â
switch ($rateType) {
|
121 |
Â
case 'flat':
|
@@ -130,19 +133,19 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
130 |
Â
'POSTNL-0036'
|
131 |
Â
);
|
132 |
Â
}
|
133 |
-
|
134 |
Â
Mage::register('current_postnl_shipping_method', $shippingMethod);
|
135 |
Â
return $shippingMethod;
|
136 |
Â
}
|
137 |
-
|
138 |
Â
/**
|
139 |
Â
* Constructs a PostNL track & trace url based on a barcode and the destination of the package (country and zipcode)
|
140 |
-
*
|
141 |
Â
* @param string $barcode
|
142 |
Â
* @param mixed $destination An array or object containing the shipment's destination data
|
143 |
Â
* @param boolean | string $lang
|
144 |
Â
* @param boolean $forceNl
|
145 |
-
*
|
146 |
Â
* @return string
|
147 |
Â
*/
|
148 |
Â
public function getBarcodeUrl($barcode, $destination = false, $lang = false, $forceNl = false)
|
@@ -153,17 +156,17 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
153 |
Â
$countryCode = $destination['countryCode'];
|
154 |
Â
$postcode = $destination['postcode'];
|
155 |
Â
}
|
156 |
-
|
157 |
Â
if (is_object($destination) && $destination instanceof Varien_Object) {
|
158 |
Â
$countryCode = $destination->getCountry();
|
159 |
Â
$postcode = $destination->getPostcode();
|
160 |
Â
}
|
161 |
-
|
162 |
Â
/**
|
163 |
Â
* Get the diutch track & trace URL for dutch shipments or for the admin
|
164 |
Â
*/
|
165 |
Â
if ($forceNl
|
166 |
-
|| (!empty($countryCode)
|
167 |
Â
&& $countryCode == 'NL'
|
168 |
Â
)
|
169 |
Â
) {
|
@@ -172,22 +175,22 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
172 |
Â
/**
|
173 |
Â
* For dutch shipments add the postcode. For international shipments add an 'international' flag
|
174 |
Â
*/
|
175 |
-
if (!empty($postcode)
|
176 |
-
&& !empty($countryCode)
|
177 |
Â
&& $countryCode == 'NL'
|
178 |
Â
) {
|
179 |
Â
$barcodeUrl .= '&p=' . $postcode;
|
180 |
Â
} else {
|
181 |
Â
$barcodeUrl .= '&i=true';
|
182 |
Â
}
|
183 |
-
|
184 |
Â
return $barcodeUrl;
|
185 |
Â
}
|
186 |
-
|
187 |
Â
/**
|
188 |
Â
* Get localized track & trace URLs for UK, DE and FR shipments
|
189 |
Â
*/
|
190 |
-
if (isset($countryCode)
|
191 |
Â
&& ($countryCode == 'UK'
|
192 |
Â
|| $countryCode == 'GB'
|
193 |
Â
)
|
@@ -196,43 +199,43 @@ class TIG_PostNL_Helper_Carrier extends TIG_PostNL_Helper_Data
|
|
196 |
Â
. '&B=' . $barcode
|
197 |
Â
. '&D=GB'
|
198 |
Â
. '&lang=en';
|
199 |
-
|
200 |
Â
return $barcodeUrl;
|
201 |
Â
}
|
202 |
-
|
203 |
Â
if (isset($countryCode) && $countryCode == 'DE') {
|
204 |
Â
$barcodeUrl = self::POSTNL_TRACK_AND_TRACE_DE_BASE_URL
|
205 |
Â
. '&B=' . $barcode
|
206 |
Â
. '&D=DE'
|
207 |
Â
. '&lang=de';
|
208 |
-
|
209 |
Â
return $barcodeUrl;
|
210 |
Â
}
|
211 |
-
|
212 |
Â
if (isset($countryCode) && $countryCode == 'FR') {
|
213 |
Â
$barcodeUrl = self::POSTNL_TRACK_AND_TRACE_FR_BASE_URL
|
214 |
Â
. '&B=' . $barcode
|
215 |
Â
. '&D=FR'
|
216 |
Â
. '&lang=fr';
|
217 |
-
|
218 |
Â
return $barcodeUrl;
|
219 |
Â
}
|
220 |
-
|
221 |
Â
/**
|
222 |
Â
* Get a general track & trace URL for all other destinations
|
223 |
Â
*/
|
224 |
Â
$barcodeUrl = self::POSTNL_TRACK_AND_TRACE_INT_BASE_URL
|
225 |
Â
. '&B=' . $barcode
|
226 |
Â
. '&I=true';
|
227 |
-
|
228 |
Â
if ($lang) {
|
229 |
Â
$barcodeUrl .= '&lang=' . strtolower($lang);
|
230 |
Â
}
|
231 |
-
|
232 |
Â
if ($countryCode) {
|
233 |
Â
$barcodeUrl .= '&D=' . $countryCode;
|
234 |
Â
}
|
235 |
-
|
236 |
Â
return $barcodeUrl;
|
237 |
Â
}
|
238 |
Â
}
|
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 |
Â
* Shipping carrier code used by PostNL
|
43 |
Â
*/
|
44 |
Â
const POSTNL_CARRIER = 'postnl';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* PostNL shipping methods
|
48 |
Â
*/
|
49 |
Â
const POSTNL_FLATRATE_METHOD = 'flatrate';
|
50 |
Â
const POSTNL_TABLERATE_METHOD = 'tablerate';
|
51 |
+
|
52 |
Â
/**
|
53 |
Â
* Localised track and trace base URL's
|
54 |
Â
*/
|
57 |
Â
const POSTNL_TRACK_AND_TRACE_DE_BASE_URL = 'http://parcels-de.tntpost.com/de/mytrackandtrace/TrackAndTrace.aspx?';
|
58 |
Â
const POSTNL_TRACK_AND_TRACE_FR_BASE_URL = 'http://parcels-fr.tntpost.com/fr/mytrackandtrace/TrackAndTrace.aspx?';
|
59 |
Â
const POSTNL_TRACK_AND_TRACE_INT_BASE_URL = 'http://www.postnlpakketten.nl/klantenservice/tracktrace/basicsearch.aspx?';
|
60 |
+
|
61 |
Â
/**
|
62 |
Â
* XML path to rate type setting
|
63 |
Â
*/
|
64 |
Â
const XML_PATH_RATE_TYPE = 'carriers/postnl/rate_type';
|
65 |
+
|
66 |
Â
/**
|
67 |
Â
* Array of possible PostNL shipping methods
|
68 |
+
*
|
69 |
Â
* @var array
|
70 |
Â
*/
|
71 |
Â
protected $_postnlShippingMethods = array(
|
73 |
Â
'postnl_flatrate',
|
74 |
Â
'postnl_tablerate',
|
75 |
Â
);
|
76 |
+
|
77 |
Â
/**
|
78 |
Â
* Gets an array of possible PostNL shipping methods
|
79 |
+
*
|
80 |
Â
* @return array
|
81 |
Â
*/
|
82 |
Â
public function getPostnlShippingMethods()
|
84 |
Â
$shippingMethods = $this->_postnlShippingMethods;
|
85 |
Â
return $shippingMethods;
|
86 |
Â
}
|
87 |
+
|
88 |
Â
/**
|
89 |
Â
* Alias for getCurrentPostnlShippingMethod()
|
90 |
+
*
|
91 |
Â
* @return string
|
92 |
+
*
|
93 |
Â
* @see TIG_PostNL_Helper_Carrier::getCurrentPostnlShippingMethod()
|
94 |
+
*
|
95 |
Â
* @deprecated
|
96 |
Â
*/
|
97 |
Â
public function getPostnlShippingMethod()
|
98 |
Â
{
|
99 |
Â
return $this->getCurrentPostnlShippingMethod();
|
100 |
Â
}
|
101 |
+
|
102 |
Â
/**
|
103 |
Â
* Returns the PostNL shipping method
|
104 |
+
*
|
105 |
+
* @param null $storeId
|
106 |
+
*
|
107 |
+
* @throws TIG_PostNL_Exception
|
108 |
Â
* @return string
|
109 |
Â
*/
|
110 |
Â
public function getCurrentPostnlShippingMethod($storeId = null)
|
112 |
Â
if (Mage::registry('current_postnl_shipping_method') !== null) {
|
113 |
Â
return Mage::registry('current_postnl_shipping_method');
|
114 |
Â
}
|
115 |
+
|
116 |
Â
if (is_null($storeId)) {
|
117 |
Â
$storeId = Mage::app()->getStore()->getId();
|
118 |
Â
}
|
119 |
+
|
120 |
Â
$rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, $storeId);
|
121 |
+
|
122 |
Â
$carrier = self::POSTNL_CARRIER;
|
123 |
Â
switch ($rateType) {
|
124 |
Â
case 'flat':
|
133 |
Â
'POSTNL-0036'
|
134 |
Â
);
|
135 |
Â
}
|
136 |
+
|
137 |
Â
Mage::register('current_postnl_shipping_method', $shippingMethod);
|
138 |
Â
return $shippingMethod;
|
139 |
Â
}
|
140 |
+
|
141 |
Â
/**
|
142 |
Â
* Constructs a PostNL track & trace url based on a barcode and the destination of the package (country and zipcode)
|
143 |
+
*
|
144 |
Â
* @param string $barcode
|
145 |
Â
* @param mixed $destination An array or object containing the shipment's destination data
|
146 |
Â
* @param boolean | string $lang
|
147 |
Â
* @param boolean $forceNl
|
148 |
+
*
|
149 |
Â
* @return string
|
150 |
Â
*/
|
151 |
Â
public function getBarcodeUrl($barcode, $destination = false, $lang = false, $forceNl = false)
|
156 |
Â
$countryCode = $destination['countryCode'];
|
157 |
Â
$postcode = $destination['postcode'];
|
158 |
Â
}
|
159 |
+
|
160 |
Â
if (is_object($destination) && $destination instanceof Varien_Object) {
|
161 |
Â
$countryCode = $destination->getCountry();
|
162 |
Â
$postcode = $destination->getPostcode();
|
163 |
Â
}
|
164 |
+
|
165 |
Â
/**
|
166 |
Â
* Get the diutch track & trace URL for dutch shipments or for the admin
|
167 |
Â
*/
|
168 |
Â
if ($forceNl
|
169 |
+
|| (!empty($countryCode)
|
170 |
Â
&& $countryCode == 'NL'
|
171 |
Â
)
|
172 |
Â
) {
|
175 |
Â
/**
|
176 |
Â
* For dutch shipments add the postcode. For international shipments add an 'international' flag
|
177 |
Â
*/
|
178 |
+
if (!empty($postcode)
|
179 |
+
&& !empty($countryCode)
|
180 |
Â
&& $countryCode == 'NL'
|
181 |
Â
) {
|
182 |
Â
$barcodeUrl .= '&p=' . $postcode;
|
183 |
Â
} else {
|
184 |
Â
$barcodeUrl .= '&i=true';
|
185 |
Â
}
|
186 |
+
|
187 |
Â
return $barcodeUrl;
|
188 |
Â
}
|
189 |
+
|
190 |
Â
/**
|
191 |
Â
* Get localized track & trace URLs for UK, DE and FR shipments
|
192 |
Â
*/
|
193 |
+
if (isset($countryCode)
|
194 |
Â
&& ($countryCode == 'UK'
|
195 |
Â
|| $countryCode == 'GB'
|
196 |
Â
)
|
199 |
Â
. '&B=' . $barcode
|
200 |
Â
. '&D=GB'
|
201 |
Â
. '&lang=en';
|
202 |
+
|
203 |
Â
return $barcodeUrl;
|
204 |
Â
}
|
205 |
+
|
206 |
Â
if (isset($countryCode) && $countryCode == 'DE') {
|
207 |
Â
$barcodeUrl = self::POSTNL_TRACK_AND_TRACE_DE_BASE_URL
|
208 |
Â
. '&B=' . $barcode
|
209 |
Â
. '&D=DE'
|
210 |
Â
. '&lang=de';
|
211 |
+
|
212 |
Â
return $barcodeUrl;
|
213 |
Â
}
|
214 |
+
|
215 |
Â
if (isset($countryCode) && $countryCode == 'FR') {
|
216 |
Â
$barcodeUrl = self::POSTNL_TRACK_AND_TRACE_FR_BASE_URL
|
217 |
Â
. '&B=' . $barcode
|
218 |
Â
. '&D=FR'
|
219 |
Â
. '&lang=fr';
|
220 |
+
|
221 |
Â
return $barcodeUrl;
|
222 |
Â
}
|
223 |
+
|
224 |
Â
/**
|
225 |
Â
* Get a general track & trace URL for all other destinations
|
226 |
Â
*/
|
227 |
Â
$barcodeUrl = self::POSTNL_TRACK_AND_TRACE_INT_BASE_URL
|
228 |
Â
. '&B=' . $barcode
|
229 |
Â
. '&I=true';
|
230 |
+
|
231 |
Â
if ($lang) {
|
232 |
Â
$barcodeUrl .= '&lang=' . strtolower($lang);
|
233 |
Â
}
|
234 |
+
|
235 |
Â
if ($countryCode) {
|
236 |
Â
$barcodeUrl .= '&D=' . $countryCode;
|
237 |
Â
}
|
238 |
+
|
239 |
Â
return $barcodeUrl;
|
240 |
Â
}
|
241 |
Â
}
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
@@ -42,7 +42,6 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
42 |
Â
* XML path to checkout on/off switch
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_CHECKOUT_ACTIVE = 'postnl/checkout/active';
|
45 |
-
const XML_PATH_USE_CHECKOUT = 'postnl/cif/use_checkout';
|
46 |
Â
|
47 |
Â
/**
|
48 |
Â
* XML path to all PostNL Checkout payment methods.
|
@@ -53,7 +52,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
53 |
Â
/**
|
54 |
Â
* XML path to test / live mode setting
|
55 |
Â
*/
|
56 |
-
const XML_PATH_TEST_MODE = 'postnl/
|
57 |
Â
|
58 |
Â
/**
|
59 |
Â
* XML path for config options used to determine whether or not PostNL Checkout is available
|
@@ -99,8 +98,8 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
99 |
Â
);
|
100 |
Â
|
101 |
Â
/**
|
102 |
-
* Array containing conversions between PostNL CHeckout payment option fields and those used by Magento payment
|
103 |
-
* This array should be extended as time goes on in order to support as many payment methods as possible.
|
104 |
Â
*
|
105 |
Â
* @var array
|
106 |
Â
*/
|
@@ -153,7 +152,8 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
153 |
Â
}
|
154 |
Â
|
155 |
Â
/**
|
156 |
-
* Returns a conversion array used to convert PostNL Checkout payment method fields to those used by Magento payment
|
Â
|
|
157 |
Â
*
|
158 |
Â
* @return array
|
159 |
Â
*/
|
@@ -166,8 +166,8 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
166 |
Â
$conversionObject = new Varien_Object($conversionArray);
|
167 |
Â
|
168 |
Â
/**
|
169 |
-
* You can observe this event in order to add (or modify) conversion options. This prevents you from having to
|
170 |
-
* this helper if you want to change this functionality.
|
171 |
Â
*/
|
172 |
Â
Mage::dispatchEvent(
|
173 |
Â
'postnl_checkout_option_conversion_before',
|
@@ -176,7 +176,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
176 |
Â
)
|
177 |
Â
);
|
178 |
Â
|
179 |
-
return $conversionObject->getConversionArray()
|
180 |
Â
}
|
181 |
Â
|
182 |
Â
/**
|
@@ -251,7 +251,9 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
251 |
Â
$errors = array(
|
252 |
Â
array(
|
253 |
Â
'code' => 'POSTNL-0106',
|
254 |
-
'message' => $this->__(
|
Â
|
|
Â
|
|
255 |
Â
)
|
256 |
Â
);
|
257 |
Â
Mage::register('postnl_enabled_checkout_errors', $errors);
|
@@ -271,7 +273,9 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
271 |
Â
$errors = array(
|
272 |
Â
array(
|
273 |
Â
'code' => 'POSTNL-0101',
|
274 |
-
'message' => $this->__(
|
Â
|
|
Â
|
|
275 |
Â
)
|
276 |
Â
);
|
277 |
Â
Mage::register('postnl_enabled_checkout_errors', $errors);
|
@@ -344,6 +348,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
344 |
Â
}
|
345 |
Â
|
346 |
Â
$totalWeight = 0;
|
Â
|
|
347 |
Â
foreach ($quoteItems as $item) {
|
348 |
Â
$totalWeight += $item->getRowWeight();
|
349 |
Â
}
|
@@ -382,33 +387,6 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
382 |
Â
return false;
|
383 |
Â
}
|
384 |
Â
|
385 |
-
/**
|
386 |
-
* Check if the module is set to test mode
|
387 |
-
*
|
388 |
-
* @return boolean
|
389 |
-
*/
|
390 |
-
public function isTestMode($storeId = false)
|
391 |
-
{
|
392 |
-
if (Mage::registry('postnl_checkout_test_mode') !== null) {
|
393 |
-
return Mage::registry('postnl_checkout_test_mode');
|
394 |
-
}
|
395 |
-
|
396 |
-
if ($storeId === false) {
|
397 |
-
$storeId = Mage::app()->getStore()->getId();
|
398 |
-
}
|
399 |
-
|
400 |
-
$testModeAllowed = $this->isTestModeAllowed();
|
401 |
-
if (!$testModeAllowed) {
|
402 |
-
Mage::register('postnl_checkout_test_mode', false);
|
403 |
-
return false;
|
404 |
-
}
|
405 |
-
|
406 |
-
$testMode = Mage::getStoreConfigFlag(self::XML_PATH_TEST_MODE, $storeId);
|
407 |
-
|
408 |
-
Mage::register('postnl_checkout_test_mode', $testMode);
|
409 |
-
return $testMode;
|
410 |
-
}
|
411 |
-
|
412 |
Â
/**
|
413 |
Â
* Checks if PostNL Checkout is active
|
414 |
Â
*
|
@@ -422,9 +400,7 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
422 |
Â
$storeId = Mage::app()->getStore()->getId();
|
423 |
Â
}
|
424 |
Â
|
425 |
-
|
426 |
-
|
427 |
-
if (!$useCheckout) {
|
428 |
Â
return false;
|
429 |
Â
}
|
430 |
Â
|
@@ -493,7 +469,9 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
493 |
Â
$errors = array();
|
494 |
Â
|
495 |
Â
/**
|
496 |
-
* Get the system > config fields for this section
|
Â
|
|
Â
|
|
497 |
Â
*/
|
498 |
Â
$configFields = Mage::getSingleton('adminhtml/config');
|
499 |
Â
$sections = $configFields->getSections('postnl');
|
@@ -506,22 +484,29 @@ class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
|
506 |
Â
foreach ($requiredFields as $requiredField) {
|
507 |
Â
$value = Mage::getStoreConfig($requiredField, $storeId);
|
508 |
Â
|
509 |
-
if ($value
|
510 |
-
|
511 |
-
|
512 |
-
$group = $fieldParts[1];
|
513 |
Â
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
Â
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
Â
|
523 |
-
|
524 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
525 |
Â
}
|
526 |
Â
|
527 |
Â
/**
|
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 |
Â
class TIG_PostNL_Helper_Checkout extends TIG_PostNL_Helper_Data
|
42 |
Â
* XML path to checkout on/off switch
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_CHECKOUT_ACTIVE = 'postnl/checkout/active';
|
Â
|
|
45 |
Â
|
46 |
Â
/**
|
47 |
Â
* XML path to all PostNL Checkout payment methods.
|
52 |
Â
/**
|
53 |
Â
* XML path to test / live mode setting
|
54 |
Â
*/
|
55 |
+
const XML_PATH_TEST_MODE = 'postnl/cif/mode';
|
56 |
Â
|
57 |
Â
/**
|
58 |
Â
* XML path for config options used to determine whether or not PostNL Checkout is available
|
98 |
Â
);
|
99 |
Â
|
100 |
Â
/**
|
101 |
+
* Array containing conversions between PostNL CHeckout payment option fields and those used by Magento payment
|
102 |
+
* methods. This array should be extended as time goes on in order to support as many payment methods as possible.
|
103 |
Â
*
|
104 |
Â
* @var array
|
105 |
Â
*/
|
152 |
Â
}
|
153 |
Â
|
154 |
Â
/**
|
155 |
+
* Returns a conversion array used to convert PostNL Checkout payment method fields to those used by Magento payment
|
156 |
+
* methods.
|
157 |
Â
*
|
158 |
Â
* @return array
|
159 |
Â
*/
|
166 |
Â
$conversionObject = new Varien_Object($conversionArray);
|
167 |
Â
|
168 |
Â
/**
|
169 |
+
* You can observe this event in order to add (or modify) conversion options. This prevents you from having to
|
170 |
+
* overload this helper if you want to change this functionality.
|
171 |
Â
*/
|
172 |
Â
Mage::dispatchEvent(
|
173 |
Â
'postnl_checkout_option_conversion_before',
|
176 |
Â
)
|
177 |
Â
);
|
178 |
Â
|
179 |
+
return $conversionObject->getConversionArray();
|
180 |
Â
}
|
181 |
Â
|
182 |
Â
/**
|
251 |
Â
$errors = array(
|
252 |
Â
array(
|
253 |
Â
'code' => 'POSTNL-0106',
|
254 |
+
'message' => $this->__(
|
255 |
+
'No standard product options are enabled. At least 1 option must be active.'
|
256 |
+
),
|
257 |
Â
)
|
258 |
Â
);
|
259 |
Â
Mage::register('postnl_enabled_checkout_errors', $errors);
|
273 |
Â
$errors = array(
|
274 |
Â
array(
|
275 |
Â
'code' => 'POSTNL-0101',
|
276 |
+
'message' => $this->__(
|
277 |
+
"The quote's total weight is below the miniumum required to use PostNL Checkout."
|
278 |
+
),
|
279 |
Â
)
|
280 |
Â
);
|
281 |
Â
Mage::register('postnl_enabled_checkout_errors', $errors);
|
348 |
Â
}
|
349 |
Â
|
350 |
Â
$totalWeight = 0;
|
351 |
+
/** @var Mage_Sales_Model_Quote_Item $item */
|
352 |
Â
foreach ($quoteItems as $item) {
|
353 |
Â
$totalWeight += $item->getRowWeight();
|
354 |
Â
}
|
387 |
Â
return false;
|
388 |
Â
}
|
389 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
390 |
Â
/**
|
391 |
Â
* Checks if PostNL Checkout is active
|
392 |
Â
*
|
400 |
Â
$storeId = Mage::app()->getStore()->getId();
|
401 |
Â
}
|
402 |
Â
|
403 |
+
if (!parent::isActive()) {
|
Â
|
|
Â
|
|
404 |
Â
return false;
|
405 |
Â
}
|
406 |
Â
|
469 |
Â
$errors = array();
|
470 |
Â
|
471 |
Â
/**
|
472 |
+
* Get the system > config fields for this section.
|
473 |
+
*
|
474 |
+
* @var Varien_Simplexml_Element $section
|
475 |
Â
*/
|
476 |
Â
$configFields = Mage::getSingleton('adminhtml/config');
|
477 |
Â
$sections = $configFields->getSections('postnl');
|
484 |
Â
foreach ($requiredFields as $requiredField) {
|
485 |
Â
$value = Mage::getStoreConfig($requiredField, $storeId);
|
486 |
Â
|
487 |
+
if ($value !== null && $value !== '') {
|
488 |
+
continue;
|
489 |
+
}
|
Â
|
|
490 |
Â
|
491 |
+
$fieldParts = explode('/', $requiredField);
|
492 |
+
$field = $fieldParts[2];
|
493 |
+
$group = $fieldParts[1];
|
494 |
Â
|
495 |
+
/**
|
496 |
+
* @var Varien_Simplexml_Element $sectionGroup
|
497 |
+
*/
|
498 |
+
$sectionGroup = $section->groups->$group;
|
499 |
Â
|
500 |
+
$label = (string) $sectionGroup->fields->$field->label;
|
501 |
+
$groupLabel = (string) $sectionGroup->label;
|
502 |
+
$groupName = $sectionGroup->getName();
|
503 |
+
|
504 |
+
$errors[] = array(
|
505 |
+
'code' => 'POSTNL-0034',
|
506 |
+
'message' => $this->__('%s > %s is required.', $this->__($groupLabel), $this->__($label)),
|
507 |
+
);
|
508 |
+
|
509 |
+
$this->saveConfigState(array('postnl_' . $groupName => 1));
|
510 |
Â
}
|
511 |
Â
|
512 |
Â
/**
|
@@ -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.
|
@@ -33,10 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
|
40 |
Â
/**
|
41 |
Â
* Helper class for CIF operations
|
42 |
Â
*/
|
@@ -46,44 +46,56 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
46 |
Â
* Log filename to log all CIF exceptions
|
47 |
Â
*/
|
48 |
Â
const CIF_EXCEPTION_LOG_FILE = 'TIG_PostNL_CIF_Exception.log';
|
49 |
-
|
50 |
Â
/**
|
51 |
Â
* Log filename to log CIF calls
|
52 |
Â
*/
|
53 |
Â
const CIF_DEBUG_LOG_FILE = 'TIG_PostNL_CIF_Debug.log';
|
54 |
-
|
55 |
Â
/**
|
56 |
Â
* available barcode types
|
57 |
Â
*/
|
58 |
Â
const DUTCH_BARCODE_TYPE = 'NL';
|
59 |
Â
const EU_BARCODE_TYPE = 'EU';
|
60 |
Â
const GLOBAL_BARCODE_TYPE = 'GLOBAL';
|
61 |
-
|
62 |
Â
/**
|
63 |
Â
* XML path to infinite label printiong setting
|
64 |
Â
*/
|
65 |
Â
const XML_PATH_INFINITE_LABEL_PRINTING = 'postnl/advanced/infinite_label_printing';
|
66 |
-
|
67 |
Â
/**
|
68 |
Â
* XML path to weight unit used
|
69 |
Â
*/
|
70 |
Â
const XML_PATH_WEIGHT_UNIT = 'postnl/cif_labels_and_confirming/weight_unit';
|
71 |
-
|
72 |
Â
/**
|
73 |
Â
* XML path to weight per parcel config setting
|
74 |
Â
*/
|
75 |
-
const XML_PATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
|
76 |
-
|
77 |
Â
/**
|
78 |
Â
* XML paths to default product options settings
|
79 |
Â
*/
|
80 |
-
const XML_PATH_DEFAULT_STANDARD_PRODUCT_OPTION
|
81 |
-
const XML_PATH_DEFAULT_EU_PRODUCT_OPTION
|
82 |
-
const XML_PATH_DEFAULT_GLOBAL_PRODUCT_OPTION
|
83 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
84 |
Â
/**
|
85 |
Â
* Array of countries to which PostNL ships using EPS. Other EU countries are shipped to using GlobalPack
|
86 |
-
*
|
87 |
Â
* @var array
|
88 |
Â
*/
|
89 |
Â
protected $_euCountries = array(
|
@@ -111,24 +123,24 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
111 |
Â
'CZ',
|
112 |
Â
'SE',
|
113 |
Â
);
|
114 |
-
|
115 |
Â
/**
|
116 |
Â
* Array of country-restricted product codes
|
117 |
-
*
|
118 |
Â
* Array is constructed as follows:
|
119 |
Â
* <restricted code> => array(<allowed country>, <allowed country>, <allowed country>,...)
|
120 |
-
*
|
121 |
Â
* @var array
|
122 |
Â
*/
|
123 |
Â
protected $_countryRestrictedProductCodes = array(
|
124 |
Â
'4955' => array(
|
125 |
-
|
126 |
-
|
127 |
Â
);
|
128 |
-
|
129 |
Â
/**
|
130 |
-
* Array of supported shipment types
|
131 |
-
*
|
132 |
Â
* @var array
|
133 |
Â
*/
|
134 |
Â
protected $_shipmentTypes = array(
|
@@ -138,10 +150,23 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
138 |
Â
'commercial_sample' => 'Commercial Sample',
|
139 |
Â
'returned_goods' => 'Returned Goods',
|
140 |
Â
);
|
141 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
142 |
Â
/**
|
143 |
Â
* Array of possible shipping phases
|
144 |
-
*
|
145 |
Â
* @var array
|
146 |
Â
*/
|
147 |
Â
protected $_shippingPhases = array(
|
@@ -151,30 +176,55 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
151 |
Â
'4' => 'Delivered',
|
152 |
Â
'99' => 'Shipment not found',
|
153 |
Â
);
|
154 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
155 |
Â
/**
|
156 |
Â
* Get an array of EU countries
|
157 |
-
*
|
158 |
Â
* @return array
|
159 |
Â
*/
|
160 |
Â
public function getEuCountries()
|
161 |
Â
{
|
162 |
Â
return $this->_euCountries;
|
163 |
Â
}
|
164 |
-
|
165 |
Â
/**
|
166 |
Â
* Gets an array of country-restricted product codes
|
167 |
-
*
|
168 |
Â
* @return array
|
169 |
Â
*/
|
170 |
Â
public function getCountryRestrictedProductCodes()
|
171 |
Â
{
|
172 |
Â
return $this->_countryRestrictedProductCodes;
|
173 |
Â
}
|
174 |
-
|
175 |
Â
/**
|
176 |
Â
* Get an array of standard product codes
|
177 |
-
*
|
Â
|
|
Â
|
|
178 |
Â
* @return array
|
179 |
Â
*/
|
180 |
Â
public function getStandardProductCodes($storeId = false)
|
@@ -182,10 +232,25 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
182 |
Â
$standardProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
183 |
Â
return $standardProductCodes->getAvailableOptions($storeId, true);
|
184 |
Â
}
|
185 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
186 |
Â
/**
|
187 |
Â
* Get an array of pakjegemak product codes
|
188 |
-
*
|
Â
|
|
Â
|
|
189 |
Â
* @return array
|
190 |
Â
*/
|
191 |
Â
public function getPakjeGemakProductCodes($storeId = false)
|
@@ -193,10 +258,40 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
193 |
Â
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
194 |
Â
return $pakjeGemakProductCodes->getAvailableOptions($storeId, true);
|
195 |
Â
}
|
196 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
197 |
Â
/**
|
198 |
Â
* Get an array of eu product codes
|
199 |
-
*
|
Â
|
|
Â
|
|
200 |
Â
* @return array
|
201 |
Â
*/
|
202 |
Â
public function getEuProductCodes($storeId = false)
|
@@ -204,10 +299,12 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
204 |
Â
$euProductCodes = Mage::getSingleton('postnl_core/system_config_source_euProductOptions');
|
205 |
Â
return $euProductCodes->getAvailableOptions($storeId, true);
|
206 |
Â
}
|
207 |
-
|
208 |
Â
/**
|
209 |
Â
* Get an array of global product codes
|
210 |
-
*
|
Â
|
|
Â
|
|
211 |
Â
* @return array
|
212 |
Â
*/
|
213 |
Â
public function getGlobalProductCodes($storeId = false)
|
@@ -215,56 +312,86 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
215 |
Â
$globalProductCodes = Mage::getSingleton('postnl_core/system_config_source_globalProductOptions');
|
216 |
Â
return $globalProductCodes->getAvailableOptions($storeId, true);
|
217 |
Â
}
|
218 |
-
|
219 |
Â
/**
|
220 |
Â
* Get an array of possible shipment types
|
221 |
-
*
|
222 |
Â
* @return array
|
223 |
Â
*/
|
224 |
Â
public function getShipmentTypes()
|
225 |
Â
{
|
226 |
Â
return $this->_shipmentTypes;
|
227 |
Â
}
|
228 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
229 |
Â
/**
|
230 |
Â
* Get an array of possible shipping phases
|
231 |
-
*
|
232 |
Â
* @return array
|
233 |
Â
*/
|
234 |
Â
public function getShippingPhases()
|
235 |
Â
{
|
236 |
Â
$shippingPhases = $this->_shippingPhases;
|
237 |
-
foreach ($shippingPhases as
|
238 |
Â
$value = $this->__($value);
|
239 |
Â
}
|
240 |
-
|
241 |
Â
return $shippingPhases;
|
242 |
Â
}
|
243 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
244 |
Â
/**
|
245 |
Â
* Checks if infinite label printing is enabled in the module configuration.
|
246 |
-
*
|
247 |
Â
* @return boolean
|
248 |
Â
*/
|
249 |
Â
public function allowInfinitePrinting()
|
250 |
Â
{
|
251 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
252 |
Â
$enabled = Mage::getStoreConfigFlag(self::XML_PATH_INFINITE_LABEL_PRINTING, $storeId);
|
253 |
-
|
254 |
Â
return $enabled;
|
255 |
Â
}
|
256 |
Â
/**
|
257 |
Â
* Checks which barcode type is applicable for this shipment
|
258 |
-
*
|
259 |
Â
* Possible return values:
|
260 |
Â
* - NL
|
261 |
Â
* - EU
|
262 |
Â
* - GLOBAL
|
263 |
-
*
|
264 |
-
* @
|
265 |
-
*
|
266 |
Â
* @return string | TIG_PostNL_Helper_Cif
|
267 |
-
*
|
268 |
Â
* @throws TIG_PostNL_Exception
|
269 |
Â
*/
|
270 |
Â
public function getBarcodeTypeForShipment($shipment)
|
@@ -273,30 +400,28 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
273 |
Â
$barcodeType = self::DUTCH_BARCODE_TYPE;
|
274 |
Â
return $barcodeType;
|
275 |
Â
}
|
276 |
-
|
277 |
Â
if ($shipment->isEuShipment()) {
|
278 |
Â
$barcodeType = self::EU_BARCODE_TYPE;
|
279 |
Â
return $barcodeType;
|
280 |
Â
}
|
281 |
-
|
282 |
Â
if ($shipment->isGlobalShipment()) {
|
283 |
Â
$barcodeType = self::GLOBAL_BARCODE_TYPE;
|
284 |
Â
return $barcodeType;
|
285 |
Â
}
|
286 |
-
|
287 |
Â
throw new TIG_PostNL_Exception(
|
288 |
Â
$this->__('Unable to get valid barcodetype for postnl shipment id #%s', $shipment->getId()),
|
289 |
Â
'POSTNL-0029'
|
290 |
Â
);
|
291 |
-
|
292 |
-
return $this;
|
293 |
Â
}
|
294 |
-
|
295 |
Â
/**
|
296 |
Â
* Get a list of available product options for a specified shipment
|
297 |
-
*
|
298 |
Â
* @param Mage_Sales_Model_Order_Shipment $shipment
|
299 |
-
*
|
300 |
Â
* @return array | null
|
301 |
Â
*/
|
302 |
Â
public function getProductOptionsForShipment($shipment)
|
@@ -307,305 +432,357 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
307 |
Â
if ($this->isPakjeGemakShipment($shipment)) {
|
308 |
Â
$options = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions')
|
309 |
Â
->getAvailableOptions();
|
310 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
311 |
Â
return $options;
|
312 |
Â
}
|
313 |
-
|
314 |
Â
/**
|
315 |
Â
* Dutch product options
|
316 |
Â
*/
|
317 |
Â
if ($this->isDutchShipment($shipment)) {
|
318 |
Â
$options = Mage::getModel('postnl_core/system_config_source_standardProductOptions')
|
319 |
Â
->getAvailableOptions();
|
320 |
-
|
321 |
Â
return $options;
|
322 |
Â
}
|
323 |
-
|
324 |
Â
/**
|
325 |
Â
* EU product options
|
326 |
Â
*/
|
327 |
Â
if ($this->isEuShipment($shipment)) {
|
328 |
Â
$options = Mage::getModel('postnl_core/system_config_source_euProductOptions')
|
329 |
Â
->getAvailableOptions();
|
330 |
-
|
331 |
Â
return $options;
|
332 |
Â
}
|
333 |
-
|
334 |
Â
/**
|
335 |
Â
* Global product options
|
336 |
Â
*/
|
337 |
Â
if ($this->isGlobalShipment($shipment)) {
|
338 |
Â
$options = Mage::getModel('postnl_core/system_config_source_globalProductOptions')
|
339 |
Â
->getAvailableOptions();
|
340 |
-
|
341 |
Â
return $options;
|
342 |
Â
}
|
343 |
-
|
344 |
Â
return null;
|
345 |
Â
}
|
346 |
-
|
347 |
Â
/**
|
348 |
Â
* Check if a given shipment is PakjeGemak
|
349 |
-
*
|
350 |
-
* @param TIG_PostNL_Model_Core_Shipment
|
351 |
-
*
|
352 |
Â
* @return boolean
|
353 |
-
*
|
354 |
-
* @see TIG_PostNL_Model_Core_Shipment->
|
355 |
Â
*/
|
356 |
Â
public function isPakjeGemakShipment($shipment)
|
357 |
Â
{
|
358 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
359 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
Â
|
|
Â
|
|
Â
|
|
360 |
Â
return $shipment->isPakjeGemakShipment();
|
361 |
Â
}
|
362 |
-
|
363 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
364 |
Â
$tempPostnlShipment->setShipment($shipment);
|
365 |
-
|
366 |
Â
return $tempPostnlShipment->isPakjeGemakShipment();
|
367 |
Â
}
|
368 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
369 |
Â
/**
|
370 |
Â
* Check if a given shipment is dutch
|
371 |
-
*
|
372 |
Â
* @param TIG_PostNL_Model_Core_Shipment | Mage_Sales_Model_Order_Shipment $shipment
|
373 |
-
*
|
374 |
Â
* @return boolean
|
375 |
-
*
|
376 |
Â
* @see TIG_PostNL_Model_Core_Shipment->isDutchSHipment();
|
377 |
Â
*/
|
378 |
Â
public function isDutchShipment($shipment)
|
379 |
Â
{
|
380 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
381 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
Â
|
|
Â
|
|
Â
|
|
382 |
Â
return $shipment->isDutchShipment();
|
383 |
Â
}
|
384 |
-
|
385 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
386 |
Â
$tempPostnlShipment->setShipment($shipment);
|
387 |
-
|
388 |
Â
return $tempPostnlShipment->isDutchShipment();
|
389 |
Â
}
|
390 |
-
|
391 |
Â
/**
|
392 |
Â
* Check if a given shipment has an EU destination
|
393 |
-
*
|
394 |
Â
* @param TIG_PostNL_Model_Core_Shipment | Mage_Sales_Model_Order_Shipment $shipment
|
395 |
-
*
|
396 |
Â
* @return boolean
|
397 |
-
*
|
398 |
-
* @see TIG_PostNL_Model_Core_Shipment->
|
399 |
Â
*/
|
400 |
Â
public function isEuShipment($shipment)
|
401 |
Â
{
|
402 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
403 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
Â
|
|
Â
|
|
Â
|
|
404 |
Â
return $shipment->isEuShipment();
|
405 |
Â
}
|
406 |
-
|
407 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
408 |
Â
$tempPostnlShipment->setShipment($shipment);
|
409 |
-
|
410 |
Â
return $tempPostnlShipment->isEuShipment();
|
411 |
Â
}
|
412 |
-
|
413 |
Â
/**
|
414 |
Â
* Check if a given shipment has a global destination
|
415 |
-
*
|
416 |
-
* @param TIG_PostNL_Model_Core_Shipment
|
417 |
-
*
|
418 |
Â
* @return boolean
|
419 |
-
*
|
420 |
-
* @see TIG_PostNL_Model_Core_Shipment->
|
421 |
Â
*/
|
422 |
Â
public function isGlobalShipment($shipment)
|
423 |
Â
{
|
424 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
425 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
Â
|
|
Â
|
|
Â
|
|
426 |
Â
return $shipment->isGlobalShipment();
|
427 |
Â
}
|
428 |
-
|
429 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
430 |
Â
$tempPostnlShipment->setShipment($shipment);
|
431 |
-
|
432 |
Â
return $tempPostnlShipment->isGlobalShipment();
|
433 |
Â
}
|
434 |
-
|
435 |
Â
/**
|
436 |
Â
* Gets the default product option for a shipment
|
437 |
-
*
|
438 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
439 |
-
*
|
440 |
Â
* @return string
|
441 |
Â
*/
|
442 |
Â
public function getDefaultProductOptionForShipment($shipment)
|
443 |
Â
{
|
444 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
445 |
Â
$postnlShipment->setShipment($shipment);
|
446 |
-
|
447 |
Â
$productOption = $postnlShipment->getDefaultProductCode();
|
448 |
-
|
449 |
Â
return $productOption;
|
450 |
Â
}
|
451 |
-
|
452 |
Â
/**
|
453 |
Â
* Get an array of all default product options. This is a simple method to quickly get a list of default options based on
|
454 |
Â
* the current storeview.
|
455 |
-
*
|
456 |
Â
* This does not take into account the possible use of an alternative default for dutch shipments. For that you need to use
|
457 |
Â
* TIG_PostNL_Model_Core_Shipment::getDefaultProductCode() which is more precise.
|
458 |
-
*
|
459 |
Â
* @return array
|
460 |
Â
*/
|
461 |
Â
public function getDefaultProductOptions()
|
462 |
Â
{
|
463 |
Â
$storeId = Mage::app()->getStore()->getId();
|
464 |
-
|
465 |
-
$defaultDutchOption
|
466 |
-
$defaultEuOption
|
467 |
-
$defaultGlobalOption
|
468 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
469 |
Â
$defaultOptions = array(
|
470 |
-
'dutch'
|
471 |
-
'eu'
|
472 |
-
'global'
|
Â
|
|
473 |
Â
);
|
474 |
-
|
475 |
Â
return $defaultOptions;
|
476 |
Â
}
|
477 |
-
|
478 |
Â
/**
|
479 |
Â
* Gets the number of parcels in this shipment based on it's weight
|
480 |
-
*
|
481 |
Â
* @param Mage_Sales_Model_Order_Shipment $shipment
|
482 |
-
*
|
483 |
Â
* @return int
|
484 |
Â
*/
|
485 |
Â
public function getParcelCount($shipment)
|
486 |
Â
{
|
487 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
488 |
Â
$postnlShipment->setShipment($shipment);
|
489 |
-
|
490 |
Â
/**
|
491 |
Â
* Only NL shipments support multi-colli shipments
|
492 |
Â
*/
|
493 |
Â
if (!$postnlShipment->isDutchShipment()) {
|
494 |
Â
return 1;
|
495 |
Â
}
|
496 |
-
|
497 |
Â
/**
|
498 |
Â
* get this shipment's total weight
|
499 |
Â
*/
|
500 |
Â
$weight = $postnlShipment->getTotalWeight(true);
|
501 |
-
|
502 |
Â
/**
|
503 |
Â
* get the weight per parcel
|
504 |
Â
*/
|
505 |
Â
$weightPerParcel = Mage::getStoreConfig(self::XML_PATH_WEIGHT_PER_PARCEL, $shipment->getStoreId());
|
506 |
Â
$weightPerParcel = $this->standardizeWeight($weightPerParcel, $shipment->getStoreId());
|
507 |
-
|
508 |
Â
/**
|
509 |
Â
* calculate the number of parcels needed to ship the total weight of this shipment
|
510 |
Â
*/
|
511 |
Â
$parcelCount = ceil($weight / $weightPerParcel);
|
512 |
-
|
513 |
Â
return $parcelCount;
|
514 |
Â
}
|
515 |
-
|
516 |
Â
/**
|
517 |
Â
* Checks if a given postnl shipment exists using Zend_Validate_Db_RecordExists.
|
518 |
-
*
|
519 |
Â
* @param string $shipmentId
|
520 |
-
*
|
521 |
Â
* @return boolean
|
522 |
-
*
|
523 |
Â
* @see Zend_Validate_Db_RecordExists
|
524 |
-
*
|
525 |
Â
* @link http://framework.zend.com/manual/1.12/en/zend.validate.set.html#zend.validate.Db
|
526 |
Â
*/
|
527 |
Â
public function postnlShipmentExists($shipmentId)
|
528 |
Â
{
|
529 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
530 |
Â
$readAdapter = $coreResource->getConnection('core_read');
|
531 |
-
|
532 |
-
$validator =
|
533 |
Â
array(
|
534 |
Â
'table' => $coreResource->getTableName('postnl_core/shipment'),
|
535 |
Â
'field' => 'shipment_id',
|
536 |
Â
'adapter' => $readAdapter,
|
537 |
Â
)
|
538 |
Â
);
|
539 |
-
|
540 |
Â
$postnlShipmentExists = $validator->isValid($shipmentId);
|
541 |
-
|
542 |
Â
if ($postnlShipmentExists) {
|
543 |
Â
return true;
|
544 |
Â
}
|
545 |
-
|
546 |
Â
return false;
|
547 |
Â
}
|
548 |
-
|
549 |
Â
/**
|
550 |
Â
* Checks if a given barcode exists using Zend_Validate_Db_RecordExists.
|
551 |
-
*
|
552 |
Â
* @param string $barcode
|
553 |
-
*
|
554 |
Â
* @return boolean
|
555 |
-
*
|
556 |
Â
* @see Zend_Validate_Db_RecordExists
|
557 |
-
*
|
558 |
Â
* @link http://framework.zend.com/manual/1.12/en/zend.validate.set.html#zend.validate.Db
|
559 |
Â
*/
|
560 |
Â
public function barcodeExists($barcode)
|
561 |
Â
{
|
562 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
563 |
Â
$readAdapter = $coreResource->getConnection('core_read');
|
564 |
-
|
565 |
Â
/**
|
566 |
Â
* Check if the barcode exists as a main barcode
|
567 |
Â
*/
|
568 |
-
$validator =
|
569 |
Â
array(
|
570 |
Â
'table' => $coreResource->getTableName('postnl_core/shipment'),
|
571 |
Â
'field' => 'main_barcode',
|
572 |
Â
'adapter' => $readAdapter,
|
573 |
Â
)
|
574 |
Â
);
|
575 |
-
|
576 |
Â
$barcodeExists = $validator->isValid($barcode);
|
577 |
-
|
578 |
Â
if ($barcodeExists) {
|
579 |
Â
return true;
|
580 |
Â
}
|
581 |
-
|
582 |
Â
/**
|
583 |
Â
* Check if the barcode exists as a secondary barcode
|
584 |
Â
*/
|
585 |
-
$validator =
|
586 |
Â
array(
|
587 |
Â
'table' => $coreResource->getTableName('postnl_core/shipment_barcode'),
|
588 |
Â
'field' => 'barcode',
|
589 |
Â
'adapter' => $readAdapter,
|
590 |
Â
)
|
591 |
Â
);
|
592 |
-
|
593 |
Â
$barcodeExists = $validator->isValid($barcode);
|
594 |
-
|
595 |
Â
if ($barcodeExists) {
|
596 |
Â
return true;
|
597 |
Â
}
|
598 |
-
|
599 |
Â
return false;
|
600 |
Â
}
|
601 |
-
|
602 |
Â
/**
|
603 |
Â
* Convert a given weight to kilogram or gram
|
604 |
-
*
|
605 |
Â
* @param float $weight The weight to be converted
|
606 |
Â
* @param int | null $storeId Store Id used to determine the weight unit that was originally used
|
607 |
Â
* @param boolean $toGram Optional parameter to convert to gram instead of kilogram
|
608 |
-
*
|
609 |
Â
* @return float
|
610 |
Â
*/
|
611 |
Â
public function standardizeWeight($weight, $storeId = null, $toGram = false)
|
@@ -613,10 +790,9 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
613 |
Â
if (is_null($storeId)) {
|
614 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
615 |
Â
}
|
616 |
-
|
617 |
Â
$unitUsed = Mage::getStoreConfig(self::XML_PATH_WEIGHT_UNIT, $storeId);
|
618 |
-
|
619 |
-
$returnWeight = $weight;
|
620 |
Â
switch ($unitUsed) {
|
621 |
Â
case 'tonne':
|
622 |
Â
$returnWeight = $weight * 1000;
|
@@ -657,9 +833,6 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
657 |
Â
case 'pound':
|
658 |
Â
$returnWeight = $weight * 0.45359237;
|
659 |
Â
break;
|
660 |
-
case 'shortton':
|
661 |
-
$returnWeight = $weight * 907;
|
662 |
-
break;
|
663 |
Â
case 'ounce':
|
664 |
Â
$returnWeight = $weight * 0.028349523125;
|
665 |
Â
break;
|
@@ -690,75 +863,283 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
690 |
Â
if ($toGram === true) {
|
691 |
Â
$returnWeight *= 1000;
|
692 |
Â
}
|
693 |
-
|
694 |
Â
return $returnWeight;
|
695 |
Â
}
|
696 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
697 |
Â
/**
|
698 |
Â
* Logs a CIF request and response for debug purposes.
|
699 |
-
*
|
700 |
Â
* N.B.: if file logging is enabled, the log will be forced
|
701 |
-
*
|
702 |
-
* @param
|
703 |
-
*
|
704 |
Â
* @return TIG_PostNL_Helper_Cif
|
705 |
-
*
|
706 |
Â
* @see Mage::log()
|
707 |
-
*
|
708 |
-
* @todo add additional debug options
|
709 |
-
*
|
710 |
Â
*/
|
711 |
Â
public function logCifCall($client)
|
712 |
Â
{
|
713 |
-
if (!$this->isLoggingEnabled()) {
|
714 |
Â
return $this;
|
715 |
Â
}
|
716 |
-
|
717 |
Â
$requestXml = $this->formatXml($client->getLastRequest());
|
718 |
Â
$responseXML = $this->formatXml($client->getLastResponse());
|
719 |
-
|
720 |
Â
$logMessage = "Request sent:\n"
|
721 |
Â
. $requestXml
|
722 |
Â
. "\nResponse received:\n"
|
723 |
Â
. $responseXML;
|
724 |
-
|
725 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::CIF_DEBUG_LOG_FILE;
|
726 |
Â
$this->log($logMessage, Zend_Log::DEBUG, $file);
|
727 |
-
|
728 |
Â
return $this;
|
729 |
Â
}
|
730 |
-
|
731 |
Â
/**
|
732 |
-
* Logs a CIF exception in the database and/or a log file
|
733 |
-
*
|
734 |
-
* N.B.: if file logging is enabled, the log will be forced
|
735 |
-
*
|
736 |
Â
* @param Mage_Core_Exception | TIG_PostNL_Model_Core_Cif_Exception $exception
|
737 |
-
*
|
738 |
Â
* @return TIG_PostNL_Helper_Cif
|
739 |
-
*
|
740 |
Â
* @see Mage::logException()
|
741 |
-
*
|
742 |
-
* @todo add additional debug options
|
743 |
Â
*/
|
744 |
Â
public function logCifException($exception)
|
745 |
Â
{
|
746 |
Â
if (!$this->isExceptionLoggingEnabled()) {
|
747 |
Â
return $this;
|
748 |
Â
}
|
749 |
-
|
750 |
Â
if ($exception instanceof TIG_PostNL_Model_Core_Cif_Exception) {
|
751 |
Â
$requestXml = $this->formatXml($exception->getRequestXml());
|
752 |
Â
$responseXML = $this->formatXml($exception->getResponseXml());
|
753 |
-
|
754 |
Â
$logMessage = '';
|
755 |
-
|
756 |
Â
$errorNumbers = $exception->getErrorNumbers();
|
757 |
Â
if (!empty($errorNumbers)) {
|
758 |
Â
$errorNumbers = implode(', ', $errorNumbers);
|
759 |
Â
$logMessage .= "Error numbers received: {$errorNumbers}\n";
|
760 |
Â
}
|
761 |
-
|
762 |
Â
$logMessage .= "<<< REQUEST SENT >>>\n"
|
763 |
Â
. $requestXml
|
764 |
Â
. "\n<<< RESPONSE RECEIVED >>>\n"
|
@@ -766,10 +1147,10 @@ class TIG_PostNL_Helper_Cif extends TIG_PostNL_Helper_Data
|
|
766 |
Â
} else {
|
767 |
Â
$logMessage = "\n" . $exception->__toString();
|
768 |
Â
}
|
769 |
-
|
770 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::CIF_EXCEPTION_LOG_FILE;
|
771 |
Â
$this->log($logMessage, Zend_Log::ERR, $file, false, true);
|
772 |
-
|
773 |
Â
return $this;
|
774 |
Â
}
|
775 |
Â
}
|
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.
|
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 |
Â
* Helper class for CIF operations
|
42 |
Â
*/
|
46 |
Â
* Log filename to log all CIF exceptions
|
47 |
Â
*/
|
48 |
Â
const CIF_EXCEPTION_LOG_FILE = 'TIG_PostNL_CIF_Exception.log';
|
49 |
+
|
50 |
Â
/**
|
51 |
Â
* Log filename to log CIF calls
|
52 |
Â
*/
|
53 |
Â
const CIF_DEBUG_LOG_FILE = 'TIG_PostNL_CIF_Debug.log';
|
54 |
+
|
55 |
Â
/**
|
56 |
Â
* available barcode types
|
57 |
Â
*/
|
58 |
Â
const DUTCH_BARCODE_TYPE = 'NL';
|
59 |
Â
const EU_BARCODE_TYPE = 'EU';
|
60 |
Â
const GLOBAL_BARCODE_TYPE = 'GLOBAL';
|
61 |
+
|
62 |
Â
/**
|
63 |
Â
* XML path to infinite label printiong setting
|
64 |
Â
*/
|
65 |
Â
const XML_PATH_INFINITE_LABEL_PRINTING = 'postnl/advanced/infinite_label_printing';
|
66 |
+
|
67 |
Â
/**
|
68 |
Â
* XML path to weight unit used
|
69 |
Â
*/
|
70 |
Â
const XML_PATH_WEIGHT_UNIT = 'postnl/cif_labels_and_confirming/weight_unit';
|
71 |
+
|
72 |
Â
/**
|
73 |
Â
* XML path to weight per parcel config setting
|
74 |
Â
*/
|
75 |
+
const XML_PATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
|
76 |
+
|
77 |
Â
/**
|
78 |
Â
* XML paths to default product options settings
|
79 |
Â
*/
|
80 |
+
const XML_PATH_DEFAULT_STANDARD_PRODUCT_OPTION = 'postnl/cif_product_options/default_product_option';
|
81 |
+
const XML_PATH_DEFAULT_EU_PRODUCT_OPTION = 'postnl/cif_product_options/default_eu_product_option';
|
82 |
+
const XML_PATH_DEFAULT_GLOBAL_PRODUCT_OPTION = 'postnl/cif_product_options/default_global_product_option';
|
83 |
+
const XML_PATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION = 'postnl/cif_product_options/default_pakketautomaat_product_option';
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Regular expression used to split streetname from housenumber. This regex works well for dutch addresses, but may
|
87 |
+
* fail for international addresses. We strongly recommend using split address lines instead.
|
88 |
+
*/
|
89 |
+
const SPLIT_STREET_REGEX = '#\A(.*?)\s+(\d+[a-zA-Z]{0,1}\s{0,1}[-]{1}\s{0,1}\d*[a-zA-Z]{0,1}|\d+[a-zA-Z-]{0,1}\d*[a-zA-Z]{0,1})#';
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Regular expression used to split housenumber and housenumber extension
|
93 |
+
*/
|
94 |
+
const SPLIT_HOUSENUMBER_REGEX = '#^([\d]+)(.*)#s';
|
95 |
+
|
96 |
Â
/**
|
97 |
Â
* Array of countries to which PostNL ships using EPS. Other EU countries are shipped to using GlobalPack
|
98 |
+
*
|
99 |
Â
* @var array
|
100 |
Â
*/
|
101 |
Â
protected $_euCountries = array(
|
123 |
Â
'CZ',
|
124 |
Â
'SE',
|
125 |
Â
);
|
126 |
+
|
127 |
Â
/**
|
128 |
Â
* Array of country-restricted product codes
|
129 |
+
*
|
130 |
Â
* Array is constructed as follows:
|
131 |
Â
* <restricted code> => array(<allowed country>, <allowed country>, <allowed country>,...)
|
132 |
+
*
|
133 |
Â
* @var array
|
134 |
Â
*/
|
135 |
Â
protected $_countryRestrictedProductCodes = array(
|
136 |
Â
'4955' => array(
|
137 |
+
'BE',
|
138 |
+
),
|
139 |
Â
);
|
140 |
+
|
141 |
Â
/**
|
142 |
+
* Array of supported shipment types.
|
143 |
+
*
|
144 |
Â
* @var array
|
145 |
Â
*/
|
146 |
Â
protected $_shipmentTypes = array(
|
150 |
Â
'commercial_sample' => 'Commercial Sample',
|
151 |
Â
'returned_goods' => 'Returned Goods',
|
152 |
Â
);
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Array of supported shipment types and their numeric counterparts.
|
156 |
+
*
|
157 |
+
* @var array
|
158 |
+
*/
|
159 |
+
protected $_numericShipmentTypes = array(
|
160 |
+
'Gift' => 0,
|
161 |
+
'Documents' => 1,
|
162 |
+
'Commercial Goods' => 2,
|
163 |
+
'Commercial Sample' => 3,
|
164 |
+
'Returned Goods' => 4,
|
165 |
+
);
|
166 |
+
|
167 |
Â
/**
|
168 |
Â
* Array of possible shipping phases
|
169 |
+
*
|
170 |
Â
* @var array
|
171 |
Â
*/
|
172 |
Â
protected $_shippingPhases = array(
|
176 |
Â
'4' => 'Delivered',
|
177 |
Â
'99' => 'Shipment not found',
|
178 |
Â
);
|
179 |
+
|
180 |
+
/**
|
181 |
+
* Array of countires which may send their full street data in a single line,
|
182 |
+
* rather than having to split them into streetname, housenr and extension parts
|
183 |
+
*
|
184 |
+
* @var array
|
185 |
+
*/
|
186 |
+
protected $_allowedFullStreetCountries = array(
|
187 |
+
'NL',
|
188 |
+
'BE'
|
189 |
+
);
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Array of EPS product codes and their combi-label counterparts.
|
193 |
+
*
|
194 |
+
* @var array
|
195 |
+
*/
|
196 |
+
protected $_combiLabelProductCodes = array(
|
197 |
+
'4940' => '4950',
|
198 |
+
'4924' => '4954',
|
199 |
+
'4946' => '4955',
|
200 |
+
'4944' => '4952',
|
201 |
+
);
|
202 |
+
|
203 |
Â
/**
|
204 |
Â
* Get an array of EU countries
|
205 |
+
*
|
206 |
Â
* @return array
|
207 |
Â
*/
|
208 |
Â
public function getEuCountries()
|
209 |
Â
{
|
210 |
Â
return $this->_euCountries;
|
211 |
Â
}
|
212 |
+
|
213 |
Â
/**
|
214 |
Â
* Gets an array of country-restricted product codes
|
215 |
+
*
|
216 |
Â
* @return array
|
217 |
Â
*/
|
218 |
Â
public function getCountryRestrictedProductCodes()
|
219 |
Â
{
|
220 |
Â
return $this->_countryRestrictedProductCodes;
|
221 |
Â
}
|
222 |
+
|
223 |
Â
/**
|
224 |
Â
* Get an array of standard product codes
|
225 |
+
*
|
226 |
+
* @param bool $storeId
|
227 |
+
*
|
228 |
Â
* @return array
|
229 |
Â
*/
|
230 |
Â
public function getStandardProductCodes($storeId = false)
|
232 |
Â
$standardProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
233 |
Â
return $standardProductCodes->getAvailableOptions($storeId, true);
|
234 |
Â
}
|
235 |
+
|
236 |
+
/**
|
237 |
+
* Get an array of evening delivery product codes.
|
238 |
+
*
|
239 |
+
* @param bool $storeId
|
240 |
+
*
|
241 |
+
* @return array
|
242 |
+
*/
|
243 |
+
public function getAvondProductCodes($storeId = false)
|
244 |
+
{
|
245 |
+
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_standardProductOptions');
|
246 |
+
return $pakjeGemakProductCodes->getAvailableAvondOptions($storeId, true);
|
247 |
+
}
|
248 |
+
|
249 |
Â
/**
|
250 |
Â
* Get an array of pakjegemak product codes
|
251 |
+
*
|
252 |
+
* @param bool $storeId
|
253 |
+
*
|
254 |
Â
* @return array
|
255 |
Â
*/
|
256 |
Â
public function getPakjeGemakProductCodes($storeId = false)
|
258 |
Â
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
259 |
Â
return $pakjeGemakProductCodes->getAvailableOptions($storeId, true);
|
260 |
Â
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Get an array of PakjeGemak Express product codes.
|
264 |
+
*
|
265 |
+
* @param bool $storeId
|
266 |
+
*
|
267 |
+
* @return array
|
268 |
+
*/
|
269 |
+
public function getPgeProductCodes($storeId = false)
|
270 |
+
{
|
271 |
+
$pakjeGemakProductCodes = Mage::getSingleton('postnl_core/system_config_source_pakjeGemakProductOptions');
|
272 |
+
return $pakjeGemakProductCodes->getAvailablePgeOptions($storeId, true);
|
273 |
+
}
|
274 |
+
|
275 |
+
/**
|
276 |
+
* Get an array of pakketautomaat product codes
|
277 |
+
*
|
278 |
+
* @param bool $storeId
|
279 |
+
*
|
280 |
+
* @return array
|
281 |
+
*/
|
282 |
+
public function getPakketautomaatProductCodes($storeId = false)
|
283 |
+
{
|
284 |
+
$pakketautomaatProductCodes = Mage::getSingleton(
|
285 |
+
'postnl_core/system_config_source_pakketautomaatProductOptions'
|
286 |
+
);
|
287 |
+
return $pakketautomaatProductCodes->getAvailableOptions($storeId, true);
|
288 |
+
}
|
289 |
+
|
290 |
Â
/**
|
291 |
Â
* Get an array of eu product codes
|
292 |
+
*
|
293 |
+
* @param bool $storeId
|
294 |
+
*
|
295 |
Â
* @return array
|
296 |
Â
*/
|
297 |
Â
public function getEuProductCodes($storeId = false)
|
299 |
Â
$euProductCodes = Mage::getSingleton('postnl_core/system_config_source_euProductOptions');
|
300 |
Â
return $euProductCodes->getAvailableOptions($storeId, true);
|
301 |
Â
}
|
302 |
+
|
303 |
Â
/**
|
304 |
Â
* Get an array of global product codes
|
305 |
+
*
|
306 |
+
* @param bool $storeId
|
307 |
+
*
|
308 |
Â
* @return array
|
309 |
Â
*/
|
310 |
Â
public function getGlobalProductCodes($storeId = false)
|
312 |
Â
$globalProductCodes = Mage::getSingleton('postnl_core/system_config_source_globalProductOptions');
|
313 |
Â
return $globalProductCodes->getAvailableOptions($storeId, true);
|
314 |
Â
}
|
315 |
+
|
316 |
Â
/**
|
317 |
Â
* Get an array of possible shipment types
|
318 |
+
*
|
319 |
Â
* @return array
|
320 |
Â
*/
|
321 |
Â
public function getShipmentTypes()
|
322 |
Â
{
|
323 |
Â
return $this->_shipmentTypes;
|
324 |
Â
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Get an array of numeric shipment types
|
328 |
+
*
|
329 |
+
* @return array
|
330 |
+
*/
|
331 |
+
public function getNumericShipmentTypes()
|
332 |
+
{
|
333 |
+
return $this->_numericShipmentTypes;
|
334 |
+
}
|
335 |
+
|
336 |
Â
/**
|
337 |
Â
* Get an array of possible shipping phases
|
338 |
+
*
|
339 |
Â
* @return array
|
340 |
Â
*/
|
341 |
Â
public function getShippingPhases()
|
342 |
Â
{
|
343 |
Â
$shippingPhases = $this->_shippingPhases;
|
344 |
+
foreach ($shippingPhases as &$value) {
|
345 |
Â
$value = $this->__($value);
|
346 |
Â
}
|
347 |
+
|
348 |
Â
return $shippingPhases;
|
349 |
Â
}
|
350 |
+
|
351 |
+
/**
|
352 |
+
* Get country IDs that allow fullstreet usage
|
353 |
+
*
|
354 |
+
* @return array
|
355 |
+
*/
|
356 |
+
public function getAllowedFullStreetCountries()
|
357 |
+
{
|
358 |
+
return $this->_allowedFullStreetCountries;
|
359 |
+
}
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Get EPS combilabel codes.
|
363 |
+
*
|
364 |
+
* @return array
|
365 |
+
*/
|
366 |
+
public function getCombiLabelProductCodes()
|
367 |
+
{
|
368 |
+
return $this->_combiLabelProductCodes;
|
369 |
+
}
|
370 |
+
|
371 |
Â
/**
|
372 |
Â
* Checks if infinite label printing is enabled in the module configuration.
|
373 |
+
*
|
374 |
Â
* @return boolean
|
375 |
Â
*/
|
376 |
Â
public function allowInfinitePrinting()
|
377 |
Â
{
|
378 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
379 |
Â
$enabled = Mage::getStoreConfigFlag(self::XML_PATH_INFINITE_LABEL_PRINTING, $storeId);
|
380 |
+
|
381 |
Â
return $enabled;
|
382 |
Â
}
|
383 |
Â
/**
|
384 |
Â
* Checks which barcode type is applicable for this shipment
|
385 |
+
*
|
386 |
Â
* Possible return values:
|
387 |
Â
* - NL
|
388 |
Â
* - EU
|
389 |
Â
* - GLOBAL
|
390 |
+
*
|
391 |
+
* @param TIG_PostNL_Model_Core_Shipment $shipment
|
392 |
+
*
|
393 |
Â
* @return string | TIG_PostNL_Helper_Cif
|
394 |
+
*
|
395 |
Â
* @throws TIG_PostNL_Exception
|
396 |
Â
*/
|
397 |
Â
public function getBarcodeTypeForShipment($shipment)
|
400 |
Â
$barcodeType = self::DUTCH_BARCODE_TYPE;
|
401 |
Â
return $barcodeType;
|
402 |
Â
}
|
403 |
+
|
404 |
Â
if ($shipment->isEuShipment()) {
|
405 |
Â
$barcodeType = self::EU_BARCODE_TYPE;
|
406 |
Â
return $barcodeType;
|
407 |
Â
}
|
408 |
+
|
409 |
Â
if ($shipment->isGlobalShipment()) {
|
410 |
Â
$barcodeType = self::GLOBAL_BARCODE_TYPE;
|
411 |
Â
return $barcodeType;
|
412 |
Â
}
|
413 |
+
|
414 |
Â
throw new TIG_PostNL_Exception(
|
415 |
Â
$this->__('Unable to get valid barcodetype for postnl shipment id #%s', $shipment->getId()),
|
416 |
Â
'POSTNL-0029'
|
417 |
Â
);
|
Â
|
|
Â
|
|
418 |
Â
}
|
419 |
+
|
420 |
Â
/**
|
421 |
Â
* Get a list of available product options for a specified shipment
|
422 |
+
*
|
423 |
Â
* @param Mage_Sales_Model_Order_Shipment $shipment
|
424 |
+
*
|
425 |
Â
* @return array | null
|
426 |
Â
*/
|
427 |
Â
public function getProductOptionsForShipment($shipment)
|
432 |
Â
if ($this->isPakjeGemakShipment($shipment)) {
|
433 |
Â
$options = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions')
|
434 |
Â
->getAvailableOptions();
|
435 |
+
|
436 |
+
return $options;
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Pakketautomaat product options
|
441 |
+
*/
|
442 |
+
if ($this->isPakketautomaatShipment($shipment)) {
|
443 |
+
$options = Mage::getModel('postnl_core/system_config_source_pakketautomaatProductOptions')
|
444 |
+
->getAvailableOptions();
|
445 |
+
|
446 |
Â
return $options;
|
447 |
Â
}
|
448 |
+
|
449 |
Â
/**
|
450 |
Â
* Dutch product options
|
451 |
Â
*/
|
452 |
Â
if ($this->isDutchShipment($shipment)) {
|
453 |
Â
$options = Mage::getModel('postnl_core/system_config_source_standardProductOptions')
|
454 |
Â
->getAvailableOptions();
|
455 |
+
|
456 |
Â
return $options;
|
457 |
Â
}
|
458 |
+
|
459 |
Â
/**
|
460 |
Â
* EU product options
|
461 |
Â
*/
|
462 |
Â
if ($this->isEuShipment($shipment)) {
|
463 |
Â
$options = Mage::getModel('postnl_core/system_config_source_euProductOptions')
|
464 |
Â
->getAvailableOptions();
|
465 |
+
|
466 |
Â
return $options;
|
467 |
Â
}
|
468 |
+
|
469 |
Â
/**
|
470 |
Â
* Global product options
|
471 |
Â
*/
|
472 |
Â
if ($this->isGlobalShipment($shipment)) {
|
473 |
Â
$options = Mage::getModel('postnl_core/system_config_source_globalProductOptions')
|
474 |
Â
->getAvailableOptions();
|
475 |
+
|
476 |
Â
return $options;
|
477 |
Â
}
|
478 |
+
|
479 |
Â
return null;
|
480 |
Â
}
|
481 |
+
|
482 |
Â
/**
|
483 |
Â
* Check if a given shipment is PakjeGemak
|
484 |
+
*
|
485 |
+
* @param TIG_PostNL_Model_Core_Shipment|Mage_Sales_Model_Order_Shipment $shipment
|
486 |
+
*
|
487 |
Â
* @return boolean
|
488 |
+
*
|
489 |
+
* @see TIG_PostNL_Model_Core_Shipment->isPakjeGemakShipment();
|
490 |
Â
*/
|
491 |
Â
public function isPakjeGemakShipment($shipment)
|
492 |
Â
{
|
493 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
494 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
495 |
+
/**
|
496 |
+
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
497 |
+
*/
|
498 |
Â
return $shipment->isPakjeGemakShipment();
|
499 |
Â
}
|
500 |
+
|
501 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
502 |
Â
$tempPostnlShipment->setShipment($shipment);
|
503 |
+
|
504 |
Â
return $tempPostnlShipment->isPakjeGemakShipment();
|
505 |
Â
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* Check if a given shipment is a pakketautomaat shipment.
|
509 |
+
*
|
510 |
+
* @param TIG_PostNL_Model_Core_Shipment|Mage_Sales_Model_Order_Shipment $shipment
|
511 |
+
*
|
512 |
+
* @return boolean
|
513 |
+
*
|
514 |
+
* @see TIG_PostNL_Model_Core_Shipment->isDutchShipment();
|
515 |
+
*/
|
516 |
+
public function isPakketautomaatShipment($shipment)
|
517 |
+
{
|
518 |
+
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
519 |
+
if ($shipment instanceof $postnlShipmentClass) {
|
520 |
+
/**
|
521 |
+
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
522 |
+
*/
|
523 |
+
return $shipment->isPakketautomaatShipment();
|
524 |
+
}
|
525 |
+
|
526 |
+
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
527 |
+
$tempPostnlShipment->setShipment($shipment);
|
528 |
+
|
529 |
+
return $tempPostnlShipment->isPakketautomaatShipment();
|
530 |
+
}
|
531 |
+
|
532 |
Â
/**
|
533 |
Â
* Check if a given shipment is dutch
|
534 |
+
*
|
535 |
Â
* @param TIG_PostNL_Model_Core_Shipment | Mage_Sales_Model_Order_Shipment $shipment
|
536 |
+
*
|
537 |
Â
* @return boolean
|
538 |
+
*
|
539 |
Â
* @see TIG_PostNL_Model_Core_Shipment->isDutchSHipment();
|
540 |
Â
*/
|
541 |
Â
public function isDutchShipment($shipment)
|
542 |
Â
{
|
543 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
544 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
545 |
+
/**
|
546 |
+
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
547 |
+
*/
|
548 |
Â
return $shipment->isDutchShipment();
|
549 |
Â
}
|
550 |
+
|
551 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
552 |
Â
$tempPostnlShipment->setShipment($shipment);
|
553 |
+
|
554 |
Â
return $tempPostnlShipment->isDutchShipment();
|
555 |
Â
}
|
556 |
+
|
557 |
Â
/**
|
558 |
Â
* Check if a given shipment has an EU destination
|
559 |
+
*
|
560 |
Â
* @param TIG_PostNL_Model_Core_Shipment | Mage_Sales_Model_Order_Shipment $shipment
|
561 |
+
*
|
562 |
Â
* @return boolean
|
563 |
+
*
|
564 |
+
* @see TIG_PostNL_Model_Core_Shipment->isEuShipment();
|
565 |
Â
*/
|
566 |
Â
public function isEuShipment($shipment)
|
567 |
Â
{
|
568 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
569 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
570 |
+
/**
|
571 |
+
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
572 |
+
*/
|
573 |
Â
return $shipment->isEuShipment();
|
574 |
Â
}
|
575 |
+
|
576 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
577 |
Â
$tempPostnlShipment->setShipment($shipment);
|
578 |
+
|
579 |
Â
return $tempPostnlShipment->isEuShipment();
|
580 |
Â
}
|
581 |
+
|
582 |
Â
/**
|
583 |
Â
* Check if a given shipment has a global destination
|
584 |
+
*
|
585 |
+
* @param TIG_PostNL_Model_Core_Shipment|Mage_Sales_Model_Order_Shipment $shipment
|
586 |
+
*
|
587 |
Â
* @return boolean
|
588 |
+
*
|
589 |
+
* @see TIG_PostNL_Model_Core_Shipment->isGlobalShipment();
|
590 |
Â
*/
|
591 |
Â
public function isGlobalShipment($shipment)
|
592 |
Â
{
|
593 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
594 |
Â
if ($shipment instanceof $postnlShipmentClass) {
|
595 |
+
/**
|
596 |
+
* @var TIG_PostNL_Model_Core_Shipment $shipment
|
597 |
+
*/
|
598 |
Â
return $shipment->isGlobalShipment();
|
599 |
Â
}
|
600 |
+
|
601 |
Â
$tempPostnlShipment = Mage::getModel('postnl_core/shipment');
|
602 |
Â
$tempPostnlShipment->setShipment($shipment);
|
603 |
+
|
604 |
Â
return $tempPostnlShipment->isGlobalShipment();
|
605 |
Â
}
|
606 |
+
|
607 |
Â
/**
|
608 |
Â
* Gets the default product option for a shipment
|
609 |
+
*
|
610 |
Â
* @param Mage_Sales_Model_Order_Shipment
|
611 |
+
*
|
612 |
Â
* @return string
|
613 |
Â
*/
|
614 |
Â
public function getDefaultProductOptionForShipment($shipment)
|
615 |
Â
{
|
616 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
617 |
Â
$postnlShipment->setShipment($shipment);
|
618 |
+
|
619 |
Â
$productOption = $postnlShipment->getDefaultProductCode();
|
620 |
+
|
621 |
Â
return $productOption;
|
622 |
Â
}
|
623 |
+
|
624 |
Â
/**
|
625 |
Â
* Get an array of all default product options. This is a simple method to quickly get a list of default options based on
|
626 |
Â
* the current storeview.
|
627 |
+
*
|
628 |
Â
* This does not take into account the possible use of an alternative default for dutch shipments. For that you need to use
|
629 |
Â
* TIG_PostNL_Model_Core_Shipment::getDefaultProductCode() which is more precise.
|
630 |
+
*
|
631 |
Â
* @return array
|
632 |
Â
*/
|
633 |
Â
public function getDefaultProductOptions()
|
634 |
Â
{
|
635 |
Â
$storeId = Mage::app()->getStore()->getId();
|
636 |
+
|
637 |
+
$defaultDutchOption = Mage::getStoreConfig(self::XML_PATH_DEFAULT_STANDARD_PRODUCT_OPTION, $storeId);
|
638 |
+
$defaultEuOption = Mage::getStoreConfig(self::XML_PATH_DEFAULT_EU_PRODUCT_OPTION, $storeId);
|
639 |
+
$defaultGlobalOption = Mage::getStoreConfig(self::XML_PATH_DEFAULT_GLOBAL_PRODUCT_OPTION, $storeId);
|
640 |
+
$defaultPakketautomaatOption = Mage::getStoreConfig(
|
641 |
+
self::XML_PATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION,
|
642 |
+
$storeId
|
643 |
+
);
|
644 |
+
|
645 |
Â
$defaultOptions = array(
|
646 |
+
'dutch' => $defaultDutchOption,
|
647 |
+
'eu' => $defaultEuOption,
|
648 |
+
'global' => $defaultGlobalOption,
|
649 |
+
'pakketautomaat' => $defaultPakketautomaatOption,
|
650 |
Â
);
|
651 |
+
|
652 |
Â
return $defaultOptions;
|
653 |
Â
}
|
654 |
+
|
655 |
Â
/**
|
656 |
Â
* Gets the number of parcels in this shipment based on it's weight
|
657 |
+
*
|
658 |
Â
* @param Mage_Sales_Model_Order_Shipment $shipment
|
659 |
+
*
|
660 |
Â
* @return int
|
661 |
Â
*/
|
662 |
Â
public function getParcelCount($shipment)
|
663 |
Â
{
|
664 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
665 |
Â
$postnlShipment->setShipment($shipment);
|
666 |
+
|
667 |
Â
/**
|
668 |
Â
* Only NL shipments support multi-colli shipments
|
669 |
Â
*/
|
670 |
Â
if (!$postnlShipment->isDutchShipment()) {
|
671 |
Â
return 1;
|
672 |
Â
}
|
673 |
+
|
674 |
Â
/**
|
675 |
Â
* get this shipment's total weight
|
676 |
Â
*/
|
677 |
Â
$weight = $postnlShipment->getTotalWeight(true);
|
678 |
+
|
679 |
Â
/**
|
680 |
Â
* get the weight per parcel
|
681 |
Â
*/
|
682 |
Â
$weightPerParcel = Mage::getStoreConfig(self::XML_PATH_WEIGHT_PER_PARCEL, $shipment->getStoreId());
|
683 |
Â
$weightPerParcel = $this->standardizeWeight($weightPerParcel, $shipment->getStoreId());
|
684 |
+
|
685 |
Â
/**
|
686 |
Â
* calculate the number of parcels needed to ship the total weight of this shipment
|
687 |
Â
*/
|
688 |
Â
$parcelCount = ceil($weight / $weightPerParcel);
|
689 |
+
|
690 |
Â
return $parcelCount;
|
691 |
Â
}
|
692 |
+
|
693 |
Â
/**
|
694 |
Â
* Checks if a given postnl shipment exists using Zend_Validate_Db_RecordExists.
|
695 |
+
*
|
696 |
Â
* @param string $shipmentId
|
697 |
+
*
|
698 |
Â
* @return boolean
|
699 |
+
*
|
700 |
Â
* @see Zend_Validate_Db_RecordExists
|
701 |
+
*
|
702 |
Â
* @link http://framework.zend.com/manual/1.12/en/zend.validate.set.html#zend.validate.Db
|
703 |
Â
*/
|
704 |
Â
public function postnlShipmentExists($shipmentId)
|
705 |
Â
{
|
706 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
707 |
Â
$readAdapter = $coreResource->getConnection('core_read');
|
708 |
+
|
709 |
+
$validator = new Zend_Validate_Db_RecordExists(
|
710 |
Â
array(
|
711 |
Â
'table' => $coreResource->getTableName('postnl_core/shipment'),
|
712 |
Â
'field' => 'shipment_id',
|
713 |
Â
'adapter' => $readAdapter,
|
714 |
Â
)
|
715 |
Â
);
|
716 |
+
|
717 |
Â
$postnlShipmentExists = $validator->isValid($shipmentId);
|
718 |
+
|
719 |
Â
if ($postnlShipmentExists) {
|
720 |
Â
return true;
|
721 |
Â
}
|
722 |
+
|
723 |
Â
return false;
|
724 |
Â
}
|
725 |
+
|
726 |
Â
/**
|
727 |
Â
* Checks if a given barcode exists using Zend_Validate_Db_RecordExists.
|
728 |
+
*
|
729 |
Â
* @param string $barcode
|
730 |
+
*
|
731 |
Â
* @return boolean
|
732 |
+
*
|
733 |
Â
* @see Zend_Validate_Db_RecordExists
|
734 |
+
*
|
735 |
Â
* @link http://framework.zend.com/manual/1.12/en/zend.validate.set.html#zend.validate.Db
|
736 |
Â
*/
|
737 |
Â
public function barcodeExists($barcode)
|
738 |
Â
{
|
739 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
740 |
Â
$readAdapter = $coreResource->getConnection('core_read');
|
741 |
+
|
742 |
Â
/**
|
743 |
Â
* Check if the barcode exists as a main barcode
|
744 |
Â
*/
|
745 |
+
$validator = new Zend_Validate_Db_RecordExists(
|
746 |
Â
array(
|
747 |
Â
'table' => $coreResource->getTableName('postnl_core/shipment'),
|
748 |
Â
'field' => 'main_barcode',
|
749 |
Â
'adapter' => $readAdapter,
|
750 |
Â
)
|
751 |
Â
);
|
752 |
+
|
753 |
Â
$barcodeExists = $validator->isValid($barcode);
|
754 |
+
|
755 |
Â
if ($barcodeExists) {
|
756 |
Â
return true;
|
757 |
Â
}
|
758 |
+
|
759 |
Â
/**
|
760 |
Â
* Check if the barcode exists as a secondary barcode
|
761 |
Â
*/
|
762 |
+
$validator = new Zend_Validate_Db_RecordExists(
|
763 |
Â
array(
|
764 |
Â
'table' => $coreResource->getTableName('postnl_core/shipment_barcode'),
|
765 |
Â
'field' => 'barcode',
|
766 |
Â
'adapter' => $readAdapter,
|
767 |
Â
)
|
768 |
Â
);
|
769 |
+
|
770 |
Â
$barcodeExists = $validator->isValid($barcode);
|
771 |
+
|
772 |
Â
if ($barcodeExists) {
|
773 |
Â
return true;
|
774 |
Â
}
|
775 |
+
|
776 |
Â
return false;
|
777 |
Â
}
|
778 |
+
|
779 |
Â
/**
|
780 |
Â
* Convert a given weight to kilogram or gram
|
781 |
+
*
|
782 |
Â
* @param float $weight The weight to be converted
|
783 |
Â
* @param int | null $storeId Store Id used to determine the weight unit that was originally used
|
784 |
Â
* @param boolean $toGram Optional parameter to convert to gram instead of kilogram
|
785 |
+
*
|
786 |
Â
* @return float
|
787 |
Â
*/
|
788 |
Â
public function standardizeWeight($weight, $storeId = null, $toGram = false)
|
790 |
Â
if (is_null($storeId)) {
|
791 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
792 |
Â
}
|
793 |
+
|
794 |
Â
$unitUsed = Mage::getStoreConfig(self::XML_PATH_WEIGHT_UNIT, $storeId);
|
795 |
+
|
Â
|
|
796 |
Â
switch ($unitUsed) {
|
797 |
Â
case 'tonne':
|
798 |
Â
$returnWeight = $weight * 1000;
|
833 |
Â
case 'pound':
|
834 |
Â
$returnWeight = $weight * 0.45359237;
|
835 |
Â
break;
|
Â
|
|
Â
|
|
Â
|
|
836 |
Â
case 'ounce':
|
837 |
Â
$returnWeight = $weight * 0.028349523125;
|
838 |
Â
break;
|
863 |
Â
if ($toGram === true) {
|
864 |
Â
$returnWeight *= 1000;
|
865 |
Â
}
|
866 |
+
|
867 |
Â
return $returnWeight;
|
868 |
Â
}
|
869 |
+
|
870 |
+
/**
|
871 |
+
* Retrieves streetname, housenumber and housenumber extension from the shipping address.
|
872 |
+
* The shipping address may be in multiple streetlines configuration or single line
|
873 |
+
* configuration. In the case of multi-line, each part of the street data will be in a seperate
|
874 |
+
* field. In the single line configuration, each part will be in the same field and will have
|
875 |
+
* to be split using PREG.
|
876 |
+
*
|
877 |
+
* PREG cannot be relied on as it is impossible to create a regex that can filter all
|
878 |
+
* possible street syntaxes. Therefore we strongly recommend to use multiple street lines. This
|
879 |
+
* can be enabled in Magento community in system > config > customer configuration. Or if you
|
880 |
+
* use Enterprise, in customers > attributes > manage customer address attributes.
|
881 |
+
*
|
882 |
+
* @param int $storeId
|
883 |
+
* @param Mage_Customer_Model_Address_Abstract $address
|
884 |
+
* @param boolean $allowFullStreet
|
885 |
+
*
|
886 |
+
* @return array
|
887 |
+
*/
|
888 |
+
public function getStreetData($storeId, $address, $allowFullStreet = true)
|
889 |
+
{
|
890 |
+
if (!$storeId) {
|
891 |
+
$storeId = Mage::app()->getStore()->getId();
|
892 |
+
}
|
893 |
+
|
894 |
+
$splitStreet = Mage::helper('postnl/addressValidation')->useSplitStreet($storeId);
|
895 |
+
|
896 |
+
/**
|
897 |
+
* Website uses multi-line address mode
|
898 |
+
*/
|
899 |
+
if ($splitStreet) {
|
900 |
+
$streetData = $this->_getMultiLineStreetData($storeId, $address);
|
901 |
+
|
902 |
+
/**
|
903 |
+
* If $streetData is false it means a required field was missing. In this
|
904 |
+
* case the alternative methods are used to obtain the address data.
|
905 |
+
*/
|
906 |
+
if ($streetData !== false) {
|
907 |
+
return $streetData;
|
908 |
+
}
|
909 |
+
}
|
910 |
+
|
911 |
+
/**
|
912 |
+
* Website uses single-line address mode
|
913 |
+
*/
|
914 |
+
$allowedFullStreetCountries = $this->getAllowedFullStreetCountries();
|
915 |
+
$fullStreet = $address->getStreetFull();
|
916 |
+
|
917 |
+
/**
|
918 |
+
* Select countries don't have to split their street values into seperate part
|
919 |
+
*/
|
920 |
+
if ($allowFullStreet === true
|
921 |
+
&& in_array($address->getCountry(), $allowedFullStreetCountries)
|
922 |
+
) {
|
923 |
+
$streetData = array(
|
924 |
+
'streetname' => '',
|
925 |
+
'housenumber' => '',
|
926 |
+
'housenumberExtension' => '',
|
927 |
+
'fullStreet' => $fullStreet,
|
928 |
+
);
|
929 |
+
return $streetData;
|
930 |
+
}
|
931 |
+
|
932 |
+
/**
|
933 |
+
* All other countries must split them using PREG
|
934 |
+
*/
|
935 |
+
$streetData = $this->_getSplitStreetData($fullStreet);
|
936 |
+
|
937 |
+
return $streetData;
|
938 |
+
}
|
939 |
+
|
940 |
+
/**
|
941 |
+
* Retrieves streetname, housenumber and housenumber extension from the shipping address in the multiple streetlines
|
942 |
+
* configuration.
|
943 |
+
*
|
944 |
+
* @param int $storeId
|
945 |
+
* @param Mage_Sales_Model_Order_Address $address
|
946 |
+
*
|
947 |
+
* @return array
|
948 |
+
*/
|
949 |
+
protected function _getMultiLineStreetData($storeId, $address)
|
950 |
+
{
|
951 |
+
$addressHelper = Mage::helper('postnl/addressValidation');
|
952 |
+
|
953 |
+
$streetnameField = $addressHelper->getStreetnameField($storeId);;
|
954 |
+
$housenumberField = $addressHelper->getHousenumberField($storeId);;
|
955 |
+
|
956 |
+
$streetname = $address->getStreet($streetnameField);
|
957 |
+
$housenumber = $address->getStreet($housenumberField);
|
958 |
+
$housenumber = trim($housenumber);
|
959 |
+
|
960 |
+
/**
|
961 |
+
* If street or housenr fields are empty, use alternative options to obtain the address data
|
962 |
+
*/
|
963 |
+
if (empty($streetname) || empty($housenumber)) {
|
964 |
+
return false;
|
965 |
+
}
|
966 |
+
|
967 |
+
/**
|
968 |
+
* Split the housenumber into a number and an extension
|
969 |
+
*/
|
970 |
+
$splitHouseNumber = $addressHelper->useSplitHousenumber();
|
971 |
+
if ($splitHouseNumber) {
|
972 |
+
$housenumberExtensionField = $addressHelper->getHousenumberExtensionField();
|
973 |
+
$housenumberExtension = $address->getStreet($housenumberExtensionField);
|
974 |
+
|
975 |
+
/**
|
976 |
+
* Make sure the housenumber is actually split.
|
977 |
+
*/
|
978 |
+
if (!$housenumberExtension && !is_numeric($housenumber)) {
|
979 |
+
$housenumberParts = $this->_splitHousenumber($housenumber);
|
980 |
+
$housenumber = $housenumberParts['number'];
|
981 |
+
$housenumberExtension = $housenumberParts['extension'];
|
982 |
+
}
|
983 |
+
} else {
|
984 |
+
$housenumberParts = $this->_splitHousenumber($housenumber);
|
985 |
+
$housenumber = $housenumberParts['number'];
|
986 |
+
$housenumberExtension = $housenumberParts['extension'];
|
987 |
+
}
|
988 |
+
|
989 |
+
if (empty($housenumber)) {
|
990 |
+
return false;
|
991 |
+
}
|
992 |
+
|
993 |
+
$streetData = array(
|
994 |
+
'streetname' => $streetname,
|
995 |
+
'housenumber' => $housenumber,
|
996 |
+
'housenumberExtension' => $housenumberExtension,
|
997 |
+
'fullStreet' => '',
|
998 |
+
);
|
999 |
+
|
1000 |
+
return $streetData;
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
/**
|
1004 |
+
* Splits street data into seperate parts for streetname, housenumber and extension.
|
1005 |
+
*
|
1006 |
+
* @param string $fullStreet The full streetname including all parts
|
1007 |
+
*
|
1008 |
+
* @return array
|
1009 |
+
*
|
1010 |
+
* @throws TIG_PostNL_Exception
|
1011 |
+
*/
|
1012 |
+
protected function _getSplitStreetData($fullStreet)
|
1013 |
+
{
|
1014 |
+
$result = preg_match(self::SPLIT_STREET_REGEX, $fullStreet, $matches);
|
1015 |
+
if (!$result || !is_array($matches)) {
|
1016 |
+
throw new TIG_PostNL_Exception(
|
1017 |
+
Mage::helper('postnl')->__('Invalid full street supplied: %s', $fullStreet),
|
1018 |
+
'POSTNL-0060'
|
1019 |
+
);
|
1020 |
+
}
|
1021 |
+
|
1022 |
+
$streetname = '';
|
1023 |
+
$housenumber = '';
|
1024 |
+
if (isset($matches[1])) {
|
1025 |
+
$streetname = $matches[1];
|
1026 |
+
}
|
1027 |
+
|
1028 |
+
if (isset($matches[2])) {
|
1029 |
+
$housenumber = $matches[2];
|
1030 |
+
}
|
1031 |
+
|
1032 |
+
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1033 |
+
$housenumber = $housenumberParts['number'];
|
1034 |
+
$housenumberExtension = $housenumberParts['extension'];
|
1035 |
+
|
1036 |
+
$streetData = array(
|
1037 |
+
'streetname' => $streetname,
|
1038 |
+
'housenumber' => $housenumber,
|
1039 |
+
'housenumberExtension' => $housenumberExtension,
|
1040 |
+
'fullStreet' => '',
|
1041 |
+
);
|
1042 |
+
|
1043 |
+
return $streetData;
|
1044 |
+
}
|
1045 |
+
|
1046 |
+
/**
|
1047 |
+
* Splits a supplier housenumber into a number and an extension.
|
1048 |
+
*
|
1049 |
+
* @param string $housenumber
|
1050 |
+
*
|
1051 |
+
* @return array
|
1052 |
+
*
|
1053 |
+
* @throws TIG_PostNL_Exception
|
1054 |
+
*/
|
1055 |
+
protected function _splitHousenumber($housenumber)
|
1056 |
+
{
|
1057 |
+
$housenumber = trim($housenumber);
|
1058 |
+
$result = preg_match(self::SPLIT_HOUSENUMBER_REGEX, $housenumber, $matches);
|
1059 |
+
if (!$result || !is_array($matches)) {
|
1060 |
+
throw new TIG_PostNL_Exception(
|
1061 |
+
Mage::helper('postnl')->__('Invalid housnumber supplied: %s', $housenumber),
|
1062 |
+
'POSTNL-0059'
|
1063 |
+
);
|
1064 |
+
}
|
1065 |
+
|
1066 |
+
$extension = '';
|
1067 |
+
$number = '';
|
1068 |
+
if (isset($matches[1])) {
|
1069 |
+
$number = $matches[1];
|
1070 |
+
}
|
1071 |
+
|
1072 |
+
if (isset($matches[2])) {
|
1073 |
+
$extension = trim($matches[2]);
|
1074 |
+
}
|
1075 |
+
|
1076 |
+
$housenumberParts = array(
|
1077 |
+
'number' => $number,
|
1078 |
+
'extension' => $extension,
|
1079 |
+
);
|
1080 |
+
|
1081 |
+
return $housenumberParts;
|
1082 |
+
}
|
1083 |
+
|
1084 |
Â
/**
|
1085 |
Â
* Logs a CIF request and response for debug purposes.
|
1086 |
+
*
|
1087 |
Â
* N.B.: if file logging is enabled, the log will be forced
|
1088 |
+
*
|
1089 |
+
* @param Zend_Soap_Client $client
|
1090 |
+
*
|
1091 |
Â
* @return TIG_PostNL_Helper_Cif
|
1092 |
+
*
|
1093 |
Â
* @see Mage::log()
|
1094 |
+
*
|
Â
|
|
Â
|
|
1095 |
Â
*/
|
1096 |
Â
public function logCifCall($client)
|
1097 |
Â
{
|
1098 |
+
if (!$this->isLoggingEnabled()) {
|
1099 |
Â
return $this;
|
1100 |
Â
}
|
1101 |
+
|
1102 |
Â
$requestXml = $this->formatXml($client->getLastRequest());
|
1103 |
Â
$responseXML = $this->formatXml($client->getLastResponse());
|
1104 |
+
|
1105 |
Â
$logMessage = "Request sent:\n"
|
1106 |
Â
. $requestXml
|
1107 |
Â
. "\nResponse received:\n"
|
1108 |
Â
. $responseXML;
|
1109 |
+
|
1110 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::CIF_DEBUG_LOG_FILE;
|
1111 |
Â
$this->log($logMessage, Zend_Log::DEBUG, $file);
|
1112 |
+
|
1113 |
Â
return $this;
|
1114 |
Â
}
|
1115 |
+
|
1116 |
Â
/**
|
1117 |
+
* Logs a CIF exception in the database and/or a log file.
|
1118 |
+
*
|
Â
|
|
Â
|
|
1119 |
Â
* @param Mage_Core_Exception | TIG_PostNL_Model_Core_Cif_Exception $exception
|
1120 |
+
*
|
1121 |
Â
* @return TIG_PostNL_Helper_Cif
|
1122 |
+
*
|
1123 |
Â
* @see Mage::logException()
|
Â
|
|
Â
|
|
1124 |
Â
*/
|
1125 |
Â
public function logCifException($exception)
|
1126 |
Â
{
|
1127 |
Â
if (!$this->isExceptionLoggingEnabled()) {
|
1128 |
Â
return $this;
|
1129 |
Â
}
|
1130 |
+
|
1131 |
Â
if ($exception instanceof TIG_PostNL_Model_Core_Cif_Exception) {
|
1132 |
Â
$requestXml = $this->formatXml($exception->getRequestXml());
|
1133 |
Â
$responseXML = $this->formatXml($exception->getResponseXml());
|
1134 |
+
|
1135 |
Â
$logMessage = '';
|
1136 |
+
|
1137 |
Â
$errorNumbers = $exception->getErrorNumbers();
|
1138 |
Â
if (!empty($errorNumbers)) {
|
1139 |
Â
$errorNumbers = implode(', ', $errorNumbers);
|
1140 |
Â
$logMessage .= "Error numbers received: {$errorNumbers}\n";
|
1141 |
Â
}
|
1142 |
+
|
1143 |
Â
$logMessage .= "<<< REQUEST SENT >>>\n"
|
1144 |
Â
. $requestXml
|
1145 |
Â
. "\n<<< RESPONSE RECEIVED >>>\n"
|
1147 |
Â
} else {
|
1148 |
Â
$logMessage = "\n" . $exception->__toString();
|
1149 |
Â
}
|
1150 |
+
|
1151 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::CIF_EXCEPTION_LOG_FILE;
|
1152 |
Â
$this->log($logMessage, Zend_Log::ERR, $file, false, true);
|
1153 |
+
|
1154 |
Â
return $this;
|
1155 |
Â
}
|
1156 |
Â
}
|
@@ -33,68 +33,68 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
40 |
Â
{
|
41 |
Â
/**
|
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/
|
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 |
Â
|
@@ -104,7 +104,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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 |
Â
*/
|
@@ -122,7 +122,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
122 |
Â
);
|
123 |
Â
|
124 |
Â
/**
|
125 |
-
* Required configuration fields for live mode
|
126 |
Â
*
|
127 |
Â
* @var array
|
128 |
Â
*/
|
@@ -132,7 +132,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
132 |
Â
);
|
133 |
Â
|
134 |
Â
/**
|
135 |
-
* Required configuration fields for test mode
|
136 |
Â
*
|
137 |
Â
* @var array
|
138 |
Â
*/
|
@@ -142,7 +142,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
142 |
Â
);
|
143 |
Â
|
144 |
Â
/**
|
145 |
-
* Required configuration fields when using global shipments
|
146 |
Â
*
|
147 |
Â
* @var array
|
148 |
Â
*/
|
@@ -156,7 +156,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
156 |
Â
);
|
157 |
Â
|
158 |
Â
/**
|
159 |
-
* Get required fields array
|
160 |
Â
*
|
161 |
Â
* @return array
|
162 |
Â
*/
|
@@ -166,7 +166,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
166 |
Â
}
|
167 |
Â
|
168 |
Â
/**
|
169 |
-
* Get required fields for live mode array
|
170 |
Â
*
|
171 |
Â
* @return array
|
172 |
Â
*/
|
@@ -176,7 +176,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
176 |
Â
}
|
177 |
Â
|
178 |
Â
/**
|
179 |
-
* Get required fields for test mode array
|
180 |
Â
*
|
181 |
Â
* @return array
|
182 |
Â
*/
|
@@ -186,7 +186,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
186 |
Â
}
|
187 |
Â
|
188 |
Â
/**
|
189 |
-
* Get required fields for global shipments array
|
190 |
Â
*
|
191 |
Â
* @return array
|
192 |
Â
*/
|
@@ -196,7 +196,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
196 |
Â
}
|
197 |
Â
|
198 |
Â
/**
|
199 |
-
* Get debug mode config setting
|
200 |
Â
*
|
201 |
Â
* @return int
|
202 |
Â
*/
|
@@ -213,7 +213,57 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
213 |
Â
}
|
214 |
Â
|
215 |
Â
/**
|
216 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
217 |
Â
*
|
218 |
Â
* @param boolean|int $storeId
|
219 |
Â
*
|
@@ -235,7 +285,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
235 |
Â
}
|
236 |
Â
|
237 |
Â
/**
|
238 |
-
* Checks to see if the module may ship using PakjeGemak
|
239 |
Â
*
|
240 |
Â
* @param boolean|int $storeId
|
241 |
Â
*
|
@@ -336,6 +386,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
336 |
Â
*/
|
337 |
Â
public function saveConfigState($configState = array())
|
338 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
339 |
Â
$adminUser = Mage::getSingleton('admin/session')->getUser();
|
340 |
Â
if (!$adminUser) {
|
341 |
Â
return false;
|
@@ -364,6 +417,87 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
364 |
Â
return true;
|
365 |
Â
}
|
366 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
367 |
Â
/**
|
368 |
Â
* Checks if GlobalPack may be used.
|
369 |
Â
*
|
@@ -403,7 +537,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
403 |
Â
/**
|
404 |
Â
* Checks if test mode is currently allowed
|
405 |
Â
*
|
406 |
-
* @deprecated
|
Â
|
|
407 |
Â
*
|
408 |
Â
* @return boolean
|
409 |
Â
*/
|
@@ -415,8 +550,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
415 |
Â
/**
|
416 |
Â
* Alias for isEnabled()
|
417 |
Â
*
|
418 |
-
* @param int
|
419 |
-
* @param boolean
|
420 |
Â
* @param null|boolean $forceTestMode
|
421 |
Â
*
|
422 |
Â
* @return boolean
|
@@ -479,6 +614,15 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
479 |
Â
return false;
|
480 |
Â
}
|
481 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
482 |
Â
/**
|
483 |
Â
* Check if the module's required configuration options have been filled
|
484 |
Â
*/
|
@@ -504,8 +648,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
504 |
Â
);
|
505 |
Â
|
506 |
Â
$errorMessage = $this->__(
|
507 |
-
'The PostNL shipping method has not been enabled. You can enable the PostNL shipping method under
|
508 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
509 |
Â
'</a>'
|
510 |
Â
);
|
511 |
Â
|
@@ -540,6 +689,58 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
@@ -549,8 +750,6 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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)
|
556 |
Â
{
|
@@ -613,8 +812,10 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
617 |
-
* inform the merchant which fields exactly are missing.
|
Â
|
|
Â
|
|
618 |
Â
*/
|
619 |
Â
$configFields = Mage::getSingleton('adminhtml/config');
|
620 |
Â
$sections = $configFields->getSections('postnl');
|
@@ -622,22 +823,29 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
622 |
Â
foreach ($requiredFields as $requiredField) {
|
623 |
Â
$value = Mage::getStoreConfig($requiredField, $storeId);
|
624 |
Â
|
625 |
-
if ($value
|
626 |
-
|
627 |
-
|
628 |
-
$group = $fieldParts[1];
|
629 |
Â
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
Â
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
Â
|
639 |
-
|
640 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
641 |
Â
}
|
642 |
Â
|
643 |
Â
/**
|
@@ -689,17 +897,21 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
689 |
Â
* Based on Mage_Core_Model_Config::getModuleDir()
|
690 |
Â
*
|
691 |
Â
* @param string $dir The directory in question
|
692 |
-
* @param string $
|
693 |
Â
*
|
694 |
Â
* @return string
|
695 |
Â
*
|
696 |
-
* @see
|
697 |
Â
*/
|
698 |
Â
public function getModuleDir($dir, $moduleName = 'TIG_PostNL')
|
699 |
Â
{
|
700 |
Â
$config = Mage::app()->getConfig();
|
701 |
Â
|
702 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
703 |
Â
$path = $config->getOptions()->getCodeDir()
|
704 |
Â
. DS
|
705 |
Â
. $codePool
|
@@ -735,13 +947,13 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
735 |
Â
}
|
736 |
Â
|
737 |
Â
/**
|
738 |
-
* Logs a debug message. Based on Mage::log
|
739 |
Â
*
|
740 |
-
* @param string
|
741 |
-
* @param int
|
742 |
-
* @param string
|
743 |
-
* @param boolean
|
744 |
-
* @param boolean
|
745 |
Â
*
|
746 |
Â
* @return TIG_PostNL_Helper_Data
|
747 |
Â
*
|
@@ -774,7 +986,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
778 |
Â
*
|
779 |
Â
* @return TIG_PostNL_Helper_Data
|
780 |
Â
*
|
@@ -818,7 +1030,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
818 |
Â
}
|
819 |
Â
|
820 |
Â
/**
|
821 |
-
* Checks if the current edition of Magento is enterprise. Uses Mage::getEdition if available
|
Â
|
|
822 |
Â
*
|
823 |
Â
* @return boolean
|
824 |
Â
*
|
@@ -827,7 +1040,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
827 |
Â
public function isEnterprise()
|
828 |
Â
{
|
829 |
Â
/**
|
830 |
-
* Use Mage::getEdition, which is available since CE 1.7 and EE 1.12
|
831 |
Â
*/
|
832 |
Â
if (method_exists('Mage', 'getEdition')) {
|
833 |
Â
$edition = Mage::getEdition();
|
@@ -840,7 +1053,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
840 |
Â
}
|
841 |
Â
|
842 |
Â
/**
|
843 |
-
* If the edition is not community or enterprise, it is not supported
|
844 |
Â
*/
|
845 |
Â
throw new TIG_PostNL_Exception(
|
846 |
Â
$this->__('Invalid Magento edition detected: %s', $edition),
|
@@ -849,10 +1062,17 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
849 |
Â
}
|
850 |
Â
|
851 |
Â
/**
|
852 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
853 |
Â
*/
|
854 |
Â
$version = Mage::getVersion();
|
855 |
-
if (version_compare($version, '1.9.0.0', '>=')) {
|
856 |
Â
return true;
|
857 |
Â
}
|
858 |
Â
|
@@ -871,7 +1091,7 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
871 |
Â
}
|
872 |
Â
|
873 |
Â
/**
|
874 |
-
* Fallback check in case the previous check returns a false
|
875 |
Â
*/
|
876 |
Â
if (Mage::getDesign()->getArea() == 'adminhtml') {
|
877 |
Â
return true;
|
@@ -898,8 +1118,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
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 |
Â
*
|
@@ -916,8 +1136,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
916 |
Â
}
|
917 |
Â
|
918 |
Â
/**
|
919 |
-
* Adds an error message to the specified session based on an exception. The exception should contain a valid error
|
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.
|
@@ -977,8 +1197,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
981 |
-
* will be appended.
|
982 |
Â
*
|
983 |
Â
* If no $code is specified, $messageType and $message will be required
|
984 |
Â
*
|
@@ -996,9 +1216,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
996 |
Â
*/
|
997 |
Â
public function addSessionMessage($session, $code = null, $messageType = null, $message = null)
|
998 |
Â
{
|
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
|
@@ -1015,8 +1235,10 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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 |
Â
/**
|
@@ -1032,9 +1254,9 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1032 |
Â
);
|
1033 |
Â
}
|
1034 |
Â
|
1035 |
-
|
1036 |
Â
* Get the actual error from config.xml if it's available
|
1037 |
-
|
1038 |
Â
|
1039 |
Â
$error = false;
|
1040 |
Â
$link = false;
|
@@ -1049,10 +1271,10 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1049 |
Â
}
|
1050 |
Â
}
|
1051 |
Â
|
1052 |
-
|
1053 |
-
* Check that the required 'message' and 'messageType' components are available. If they are not yet available,
|
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
|
@@ -1089,10 +1311,10 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
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
|
@@ -1114,22 +1336,22 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
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
|
@@ -1155,7 +1377,8 @@ class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1155 |
Â
}
|
1156 |
Â
|
1157 |
Â
/**
|
1158 |
-
* Checks to see if we can show error details (error code and knowledgebase link) in the frontend when an error
|
Â
|
|
1159 |
Â
*
|
1160 |
Â
* @return boolean
|
1161 |
Â
*/
|
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 |
Â
class TIG_PostNL_Helper_Data extends Mage_Core_Helper_Abstract
|
40 |
Â
{
|
41 |
Â
/**
|
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/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 |
Â
|
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 |
Â
*/
|
122 |
Â
);
|
123 |
Â
|
124 |
Â
/**
|
125 |
+
* Required configuration fields for live mode.
|
126 |
Â
*
|
127 |
Â
* @var array
|
128 |
Â
*/
|
132 |
Â
);
|
133 |
Â
|
134 |
Â
/**
|
135 |
+
* Required configuration fields for test mode.
|
136 |
Â
*
|
137 |
Â
* @var array
|
138 |
Â
*/
|
142 |
Â
);
|
143 |
Â
|
144 |
Â
/**
|
145 |
+
* Required configuration fields when using global shipments.
|
146 |
Â
*
|
147 |
Â
* @var array
|
148 |
Â
*/
|
156 |
Â
);
|
157 |
Â
|
158 |
Â
/**
|
159 |
+
* Get required fields array.
|
160 |
Â
*
|
161 |
Â
* @return array
|
162 |
Â
*/
|
166 |
Â
}
|
167 |
Â
|
168 |
Â
/**
|
169 |
+
* Get required fields for live mode array.
|
170 |
Â
*
|
171 |
Â
* @return array
|
172 |
Â
*/
|
176 |
Â
}
|
177 |
Â
|
178 |
Â
/**
|
179 |
+
* Get required fields for test mode array.
|
180 |
Â
*
|
181 |
Â
* @return array
|
182 |
Â
*/
|
186 |
Â
}
|
187 |
Â
|
188 |
Â
/**
|
189 |
+
* Get required fields for global shipments array.
|
190 |
Â
*
|
191 |
Â
* @return array
|
192 |
Â
*/
|
196 |
Â
}
|
197 |
Â
|
198 |
Â
/**
|
199 |
+
* Get debug mode config setting.
|
200 |
Â
*
|
201 |
Â
* @return int
|
202 |
Â
*/
|
213 |
Â
}
|
214 |
Â
|
215 |
Â
/**
|
216 |
+
* Gets a shipment's PakjeGemak address if available.
|
217 |
+
*
|
218 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
219 |
+
*
|
220 |
+
* @return bool|Mage_Sales_Model_Order_Address
|
221 |
+
*/
|
222 |
+
public function getPakjeGemakAddressForShipment(Mage_Sales_Model_Order_Shipment $shipment)
|
223 |
+
{
|
224 |
+
$order = $shipment->getOrder();
|
225 |
+
|
226 |
+
return $this->getPakjeGemakAddressForOrder($order);
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Gets an order's PakjeGemak address if available.
|
231 |
+
*
|
232 |
+
* @param Mage_Sales_Model_Order $order
|
233 |
+
*
|
234 |
+
* @return bool|Mage_Sales_Model_Order_Address
|
235 |
+
*/
|
236 |
+
public function getPakjeGemakAddressForOrder(Mage_Sales_Model_Order $order)
|
237 |
+
{
|
238 |
+
/**
|
239 |
+
* Check if this order was placed using PostNL.
|
240 |
+
*/
|
241 |
+
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
242 |
+
$shippingMethod = $order->getShippingMethod();
|
243 |
+
|
244 |
+
/**
|
245 |
+
* If this shipment's order was not placed with PostNL, we need to ignore any PakjeGemak addresses that may have
|
246 |
+
* been saved.
|
247 |
+
*/
|
248 |
+
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
249 |
+
return false;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* @var Mage_Sales_Model_Order_Address $address
|
254 |
+
*/
|
255 |
+
$addressCollection = $order->getAddressesCollection();
|
256 |
+
foreach ($addressCollection as $address) {
|
257 |
+
if ($address->getAddressType() == 'pakje_gemak') {
|
258 |
+
return $address;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
return false;
|
263 |
+
}
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Checks to see if the module may ship to the Netherlands using PostNL standard shipments.
|
267 |
Â
*
|
268 |
Â
* @param boolean|int $storeId
|
269 |
Â
*
|
285 |
Â
}
|
286 |
Â
|
287 |
Â
/**
|
288 |
+
* Checks to see if the module may ship using PakjeGemak.
|
289 |
Â
*
|
290 |
Â
* @param boolean|int $storeId
|
291 |
Â
*
|
386 |
Â
*/
|
387 |
Â
public function saveConfigState($configState = array())
|
388 |
Â
{
|
389 |
+
/**
|
390 |
+
* @var Mage_Admin_Model_User $adminUser
|
391 |
+
*/
|
392 |
Â
$adminUser = Mage::getSingleton('admin/session')->getUser();
|
393 |
Â
if (!$adminUser) {
|
394 |
Â
return false;
|
417 |
Â
return true;
|
418 |
Â
}
|
419 |
Â
|
420 |
+
/**
|
421 |
+
* Checks if the current admin user is allowed for the specified actions.
|
422 |
+
*
|
423 |
+
* @param array|string $actions
|
424 |
+
* @param boolean $throwException
|
425 |
+
*
|
426 |
+
* @throws TIG_PostNL_Exception
|
427 |
+
*
|
428 |
+
* @return bool
|
429 |
+
*/
|
430 |
+
public function checkIsPostnlActionAllowed($actions = array(), $throwException = false)
|
431 |
+
{
|
432 |
+
if (!is_array($actions)) {
|
433 |
+
$actions = array($actions);
|
434 |
+
}
|
435 |
+
|
436 |
+
foreach ($actions as $action) {
|
437 |
+
if ($this->_isActionAllowed($action)) {
|
438 |
+
continue;
|
439 |
+
}
|
440 |
+
|
441 |
+
if ($throwException) {
|
442 |
+
throw new TIG_PostNL_Exception(
|
443 |
+
$this->__('The current user is not allowed to perform this action.'),
|
444 |
+
'POSTNL-0155'
|
445 |
+
);
|
446 |
+
} else {
|
447 |
+
return false;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
|
451 |
+
return true;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Checks if a specified action is allowed for the current admin user.
|
456 |
+
*
|
457 |
+
* @param string $action
|
458 |
+
*
|
459 |
+
* @return bool
|
460 |
+
*/
|
461 |
+
protected function _isActionAllowed($action)
|
462 |
+
{
|
463 |
+
switch ($action) {
|
464 |
+
case 'create_shipment':
|
465 |
+
$aclPath = 'sales/order/actions/ship';
|
466 |
+
break;
|
467 |
+
case 'confirm':
|
468 |
+
$aclPath = 'postnl/shipment/actions/confirm';
|
469 |
+
break;
|
470 |
+
case 'print_label':
|
471 |
+
$aclPath = 'postnl/shipment/actions/print_label';
|
472 |
+
break;
|
473 |
+
case 'view_complete_status':
|
474 |
+
$aclPath = 'postnl/shipment/complete_status';
|
475 |
+
break;
|
476 |
+
case 'reset_confirmation':
|
477 |
+
$aclPath = 'postnl/shipment/actions/reset_confirmation';
|
478 |
+
break;
|
479 |
+
case 'delete_labels':
|
480 |
+
$aclPath = 'postnl/shipment/actions/delete_labels';
|
481 |
+
break;
|
482 |
+
case 'create_parcelware_export':
|
483 |
+
$aclPath = 'postnl/shipment/actions/create_parcelware_export';
|
484 |
+
break;
|
485 |
+
case 'send_track_and_trace':
|
486 |
+
$aclPath = 'postnl/shipment/actions/send_track_and_trace';
|
487 |
+
break;
|
488 |
+
default:
|
489 |
+
$aclPath = false;
|
490 |
+
break;
|
491 |
+
}
|
492 |
+
|
493 |
+
if (!$aclPath) {
|
494 |
+
return false;
|
495 |
+
}
|
496 |
+
|
497 |
+
$isAllowed = Mage::getSingleton('admin/session')->isAllowed($aclPath);
|
498 |
+
return $isAllowed;
|
499 |
+
}
|
500 |
+
|
501 |
Â
/**
|
502 |
Â
* Checks if GlobalPack may be used.
|
503 |
Â
*
|
537 |
Â
/**
|
538 |
Â
* Checks if test mode is currently allowed
|
539 |
Â
*
|
540 |
+
* @deprecated 1.2.0 Test mode is now always allowed, regardless of configuration. This method should therefore not
|
541 |
+
* be used anymore and may be removed in the future.
|
542 |
Â
*
|
543 |
Â
* @return boolean
|
544 |
Â
*/
|
550 |
Â
/**
|
551 |
Â
* Alias for isEnabled()
|
552 |
Â
*
|
553 |
+
* @param int|boolean $storeId
|
554 |
+
* @param boolean $checkGlobal
|
555 |
Â
* @param null|boolean $forceTestMode
|
556 |
Â
*
|
557 |
Â
* @return boolean
|
614 |
Â
return false;
|
615 |
Â
}
|
616 |
Â
|
617 |
+
/**
|
618 |
+
* Make sure that the required PHP extensions are loaded.
|
619 |
+
*/
|
620 |
+
$phpExtensionsLoaded = $this->areRequiredPHPExtensionsLoaded($registryKey);
|
621 |
+
if ($phpExtensionsLoaded === false) {
|
622 |
+
Mage::register($registryKey, false);
|
623 |
+
return false;
|
624 |
+
}
|
625 |
+
|
626 |
Â
/**
|
627 |
Â
* Check if the module's required configuration options have been filled
|
628 |
Â
*/
|
648 |
Â
);
|
649 |
Â
|
650 |
Â
$errorMessage = $this->__(
|
651 |
+
'The PostNL shipping method has not been enabled. You can enable the PostNL shipping method under '
|
652 |
+
. '%sSystem > Config > Shipping Methods%s.',
|
653 |
+
'<a href="'
|
654 |
+
. $shippingMethodSectionurl
|
655 |
+
. '" target="_blank" title="'
|
656 |
+
. $this->__('Shipping Methods')
|
657 |
+
. '">',
|
658 |
Â
'</a>'
|
659 |
Â
);
|
660 |
Â
|
689 |
Â
return true;
|
690 |
Â
}
|
691 |
Â
|
692 |
+
/**
|
693 |
+
* Check if the required SOAP, OpenSSL and MCrypt PHP extensions are loaded.
|
694 |
+
*
|
695 |
+
* @param string $registryKey
|
696 |
+
*
|
697 |
+
* @return bool
|
698 |
+
*/
|
699 |
+
public function areRequiredPHPExtensionsLoaded($registryKey)
|
700 |
+
{
|
701 |
+
$errors = array();
|
702 |
+
if (!extension_loaded('soap')) {
|
703 |
+
$errors[] = array(
|
704 |
+
'code' => 'POSTNL-0134',
|
705 |
+
'message' => $this->__(
|
706 |
+
'The SOAP extension is not installed. PostNL requires the SOAP extension to communicate with '
|
707 |
+
. 'PostNL.'
|
708 |
+
),
|
709 |
+
);
|
710 |
+
}
|
711 |
+
|
712 |
+
if (!extension_loaded('openssl')) {
|
713 |
+
$errors[] = array(
|
714 |
+
'code' => 'POSTNL-0135',
|
715 |
+
'message' => $this->__(
|
716 |
+
'The OpenSSL extension is not installed. The PostNL extension requires the OpenSSL extension to '
|
717 |
+
. 'secure the communications with the PostNL servers.'
|
718 |
+
),
|
719 |
+
);
|
720 |
+
}
|
721 |
+
|
722 |
+
if (!extension_loaded('mcrypt')) {
|
723 |
+
$errors[] = array(
|
724 |
+
'code' => 'POSTNL-0137',
|
725 |
+
'message' => $this->__(
|
726 |
+
'The MCrypt extension is not installed. The PostNL extension requires the MCrypt extension to '
|
727 |
+
. 'secure the communications with the PostNL servers.'
|
728 |
+
),
|
729 |
+
);
|
730 |
+
}
|
731 |
+
|
732 |
+
/**
|
733 |
+
* Register any errors that may have ocurred and return false.
|
734 |
+
*/
|
735 |
+
if (!empty($errors)) {
|
736 |
+
Mage::register($registryKey . '_errors', $errors);
|
737 |
+
|
738 |
+
return false;
|
739 |
+
}
|
740 |
+
|
741 |
+
return true;
|
742 |
+
}
|
743 |
+
|
744 |
Â
/**
|
745 |
Â
* Check if the modules has been confgured.
|
746 |
Â
* The required fields will only be checked to see if they're not empty. The values entered will not be validated
|
750 |
Â
* @param null|boolean $forceTestMode
|
751 |
Â
*
|
752 |
Â
* @return boolean
|
Â
|
|
Â
|
|
753 |
Â
*/
|
754 |
Â
public function isConfigured($storeId = false, $checkGlobal = false, $forceTestMode = null)
|
755 |
Â
{
|
812 |
Â
}
|
813 |
Â
|
814 |
Â
/**
|
815 |
+
* Check if each required field is filled. If not add the field's label to an array of missing fields so we can
|
816 |
+
* later inform the merchant which fields exactly are missing.
|
817 |
+
*
|
818 |
+
* @var Varien_Simplexml_Element $section
|
819 |
Â
*/
|
820 |
Â
$configFields = Mage::getSingleton('adminhtml/config');
|
821 |
Â
$sections = $configFields->getSections('postnl');
|
823 |
Â
foreach ($requiredFields as $requiredField) {
|
824 |
Â
$value = Mage::getStoreConfig($requiredField, $storeId);
|
825 |
Â
|
826 |
+
if ($value !== null && $value !== '') {
|
827 |
+
continue;
|
828 |
+
}
|
Â
|
|
829 |
Â
|
830 |
+
$fieldParts = explode('/', $requiredField);
|
831 |
+
$field = $fieldParts[2];
|
832 |
+
$group = $fieldParts[1];
|
833 |
Â
|
834 |
+
/**
|
835 |
+
* @var Varien_Simplexml_Element $sectionGroup
|
836 |
+
*/
|
837 |
+
$sectionGroup = $section->groups->$group;
|
838 |
Â
|
839 |
+
$label = (string) $sectionGroup->fields->$field->label;
|
840 |
+
$groupLabel = (string) $sectionGroup->label;
|
841 |
+
$groupName = $sectionGroup->getName();
|
842 |
+
|
843 |
+
$errors[] = array(
|
844 |
+
'code' => 'POSTNL-0034',
|
845 |
+
'message' => $this->__('%s > %s is required.', $this->__($groupLabel), $this->__($label)),
|
846 |
+
);
|
847 |
+
|
848 |
+
$this->saveConfigState(array('postnl_' . $groupName => 1));
|
849 |
Â
}
|
850 |
Â
|
851 |
Â
/**
|
897 |
Â
* Based on Mage_Core_Model_Config::getModuleDir()
|
898 |
Â
*
|
899 |
Â
* @param string $dir The directory in question
|
900 |
+
* @param string $moduleName
|
901 |
Â
*
|
902 |
Â
* @return string
|
903 |
Â
*
|
904 |
+
* @see Mage_Core_Model_Config::getModuleDir()
|
905 |
Â
*/
|
906 |
Â
public function getModuleDir($dir, $moduleName = 'TIG_PostNL')
|
907 |
Â
{
|
908 |
Â
$config = Mage::app()->getConfig();
|
909 |
Â
|
910 |
+
/**
|
911 |
+
* @var Varien_Simplexml_Element $moduleConfig
|
912 |
+
*/
|
913 |
+
$moduleConfig = $config->getModuleConfig($moduleName);
|
914 |
+
$codePool = (string) $moduleConfig->codePool;
|
915 |
Â
$path = $config->getOptions()->getCodeDir()
|
916 |
Â
. DS
|
917 |
Â
. $codePool
|
947 |
Â
}
|
948 |
Â
|
949 |
Â
/**
|
950 |
+
* Logs a debug message. Based on Mage::log.
|
951 |
Â
*
|
952 |
+
* @param string $message
|
953 |
+
* @param int|null $level
|
954 |
+
* @param string|null $file
|
955 |
+
* @param boolean $forced
|
956 |
+
* @param boolean $isError
|
957 |
Â
*
|
958 |
Â
* @return TIG_PostNL_Helper_Data
|
959 |
Â
*
|
986 |
Â
* Logs a cron debug messageto a seperate file in order to differentiate it from other debug messages
|
987 |
Â
*
|
988 |
Â
* @param string $message
|
989 |
+
* @param int $level
|
990 |
Â
*
|
991 |
Â
* @return TIG_PostNL_Helper_Data
|
992 |
Â
*
|
1030 |
Â
}
|
1031 |
Â
|
1032 |
Â
/**
|
1033 |
+
* Checks if the current edition of Magento is enterprise. Uses Mage::getEdition if available. If not, look for the
|
1034 |
+
* Enterprise_Enterprise extension. Finally, check the version number.
|
1035 |
Â
*
|
1036 |
Â
* @return boolean
|
1037 |
Â
*
|
1040 |
Â
public function isEnterprise()
|
1041 |
Â
{
|
1042 |
Â
/**
|
1043 |
+
* Use Mage::getEdition, which is available since CE 1.7 and EE 1.12.
|
1044 |
Â
*/
|
1045 |
Â
if (method_exists('Mage', 'getEdition')) {
|
1046 |
Â
$edition = Mage::getEdition();
|
1053 |
Â
}
|
1054 |
Â
|
1055 |
Â
/**
|
1056 |
+
* If the edition is not community or enterprise, it is not supported.
|
1057 |
Â
*/
|
1058 |
Â
throw new TIG_PostNL_Exception(
|
1059 |
Â
$this->__('Invalid Magento edition detected: %s', $edition),
|
1062 |
Â
}
|
1063 |
Â
|
1064 |
Â
/**
|
1065 |
+
* Check if the Enterprise_Enterprise extension is installed.
|
1066 |
+
*/
|
1067 |
+
if (Mage::getConfig()->getNode('modules')->Enterprise_Enterprise) {
|
1068 |
+
return true;
|
1069 |
+
}
|
1070 |
+
|
1071 |
+
/**
|
1072 |
+
* Do a version check instead.
|
1073 |
Â
*/
|
1074 |
Â
$version = Mage::getVersion();
|
1075 |
+
if (version_compare($version, '1.9.0.0', '>=')) {
|
1076 |
Â
return true;
|
1077 |
Â
}
|
1078 |
Â
|
1091 |
Â
}
|
1092 |
Â
|
1093 |
Â
/**
|
1094 |
+
* Fallback check in case the previous check returns a false negative.
|
1095 |
Â
*/
|
1096 |
Â
if (Mage::getDesign()->getArea() == 'adminhtml') {
|
1097 |
Â
return true;
|
1118 |
Â
}
|
1119 |
Â
|
1120 |
Â
/**
|
1121 |
+
* Gets the knowledge base URL for a specified error code. First we check to see if we have an entry in config.xml
|
1122 |
+
* for this error code and if so, if it has an associated URL.
|
1123 |
Â
*
|
1124 |
Â
* @param string $errorCode The error code (for example: POSTNL-0001)
|
1125 |
Â
*
|
1136 |
Â
}
|
1137 |
Â
|
1138 |
Â
/**
|
1139 |
+
* Adds an error message to the specified session based on an exception. The exception should contain a valid error
|
1140 |
+
* code in order to properly process the error. Exceptions without a (valid) error code will behave like a regular
|
1141 |
Â
* $session->addError() call.
|
1142 |
Â
*
|
1143 |
Â
* @param string|Mage_Core_Model_Session_Abstract $session The session to which the messages will be added.
|
1197 |
Â
|
1198 |
Â
/**
|
1199 |
Â
* Add a message to the specified session. Message can be an error, a success message, an info message or a warning.
|
1200 |
+
* If a valid error code is supplied, the message will be prepended with the error code and a link to a
|
1201 |
+
* knowledgebase article will be appended.
|
1202 |
Â
*
|
1203 |
Â
* If no $code is specified, $messageType and $message will be required
|
1204 |
Â
*
|
1216 |
Â
*/
|
1217 |
Â
public function addSessionMessage($session, $code = null, $messageType = null, $message = null)
|
1218 |
Â
{
|
1219 |
+
/***************************************************************************************************************
|
1220 |
Â
* Check that the required arguments are available and valid
|
1221 |
+
**************************************************************************************************************/
|
1222 |
Â
|
1223 |
Â
/**
|
1224 |
Â
* If $code is null or 0, $messageType and $message are required
|
1235 |
Â
/**
|
1236 |
Â
* If the session is a string, treat it as a class name and instantiate it
|
1237 |
Â
*/
|
1238 |
+
if (is_string($session) && strpos($session, '/') !== false) {
|
1239 |
Â
$session = Mage::getSingleton($session);
|
1240 |
+
} elseif (is_string($session)) {
|
1241 |
+
$session = Mage::getSingleton($session . '/session');
|
1242 |
Â
}
|
1243 |
Â
|
1244 |
Â
/**
|
1254 |
Â
);
|
1255 |
Â
}
|
1256 |
Â
|
1257 |
+
/***************************************************************************************************************
|
1258 |
Â
* Get the actual error from config.xml if it's available
|
1259 |
+
**************************************************************************************************************/
|
1260 |
Â
|
1261 |
Â
$error = false;
|
1262 |
Â
$link = false;
|
1271 |
Â
}
|
1272 |
Â
}
|
1273 |
Â
|
1274 |
+
/***************************************************************************************************************
|
1275 |
+
* Check that the required 'message' and 'messageType' components are available. If they are not yet available,
|
1276 |
+
* we'll try to read them from the error itself.
|
1277 |
+
**************************************************************************************************************/
|
1278 |
Â
|
1279 |
Â
/**
|
1280 |
Â
* If the specified error was found and no message was supplied, get the error's default message
|
1311 |
Â
);
|
1312 |
Â
}
|
1313 |
Â
|
1314 |
+
/***************************************************************************************************************
|
1315 |
+
* Build the actual message we're going to add. The message will consist of the error code, followed by the
|
1316 |
+
* actual message and finally a link to the knowledge base. Only the message part is required.
|
1317 |
+
**************************************************************************************************************/
|
1318 |
Â
|
1319 |
Â
/**
|
1320 |
Â
* Flag that determines whether the error code and knowledgebase link will be included in the error message
|
1336 |
Â
/**
|
1337 |
Â
* Add the actual message. This is the only required part. The code and link are optional
|
1338 |
Â
*/
|
1339 |
+
$errorMessage .= $this->escapeHtml($this->__($message));
|
1340 |
Â
|
1341 |
Â
/**
|
1342 |
Â
* Add the link to the knowledgebase if we have one
|
1343 |
Â
*/
|
1344 |
Â
if ($canShowErrorDetails && $link) {
|
1345 |
Â
$errorMessage .= ' <a href="'
|
1346 |
+
. $this->escapeHtml($link)
|
1347 |
Â
. '" target="_blank" class="postnl-message">'
|
1348 |
Â
. $this->__('Click here for more information from the TiG knowledgebase.')
|
1349 |
Â
. '</a>';
|
1350 |
Â
}
|
1351 |
Â
|
1352 |
+
/***************************************************************************************************************
|
1353 |
Â
* Finally, let's add the error to the session
|
1354 |
+
**************************************************************************************************************/
|
1355 |
Â
|
1356 |
Â
/**
|
1357 |
Â
* The method we'll use to add the message to the session has to be built first
|
1377 |
Â
}
|
1378 |
Â
|
1379 |
Â
/**
|
1380 |
+
* Checks to see if we can show error details (error code and knowledgebase link) in the frontend when an error
|
1381 |
+
* occurs.
|
1382 |
Â
*
|
1383 |
Â
* @return boolean
|
1384 |
Â
*/
|
@@ -0,0 +1,739 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Helper_DeliveryOptions extends TIG_PostNL_Helper_Checkout
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Xpath to delivery options enabled config setting.
|
43 |
+
*/
|
44 |
+
const XPATH_DELIVERY_OPTIONS_ACTIVE = 'postnl/delivery_options/delivery_options_active';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Xpaths to various possible delivery option settings.
|
48 |
+
*/
|
49 |
+
const XPATH_ENABLE_PAKJEGEMAK = 'postnl/delivery_options/enable_pakjegemak';
|
50 |
+
const XPATH_ENABLE_PAKJEGEMAK_EXPRESS = 'postnl/delivery_options/enable_pakjegemak_express';
|
51 |
+
const XPATH_ENABLE_PAKKETAUTOMAAT_LOCATIONS = 'postnl/delivery_options/enable_pakketautomaat_locations';
|
52 |
+
const XPATH_ENABLE_TIMEFRAMES = 'postnl/delivery_options/enable_timeframes';
|
53 |
+
const XPATH_ENABLE_EVENING_TIMEFRAMES = 'postnl/delivery_options/enable_evening_timeframes';
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Xpaths to various business rule settings.
|
57 |
+
*/
|
58 |
+
const XPATH_SHOW_OPTIONS_FOR_LETTER = 'postnl/delivery_options/show_options_for_letter';
|
59 |
+
const XPATH_SHOW_OPTIONS_FOR_BACKORDERS = 'postnl/delivery_options/show_options_for_backorders';
|
60 |
+
const XPATH_ALLOW_SUNDAY_SORTING = 'postnl/delivery_options/allow_sunday_sorting';
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Xpaths to extra fee config settings.
|
64 |
+
*/
|
65 |
+
const XPATH_EVENING_TIMEFRAME_FEE = 'postnl/delivery_options/evening_timeframe_fee';
|
66 |
+
const XPATH_PAKJEGEMAK_EXPRESS_FEE = 'postnl/delivery_options/pakjegemak_express_fee';
|
67 |
+
/**
|
68 |
+
* Xpath for shipping duration setting.
|
69 |
+
*/
|
70 |
+
const XPATH_SHIPPING_DURATION = 'postnl/delivery_options/shipping_duration';
|
71 |
+
|
72 |
+
/**
|
73 |
+
* The time (as H * 100 + i) we consider to be the start of the evening.
|
74 |
+
*/
|
75 |
+
const EVENING_TIME = 1900;
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @var array
|
79 |
+
*/
|
80 |
+
protected $_validTypes = array(
|
81 |
+
'Overdag',
|
82 |
+
'Avond',
|
83 |
+
'PG',
|
84 |
+
'PGE',
|
85 |
+
'PA',
|
86 |
+
);
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @var Mage_Sales_Model_Quote
|
90 |
+
*/
|
91 |
+
protected $_quote;
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @return array
|
95 |
+
*/
|
96 |
+
public function getValidTypes()
|
97 |
+
{
|
98 |
+
return $this->_validTypes;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @return Mage_Sales_Model_Quote
|
103 |
+
*/
|
104 |
+
public function getQuote()
|
105 |
+
{
|
106 |
+
if ($this->_quote) {
|
107 |
+
return $this->_quote;
|
108 |
+
}
|
109 |
+
|
110 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
111 |
+
|
112 |
+
$this->_quote = $quote;
|
113 |
+
return $quote;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Get the fee charged for evening timeframes.
|
118 |
+
*
|
119 |
+
* @param boolean $formatted
|
120 |
+
* @param boolean $includingTax
|
121 |
+
*
|
122 |
+
* @return float
|
123 |
+
*/
|
124 |
+
public function getEveningFee($formatted = false, $includingTax = true)
|
125 |
+
{
|
126 |
+
$storeId = Mage::app()->getStore()->getId();
|
127 |
+
|
128 |
+
$eveningFee = (float) Mage::getStoreConfig(self::XPATH_EVENING_TIMEFRAME_FEE, $storeId);
|
129 |
+
|
130 |
+
$price = $this->getPriceWithTax($eveningFee, $includingTax, $formatted);
|
131 |
+
|
132 |
+
return $price;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Get the fee charged for PakjeGemak Express.
|
137 |
+
*
|
138 |
+
* @param boolean $formatted
|
139 |
+
* @param boolean $includingTax
|
140 |
+
*
|
141 |
+
* @return float
|
142 |
+
*/
|
143 |
+
public function getExpressFee($formatted = false, $includingTax = true)
|
144 |
+
{
|
145 |
+
$storeId = Mage::app()->getStore()->getId();
|
146 |
+
|
147 |
+
$expressFee = (float) Mage::getStoreConfig(self::XPATH_PAKJEGEMAK_EXPRESS_FEE, $storeId);
|
148 |
+
|
149 |
+
$price = $this->getPriceWithTax($expressFee, $includingTax, $formatted);
|
150 |
+
|
151 |
+
return $price;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Get the Shipping date for a specified order date.
|
156 |
+
*
|
157 |
+
* @param null|string $orderDate
|
158 |
+
* @param null|int $storeId
|
159 |
+
*
|
160 |
+
* @return bool|string
|
161 |
+
*/
|
162 |
+
public function getShippingDate($orderDate = null, $storeId = null)
|
163 |
+
{
|
164 |
+
if ($orderDate === null) {
|
165 |
+
$orderDate = date('Y-m-d');
|
166 |
+
}
|
167 |
+
|
168 |
+
if ($storeId === null) {
|
169 |
+
$storeId = Mage::app()->getStore()->getId();
|
170 |
+
}
|
171 |
+
|
172 |
+
$shippingDuration = Mage::getStoreConfig(self::XPATH_SHIPPING_DURATION, $storeId);
|
173 |
+
$deliveryTime = strtotime("+{$shippingDuration} days", strtotime($orderDate));
|
174 |
+
$deliveryDay = date('N', $deliveryTime);
|
175 |
+
|
176 |
+
if ($deliveryDay == 1 && !Mage::helper('postnl/deliveryOptions')->canUseSundaySorting()) {
|
177 |
+
$deliveryTime = strtotime('+1 day', $deliveryTime);
|
178 |
+
}
|
179 |
+
|
180 |
+
$deliveryDate = date('Y-m-d', $deliveryTime);
|
181 |
+
return $deliveryDate;
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Gets the shipping duration for the specified quote.
|
186 |
+
*
|
187 |
+
* @param Mage_Sales_Model_Quote $quote
|
188 |
+
*
|
189 |
+
* @return int
|
190 |
+
*
|
191 |
+
* @throws TIG_PostNL_Exception
|
192 |
+
*/
|
193 |
+
public function getShippingDuration(Mage_Sales_Model_Quote $quote)
|
194 |
+
{
|
195 |
+
$storeId = $quote->getStoreId();
|
196 |
+
|
197 |
+
/**
|
198 |
+
* Get the default config duration.
|
199 |
+
*/
|
200 |
+
$configDuration = (int) Mage::getStoreConfig(self::XPATH_SHIPPING_DURATION, $storeId);
|
201 |
+
$durationArray = array($configDuration);
|
202 |
+
|
203 |
+
/**
|
204 |
+
* Loop through all products in the quote.
|
205 |
+
*
|
206 |
+
* @var Mage_Sales_Model_Quote_Item $item
|
207 |
+
*/
|
208 |
+
foreach ($quote->getAllVisibleItems() as $item) {
|
209 |
+
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
210 |
+
|
211 |
+
/**
|
212 |
+
* If the product has a specific shipping duration, add it to the array of durations.
|
213 |
+
*/
|
214 |
+
if ($product->hasPostnlShippingDuration() && $product->getPostnlShippingDuration() !== '') {
|
215 |
+
$durationArray[] = (int) $product->getPostnlShippingDuration();
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Sort the array and get it's last item. This will be the highest value.
|
221 |
+
*/
|
222 |
+
natsort($durationArray);
|
223 |
+
$shippingDuration = end($durationArray);
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Make sure the value is between 1 and 14 days.
|
227 |
+
*/
|
228 |
+
if ($shippingDuration > 14 || $shippingDuration < 1) {
|
229 |
+
throw new TIG_PostNL_Exception(
|
230 |
+
Mage::helper('postnl')->__(
|
231 |
+
'Invalid shipping duration: %s. Shipping duration must be between 1 and 14 days.',
|
232 |
+
$shippingDuration
|
233 |
+
),
|
234 |
+
'POSTNL-0127'
|
235 |
+
);
|
236 |
+
}
|
237 |
+
|
238 |
+
return $shippingDuration;
|
239 |
+
}
|
240 |
+
|
241 |
+
/**
|
242 |
+
* Convert a value to a formatted price.
|
243 |
+
*
|
244 |
+
* @param float $price
|
245 |
+
* @param boolean $includingTax
|
246 |
+
* @param boolean $formatted
|
247 |
+
*
|
248 |
+
* @return float
|
249 |
+
*
|
250 |
+
* @see Mage_Checkout_Block_Onepage_Shipping_Method_Available::getShippingPrice()
|
251 |
+
*/
|
252 |
+
public function getPriceWithTax($price, $includingTax, $formatted = false)
|
253 |
+
{
|
254 |
+
$quote = $this->getQuote();
|
255 |
+
$store = $quote->getStore();
|
256 |
+
|
257 |
+
$shippingPrice = Mage::helper('tax')->getShippingPrice($price, $includingTax, $quote->getShippingAddress());
|
258 |
+
$convertedPrice = $store->convertPrice($shippingPrice, $formatted, false);
|
259 |
+
|
260 |
+
return $convertedPrice;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Mark a set of location results with the 'isEvening' parameter. This will allow the google maps api to easily
|
265 |
+
* identify which locations may be filtered out later.
|
266 |
+
*
|
267 |
+
* @param array $locations An array of PostNL location objects
|
268 |
+
* @param string $deliveryDate The date on which the package should be delivered.
|
269 |
+
*
|
270 |
+
* @return array
|
271 |
+
*/
|
272 |
+
public function markEveningLocations($locations, $deliveryDate)
|
273 |
+
{
|
274 |
+
/**
|
275 |
+
* Get the day of the week on which the package should be delivered.
|
276 |
+
*
|
277 |
+
* date('l') returns the full textual representation of the day of the week (Sunday through Saturday).
|
278 |
+
*/
|
279 |
+
$weekDay = date('l', strtotime($deliveryDate));
|
280 |
+
|
281 |
+
foreach ($locations as &$location) {
|
282 |
+
/**
|
283 |
+
* if we don't have any business hours specified for this date, the location is closed.
|
284 |
+
*/
|
285 |
+
if (!isset($location->OpeningHours->$weekDay->string)) {
|
286 |
+
$location->isEvening = false;
|
287 |
+
|
288 |
+
continue;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Check if the location is open in the evening and mark it accordingly.
|
293 |
+
*/
|
294 |
+
$businessHours = $location->OpeningHours->$weekDay->string;
|
295 |
+
if ($this->_businessHoursIsEvening($businessHours)) {
|
296 |
+
$location->isEvening = true;
|
297 |
+
|
298 |
+
continue;
|
299 |
+
}
|
300 |
+
|
301 |
+
$location->isEvening = false;
|
302 |
+
|
303 |
+
continue;
|
304 |
+
}
|
305 |
+
|
306 |
+
return $locations;
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Check if an array of business hours contains a timespan that is condiered to be in the evening.
|
311 |
+
*
|
312 |
+
* @param array $businessHours
|
313 |
+
*
|
314 |
+
* @return bool
|
315 |
+
*/
|
316 |
+
protected function _businessHoursIsEvening($businessHours)
|
317 |
+
{
|
318 |
+
foreach ($businessHours as $businessHour) {
|
319 |
+
if ($this->_isEvening($businessHour)) {
|
320 |
+
return true;
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
return false;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Check if a specified opening time is considered to be in the evening. Opening times must be formatted as
|
329 |
+
* H:i-H:i. The second part of the time (the closing time) will be compared to the self::EVENING_TIME constant to
|
330 |
+
* find out if it's in the evening.
|
331 |
+
*
|
332 |
+
* @param $time
|
333 |
+
*
|
334 |
+
* @return bool
|
335 |
+
*/
|
336 |
+
protected function _isEvening($time)
|
337 |
+
{
|
338 |
+
$timeParts = explode('-', $time);
|
339 |
+
|
340 |
+
if (!isset($timeParts[1])) {
|
341 |
+
return false;
|
342 |
+
}
|
343 |
+
|
344 |
+
$closingTime = str_replace(':', '', $timeParts[1]);
|
345 |
+
|
346 |
+
if ($closingTime >= self::EVENING_TIME) {
|
347 |
+
return true;
|
348 |
+
}
|
349 |
+
|
350 |
+
return false;
|
351 |
+
}
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Checks if PakjeGemak is available.
|
355 |
+
*
|
356 |
+
* @param int|boolean $storeId
|
357 |
+
*
|
358 |
+
* @return boolean
|
359 |
+
*/
|
360 |
+
public function canUsePakjeGemak($storeId = false)
|
361 |
+
{
|
362 |
+
if ($storeId === false) {
|
363 |
+
$storeId = Mage::app()->getStore()->getId();
|
364 |
+
}
|
365 |
+
|
366 |
+
$enabled = Mage::getStoreConfigFlag(self::XPATH_ENABLE_PAKJEGEMAK, $storeId);
|
367 |
+
if (!$enabled) {
|
368 |
+
return false;
|
369 |
+
}
|
370 |
+
|
371 |
+
$canUsePakjeGemak = parent::canUsePakjeGemak($storeId);
|
372 |
+
|
373 |
+
return $canUsePakjeGemak;
|
374 |
+
}
|
375 |
+
|
376 |
+
/**
|
377 |
+
* Checks if PakjeGemak Express is available.
|
378 |
+
*
|
379 |
+
* @param int|boolean $storeId
|
380 |
+
*
|
381 |
+
* @return boolean
|
382 |
+
*/
|
383 |
+
public function canUsePakjeGemakExpress($storeId = false)
|
384 |
+
{
|
385 |
+
if ($storeId === false) {
|
386 |
+
$storeId = Mage::app()->getStore()->getId();
|
387 |
+
}
|
388 |
+
|
389 |
+
if (!$this->canUsePakjeGemak($storeId)) {
|
390 |
+
return false;
|
391 |
+
}
|
392 |
+
|
393 |
+
$enabled = Mage::getStoreConfigFlag(self::XPATH_ENABLE_PAKJEGEMAK_EXPRESS, $storeId);
|
394 |
+
if (!$enabled) {
|
395 |
+
return false;
|
396 |
+
}
|
397 |
+
|
398 |
+
$pgeOptions = Mage::getModel('postnl_core/system_config_source_pakjeGemakProductOptions')
|
399 |
+
->getAvailablePgeOptions($storeId);
|
400 |
+
|
401 |
+
if (empty($pgeOptions)) {
|
402 |
+
return false;
|
403 |
+
}
|
404 |
+
|
405 |
+
return true;
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* Checks if 'pakket automaat' is available.
|
410 |
+
*
|
411 |
+
* @param int|boolean $storeId
|
412 |
+
*
|
413 |
+
* @return boolean
|
414 |
+
*/
|
415 |
+
public function canUsePakketAutomaat($storeId = false)
|
416 |
+
{
|
417 |
+
if ($storeId === false) {
|
418 |
+
$storeId = Mage::app()->getStore()->getId();
|
419 |
+
}
|
420 |
+
|
421 |
+
$enabled = Mage::getStoreConfigFlag(self::XPATH_ENABLE_PAKKETAUTOMAAT_LOCATIONS, $storeId);
|
422 |
+
if (!$enabled) {
|
423 |
+
return false;
|
424 |
+
}
|
425 |
+
|
426 |
+
$pakketautomaatOptions = Mage::getModel('postnl_core/system_config_source_pakketautomaatProductOptions')
|
427 |
+
->getAvailableOptions($storeId);
|
428 |
+
|
429 |
+
if (empty($pakketautomaatOptions)) {
|
430 |
+
return false;
|
431 |
+
}
|
432 |
+
|
433 |
+
return true;
|
434 |
+
}
|
435 |
+
|
436 |
+
/**
|
437 |
+
* Checks if timeframes are available.
|
438 |
+
*
|
439 |
+
* @param int|boolean $storeId
|
440 |
+
*
|
441 |
+
* @return boolean
|
442 |
+
*/
|
443 |
+
public function canUseTimeframes($storeId = false)
|
444 |
+
{
|
445 |
+
if ($storeId === false) {
|
446 |
+
$storeId = Mage::app()->getStore()->getId();
|
447 |
+
}
|
448 |
+
|
449 |
+
$enabled = Mage::getStoreConfigFlag(self::XPATH_ENABLE_TIMEFRAMES, $storeId);
|
450 |
+
|
451 |
+
return $enabled;
|
452 |
+
}
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Checks if evening timeframes are available.
|
456 |
+
*
|
457 |
+
* @param int|boolean $storeId
|
458 |
+
*
|
459 |
+
* @return boolean
|
460 |
+
*/
|
461 |
+
public function canUseEveningTimeframes($storeId = false)
|
462 |
+
{
|
463 |
+
if ($storeId === false) {
|
464 |
+
$storeId = Mage::app()->getStore()->getId();
|
465 |
+
}
|
466 |
+
|
467 |
+
if (!$this->canUseTimeframes($storeId)) {
|
468 |
+
return false;
|
469 |
+
}
|
470 |
+
|
471 |
+
$enabled = Mage::getStoreConfigFlag(self::XPATH_ENABLE_EVENING_TIMEFRAMES, $storeId);
|
472 |
+
if (!$enabled) {
|
473 |
+
return false;
|
474 |
+
}
|
475 |
+
|
476 |
+
$eveningOptions = Mage::getModel('postnl_core/system_config_source_standardProductOptions')
|
477 |
+
->getAvailableAvondOptions($storeId);
|
478 |
+
|
479 |
+
if (empty($eveningOptions)) {
|
480 |
+
return false;
|
481 |
+
}
|
482 |
+
|
483 |
+
return true;
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Checks if sunday sorting is allowed.
|
488 |
+
*
|
489 |
+
* @param bool $storeId
|
490 |
+
*
|
491 |
+
* @return bool
|
492 |
+
*/
|
493 |
+
public function canUseSundaySorting($storeId = false)
|
494 |
+
{
|
495 |
+
if ($storeId === false) {
|
496 |
+
$storeId = Mage::app()->getStore()->getId();
|
497 |
+
}
|
498 |
+
|
499 |
+
$allowed = Mage::getStoreConfigFlag(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
500 |
+
|
501 |
+
return $allowed;
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Check if PostNL delivery options may be used based on a quote.
|
506 |
+
*
|
507 |
+
* @param Mage_Sales_Model_Quote|boolean $quote
|
508 |
+
* @param boolean $checkCountry
|
509 |
+
*
|
510 |
+
* @return boolean
|
511 |
+
*/
|
512 |
+
public function canUseDeliveryOptions($quote = false, $checkCountry = true)
|
513 |
+
{
|
514 |
+
$registryKey = 'can_use_delivery_options';
|
515 |
+
if ($quote) {
|
516 |
+
$registryKey .= '_quote_id_' . $quote->getId();
|
517 |
+
}
|
518 |
+
|
519 |
+
if ($checkCountry) {
|
520 |
+
$registryKey .= '_check_country';
|
521 |
+
}
|
522 |
+
|
523 |
+
if (Mage::registry($registryKey) !== null) {
|
524 |
+
return Mage::registry($registryKey);
|
525 |
+
}
|
526 |
+
|
527 |
+
Mage::unregister('postnl_enabled_delivery_options_errors');
|
528 |
+
|
529 |
+
$deliveryOptionsEnabled = $this->isDeliveryOptionsEnabled();
|
530 |
+
if (!$deliveryOptionsEnabled) {
|
531 |
+
Mage::register($registryKey, false);
|
532 |
+
return false;
|
533 |
+
}
|
534 |
+
|
535 |
+
/**
|
536 |
+
* PostNL delivery options cannot be used for virtual orders
|
537 |
+
*/
|
538 |
+
if ($quote && $quote->isVirtual()) {
|
539 |
+
$errors = array(
|
540 |
+
array(
|
541 |
+
'code' => 'POSTNL-0104',
|
542 |
+
'message' => $this->__('The quote is virtual.'),
|
543 |
+
)
|
544 |
+
);
|
545 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
546 |
+
Mage::register($registryKey, false);
|
547 |
+
return false;
|
548 |
+
}
|
549 |
+
|
550 |
+
/**
|
551 |
+
* Check if the quote has a valid minimum amount
|
552 |
+
*/
|
553 |
+
if ($quote && !$quote->validateMinimumAmount()) {
|
554 |
+
$errors = array(
|
555 |
+
array(
|
556 |
+
'code' => 'POSTNL-0105',
|
557 |
+
'message' => $this->__("The quote's grand total is below the minimum amount required."),
|
558 |
+
)
|
559 |
+
);
|
560 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
561 |
+
Mage::register($registryKey, false);
|
562 |
+
return false;
|
563 |
+
}
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Check that dutch addresses are allowed
|
567 |
+
*/
|
568 |
+
if (!$this->canUseStandard()) {
|
569 |
+
$errors = array(
|
570 |
+
array(
|
571 |
+
'code' => 'POSTNL-0106',
|
572 |
+
'message' => $this->__(
|
573 |
+
'No standard product options are enabled. At least 1 option must be active.'
|
574 |
+
),
|
575 |
+
)
|
576 |
+
);
|
577 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
578 |
+
Mage::register($registryKey, false);
|
579 |
+
return false;
|
580 |
+
}
|
581 |
+
|
582 |
+
if ($quote && $checkCountry) {
|
583 |
+
$shippingAddress = $quote->getShippingAddress();
|
584 |
+
if ($shippingAddress->getCountry() != 'NL') {
|
585 |
+
$errors = array(
|
586 |
+
array(
|
587 |
+
'code' => 'POSTNL-0132',
|
588 |
+
'message' => $this->__(
|
589 |
+
'PostNL delivery options are only available for Dutch shipping addresses.'
|
590 |
+
),
|
591 |
+
)
|
592 |
+
);
|
593 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
594 |
+
Mage::register($registryKey, false);
|
595 |
+
return false;
|
596 |
+
}
|
597 |
+
}
|
598 |
+
|
599 |
+
/**
|
600 |
+
* If we have no quote, we have no further checks to perform.
|
601 |
+
*/
|
602 |
+
if (!$quote) {
|
603 |
+
Mage::register($registryKey, true);
|
604 |
+
return true;
|
605 |
+
}
|
606 |
+
|
607 |
+
$storeId = $quote->getStoreId();
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Check if PostNL delivery options may be used for 'letter' orders and if not, if the quote could fit in an
|
611 |
+
* envelope.
|
612 |
+
*/
|
613 |
+
$showDeliveryOptionsForLetters = Mage::getStoreConfigFlag(self::XPATH_SHOW_OPTIONS_FOR_LETTER, $storeId);
|
614 |
+
if (!$showDeliveryOptionsForLetters) {
|
615 |
+
$isLetterQuote = $this->quoteIsLetter($quote, $storeId);
|
616 |
+
if ($isLetterQuote) {
|
617 |
+
$errors = array(
|
618 |
+
array(
|
619 |
+
'code' => 'POSTNL-0150',
|
620 |
+
'message' => $this->__(
|
621 |
+
"The quote's total weight is below the miniumum required to use PostNL delivery options."
|
622 |
+
),
|
623 |
+
)
|
624 |
+
);
|
625 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
626 |
+
Mage::register($registryKey, false);
|
627 |
+
return false;
|
628 |
+
}
|
629 |
+
}
|
630 |
+
|
631 |
+
/**
|
632 |
+
* Check if PostNL delivery options may be used for out-og-stock orders and if not, whether the quote has any
|
633 |
+
* such products.
|
634 |
+
*/
|
635 |
+
$showDeliveryOptionsForBackorders = Mage::getStoreConfigFlag(self::XPATH_SHOW_OPTIONS_FOR_BACKORDERS, $storeId);
|
636 |
+
if (!$showDeliveryOptionsForBackorders) {
|
637 |
+
$containsOutOfStockItems = $this->quoteHasOutOfStockItems($quote);
|
638 |
+
if ($containsOutOfStockItems) {
|
639 |
+
$errors = array(
|
640 |
+
array(
|
641 |
+
'code' => 'POSTNL-0102',
|
642 |
+
'message' => $this->__('One or more items in the cart are out of stock.'),
|
643 |
+
)
|
644 |
+
);
|
645 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
646 |
+
Mage::register($registryKey, false);
|
647 |
+
return false;
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
Mage::register($registryKey, true);
|
652 |
+
return true;
|
653 |
+
}
|
654 |
+
|
655 |
+
/**
|
656 |
+
* Check if the module is set to test mode
|
657 |
+
*
|
658 |
+
* @param bool $storeId
|
659 |
+
*
|
660 |
+
* @return boolean
|
661 |
+
*/
|
662 |
+
public function isTestMode($storeId = false)
|
663 |
+
{
|
664 |
+
if (Mage::registry('delivery_options_test_mode') !== null) {
|
665 |
+
return Mage::registry('delivery_options_test_mode');
|
666 |
+
}
|
667 |
+
|
668 |
+
if ($storeId === false) {
|
669 |
+
$storeId = Mage::app()->getStore()->getId();
|
670 |
+
}
|
671 |
+
|
672 |
+
$testMode = Mage::getStoreConfigFlag(self::XML_PATH_TEST_MODE, $storeId);
|
673 |
+
|
674 |
+
Mage::register('delivery_options_test_mode', $testMode);
|
675 |
+
return $testMode;
|
676 |
+
}
|
677 |
+
|
678 |
+
/**
|
679 |
+
* Checks if PostNL delivery options are enabled.
|
680 |
+
*
|
681 |
+
* @param null|int $storeId
|
682 |
+
*
|
683 |
+
* @return boolean
|
684 |
+
*/
|
685 |
+
public function isDeliveryOptionsEnabled($storeId = null)
|
686 |
+
{
|
687 |
+
if (is_null($storeId)) {
|
688 |
+
$storeId = Mage::app()->getStore()->getId();
|
689 |
+
}
|
690 |
+
|
691 |
+
if (Mage::registry('postnl_enabled_delivery_options_errors')) {
|
692 |
+
Mage::unregister('postnl_enabled_delivery_options_errors');
|
693 |
+
}
|
694 |
+
|
695 |
+
$isPostnlEnabled = $this->isEnabled($storeId, false, $this->isTestMode());
|
696 |
+
if ($isPostnlEnabled === false) {
|
697 |
+
$errors = array(
|
698 |
+
array(
|
699 |
+
'code' => 'POSTNL-0107',
|
700 |
+
'message' => $this->__('You have not yet enabled the PostNL extension.'),
|
701 |
+
)
|
702 |
+
);
|
703 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
704 |
+
return false;
|
705 |
+
}
|
706 |
+
|
707 |
+
$isDeliveryOptionsActive = $this->isDeliveryOptionsActive($storeId);
|
708 |
+
if (!$isDeliveryOptionsActive) {
|
709 |
+
$errors = array(
|
710 |
+
array(
|
711 |
+
'code' => 'POSTNL-0133',
|
712 |
+
'message' => $this->__('You have not yet enabled PostNL delivery options.'),
|
713 |
+
)
|
714 |
+
);
|
715 |
+
Mage::register('postnl_enabled_delivery_options_errors', $errors);
|
716 |
+
return false;
|
717 |
+
}
|
718 |
+
|
719 |
+
return true;
|
720 |
+
}
|
721 |
+
|
722 |
+
/**
|
723 |
+
* Checks if PostNL delivery options is active.
|
724 |
+
*
|
725 |
+
* @param null|int $storeId
|
726 |
+
*
|
727 |
+
* @return boolean
|
728 |
+
*/
|
729 |
+
public function isDeliveryOptionsActive($storeId = null)
|
730 |
+
{
|
731 |
+
if (is_null($storeId)) {
|
732 |
+
$storeId = Mage::app()->getStore()->getId();
|
733 |
+
}
|
734 |
+
|
735 |
+
$isActive = Mage::getStoreConfigFlag(self::XPATH_DELIVERY_OPTIONS_ACTIVE, $storeId);
|
736 |
+
|
737 |
+
return $isActive;
|
738 |
+
}
|
739 |
+
}
|
@@ -0,0 +1,105 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Helper_Mijnpakket extends TIG_PostNL_Helper_Data
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Xpath to 'mijnpakket_login_active' setting.
|
43 |
+
*/
|
44 |
+
const XPATH_MIJNPAKKET_LOGIN_ACTIVE = 'postnl/delivery_options/mijnpakket_login_active';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Log filename to log all non-specific PostNL debug messages.
|
48 |
+
*/
|
49 |
+
const POSTNL_DEBUG_LOG_FILE = 'TIG_PostNL_MijnPakket_Debug.log';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Check whether MijnPakket login is active.
|
53 |
+
*
|
54 |
+
* @return bool
|
55 |
+
*/
|
56 |
+
public function isMijnpakketLoginActive()
|
57 |
+
{
|
58 |
+
$storeId = Mage::app()->getStore()->getId();
|
59 |
+
|
60 |
+
$isActive = Mage::getStoreConfigFlag(self::XPATH_MIJNPAKKET_LOGIN_ACTIVE, $storeId);
|
61 |
+
|
62 |
+
return $isActive;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Checks whether MijnPakket login is currently available for use.
|
67 |
+
*
|
68 |
+
* @return boolean
|
69 |
+
*/
|
70 |
+
public function canLoginWithMijnpakket()
|
71 |
+
{
|
72 |
+
/**
|
73 |
+
* MijnPakket login is only available if delivery options are enabled.
|
74 |
+
*/
|
75 |
+
if (!Mage::helper('postnl/deliveryOptions')->isDeliveryOptionsEnabled()) {
|
76 |
+
return false;
|
77 |
+
}
|
78 |
+
|
79 |
+
if (!$this->isMijnpakketLoginActive()) {
|
80 |
+
return false;
|
81 |
+
}
|
82 |
+
|
83 |
+
return true;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Get initials based on a firstname.
|
88 |
+
*
|
89 |
+
* @param string $firstName
|
90 |
+
*
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
public function getInitials($firstName)
|
94 |
+
{
|
95 |
+
$nameParts = preg_split("/\s+/", $firstName);
|
96 |
+
|
97 |
+
$initials = '';
|
98 |
+
foreach ($nameParts as $name) {
|
99 |
+
$initials .= substr($name, 0, 1) . '.';
|
100 |
+
}
|
101 |
+
|
102 |
+
$initials = strtoupper($initials);
|
103 |
+
return $initials;
|
104 |
+
}
|
105 |
+
}
|
@@ -0,0 +1,146 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Helper_Parcelware extends TIG_PostNL_Helper_Data
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* XML path to auto confirm setting
|
43 |
+
*/
|
44 |
+
const XML_PATH_AUTO_CONFIRM = 'postnl/parcelware_export/auto_confirm';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* XML path to the active/inactive setting
|
48 |
+
*/
|
49 |
+
const XML_PATH_ACTIVE = 'postnl/parcelware_export/active';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* XML path to the customer code setting.
|
53 |
+
*/
|
54 |
+
const XML_PATH_CUSTOMER_CODE = 'postnl/cif/customer_code';
|
55 |
+
|
56 |
+
/**
|
57 |
+
* AutoConfirmEnabled flag
|
58 |
+
*
|
59 |
+
* @var boolean|null $_autoConfirmEnabled
|
60 |
+
*/
|
61 |
+
protected $_autoConfirmEnabled = null;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Gets the autoConfirmEnabled flag
|
65 |
+
*
|
66 |
+
* @return boolean|null
|
67 |
+
*/
|
68 |
+
public function getAutoConfirmEnabled()
|
69 |
+
{
|
70 |
+
return $this->_autoConfirmEnabled;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Sets the autoConfirmEnabled flag
|
75 |
+
*
|
76 |
+
* @param boolean $autoConfirmEnabled
|
77 |
+
*
|
78 |
+
* @return TIG_PostNL_Helper_Parcelware
|
79 |
+
*/
|
80 |
+
public function setAutoConfirmEnabled($autoConfirmEnabled)
|
81 |
+
{
|
82 |
+
$this->_autoConfirmEnabled = $autoConfirmEnabled;
|
83 |
+
|
84 |
+
return $this;
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Splits a barcode into its component parts.
|
89 |
+
*
|
90 |
+
* @param string $barcode
|
91 |
+
* @param int|bool $storeId
|
92 |
+
*
|
93 |
+
* @return array
|
94 |
+
*/
|
95 |
+
public function splitBarcode($barcode, $storeId = false)
|
96 |
+
{
|
97 |
+
if ($storeId === false) {
|
98 |
+
$storeId = Mage::app()->getStore()->getId();
|
99 |
+
}
|
100 |
+
|
101 |
+
$type = substr($barcode, 0, 2);
|
102 |
+
|
103 |
+
$customerCode = (string) Mage::getStoreConfig(self::XML_PATH_CUSTOMER_CODE, $storeId);
|
104 |
+
|
105 |
+
$number = substr($barcode, 2 + strlen($customerCode));
|
106 |
+
|
107 |
+
$barcodeComponents = array(
|
108 |
+
'type' => $type,
|
109 |
+
'range' => $customerCode,
|
110 |
+
'number' => $number,
|
111 |
+
);
|
112 |
+
|
113 |
+
return $barcodeComponents;
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Check to see if Parcelware export functionality is enabled.
|
118 |
+
*/
|
119 |
+
public function isParcelwareExportEnabled($storeId = null)
|
120 |
+
{
|
121 |
+
if ($storeId === null) {
|
122 |
+
$storeId = Mage::app()->getStore()->getId();
|
123 |
+
}
|
124 |
+
|
125 |
+
$active = Mage::getStoreConfigFlag(self::XML_PATH_ACTIVE, $storeId);
|
126 |
+
|
127 |
+
return $active;
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Checks if auto confirm is enabled
|
132 |
+
*
|
133 |
+
* @return boolean
|
134 |
+
*/
|
135 |
+
public function isAutoConfirmEnabled()
|
136 |
+
{
|
137 |
+
if ($this->getAutoConfirmEnabled() !== null) {
|
138 |
+
return $this->getAutoConfirmEnabled();
|
139 |
+
}
|
140 |
+
|
141 |
+
$autoConfirmEnabled = Mage::getStoreConfigFlag(self::XML_PATH_AUTO_CONFIRM, Mage_Core_Model_App::ADMIN_STORE_ID);
|
142 |
+
|
143 |
+
$this->setAutoConfirmEnabled($autoConfirmEnabled);
|
144 |
+
return $autoConfirmEnabled;
|
145 |
+
}
|
146 |
+
}
|
@@ -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.
|
@@ -33,10 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
|
40 |
Â
/**
|
41 |
Â
* Helper class for CIF operations
|
42 |
Â
*/
|
@@ -47,39 +47,39 @@ class TIG_PostNL_Helper_Webservices extends TIG_PostNL_Helper_Data
|
|
47 |
Â
*/
|
48 |
Â
const XML_PATH_EXTENSIONCONTROL_UNIQUE_KEY = 'postnl/general/unique_key';
|
49 |
Â
const XML_PATH_EXTENSIONCONTROL_PRIVATE_KEY = 'postnl/general/private_key';
|
50 |
-
|
51 |
Â
/**
|
52 |
Â
* XML path to updateStatistics on/off switch
|
53 |
Â
*/
|
54 |
Â
const XML_PATH_SEND_STATISTICS = 'postnl/advanced/send_statistics';
|
55 |
-
|
56 |
Â
/**
|
57 |
Â
* XML path to receiveUpdates on/off switch
|
58 |
Â
*/
|
59 |
Â
const XML_PATH_RECEIVE_UPDATES = 'postnl/advanced/receive_updates';
|
60 |
-
|
61 |
Â
/**
|
62 |
Â
* Log filename to log all webservices exceptions
|
63 |
Â
*/
|
64 |
Â
const WEBSERVICES_EXCEPTION_LOG_FILE = 'TIG_PostNL_Webservices_Exception.log';
|
65 |
-
|
66 |
Â
/**
|
67 |
-
* Log filename to webservices
|
68 |
Â
*/
|
69 |
Â
const WEBSERVICES_DEBUG_LOG_FILE = 'TIG_PostNL_Webservices_Debug.log';
|
70 |
-
|
71 |
Â
/**
|
72 |
Â
* Check if the extension has been activated with the extension control system by checking if the unique ket and private key
|
73 |
Â
* have been entered.
|
74 |
-
*
|
75 |
Â
* @param Mage_Core_Model_Website | null $website
|
76 |
-
*
|
77 |
Â
* @return boolean
|
78 |
Â
*/
|
79 |
Â
public function canSendStatistics($website = null)
|
80 |
Â
{
|
81 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
82 |
-
|
83 |
Â
/**
|
84 |
Â
* First check if sending statistics is enabled
|
85 |
Â
*/
|
@@ -94,135 +94,108 @@ class TIG_PostNL_Helper_Webservices extends TIG_PostNL_Helper_Data
|
|
94 |
Â
*/
|
95 |
Â
$sendStatistics = Mage::getStoreConfigFlag(self::XML_PATH_SEND_STATISTICS, $storeId);
|
96 |
Â
}
|
97 |
-
|
98 |
Â
if (!$sendStatistics) {
|
99 |
Â
return false;
|
100 |
Â
}
|
101 |
-
|
102 |
Â
/**
|
103 |
Â
* Check if the security keys have been entered.
|
104 |
Â
*/
|
105 |
Â
$privateKey = Mage::getStoreConfig(self::XML_PATH_EXTENSIONCONTROL_PRIVATE_KEY, $storeId);
|
106 |
Â
$uniqueKey = Mage::getStoreConfig(self::XML_PATH_EXTENSIONCONTROL_UNIQUE_KEY, $storeId);
|
107 |
-
|
108 |
Â
if (empty($privateKey) || empty($uniqueKey)) {
|
109 |
Â
return false;
|
110 |
Â
}
|
111 |
-
|
112 |
Â
return true;
|
113 |
Â
}
|
114 |
-
|
115 |
Â
/**
|
116 |
Â
* Checks whether the module may automatically receive updates regarding the module or promotions
|
117 |
-
*
|
118 |
Â
* @return boolean
|
119 |
Â
*/
|
120 |
Â
public function canReceiveUpdates()
|
121 |
Â
{
|
122 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
123 |
-
|
124 |
-
$receiveUpdates = Mage::getStoreConfigFlag(self::XML_PATH_RECEIVE_UPDATES);
|
125 |
Â
if (!$receiveUpdates) {
|
126 |
Â
return false;
|
127 |
Â
}
|
128 |
-
|
129 |
Â
return true;
|
130 |
Â
}
|
131 |
-
|
132 |
Â
/**
|
133 |
Â
* Encrypts a value
|
134 |
-
*
|
135 |
Â
* @param string $value
|
136 |
-
*
|
137 |
Â
* @return string
|
138 |
Â
*/
|
139 |
Â
public function encryptValue($value)
|
140 |
Â
{
|
141 |
Â
$value = (string) $value;
|
142 |
-
|
143 |
Â
$encrypted = Mage::helper('core')->encrypt($value);
|
144 |
-
|
145 |
Â
return $encrypted;
|
146 |
Â
}
|
147 |
-
|
148 |
Â
/**
|
149 |
Â
* Logs a webservice request and response for debug purposes.
|
150 |
-
*
|
151 |
-
*
|
152 |
-
*
|
153 |
-
* @param SoapClient $client
|
154 |
-
*
|
155 |
Â
* @return TIG_PostNL_Helper_Webservices
|
156 |
-
*
|
157 |
Â
* @see Mage::log()
|
158 |
-
*
|
159 |
-
* @todo add additional debug options
|
160 |
-
*
|
161 |
Â
*/
|
162 |
Â
public function logWebserviceCall($client)
|
163 |
Â
{
|
164 |
-
if (!$this->isLoggingEnabled()) {
|
165 |
Â
return $this;
|
166 |
Â
}
|
167 |
-
|
168 |
Â
$this->createLogDir();
|
169 |
-
|
170 |
Â
$requestXml = $this->formatXml($client->getLastRequest());
|
171 |
Â
$responseXML = $this->formatXml($client->getLastResponse());
|
172 |
-
|
173 |
Â
$logMessage = "Request sent:\n"
|
174 |
Â
. $requestXml
|
175 |
Â
. "\nResponse received:\n"
|
176 |
Â
. $responseXML;
|
177 |
-
|
178 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::WEBSERVICES_DEBUG_LOG_FILE;
|
179 |
Â
$this->log($logMessage, Zend_Log::DEBUG, $file);
|
180 |
-
|
181 |
Â
return $this;
|
182 |
Â
}
|
183 |
-
|
184 |
Â
/**
|
185 |
Â
* Logs a webservice exception in the database and/or a log file
|
186 |
-
*
|
187 |
-
*
|
188 |
-
*
|
189 |
-
* @param Mage_Core_Exception | TIG_PostNL_Model_Core_Webservices_Exception $exception
|
190 |
-
*
|
191 |
Â
* @return TIG_PostNL_Helper_Webservices
|
192 |
-
*
|
193 |
Â
* @see Mage::logException()
|
194 |
-
*
|
195 |
-
* @todo add additional debug options
|
196 |
Â
*/
|
197 |
Â
public function logWebserviceException($exception)
|
198 |
Â
{
|
199 |
Â
if (!$this->isExceptionLoggingEnabled()) {
|
200 |
Â
return $this;
|
201 |
Â
}
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
$responseXML = $this->formatXml($exception->getResponseXml());
|
206 |
-
|
207 |
-
$logMessage = '';
|
208 |
-
|
209 |
-
$errorNumbers = $exception->getErrorNumbers();
|
210 |
-
if (!empty($errorNumbers)) {
|
211 |
-
$errorNumbers = implode(', ', $errorNumbers);
|
212 |
-
$logMessage .= "Error numbers received: {$errorNumbers}\n";
|
213 |
-
}
|
214 |
-
|
215 |
-
$logMessage .= "<<< REQUEST SENT >>>\n"
|
216 |
-
. $requestXml
|
217 |
-
. "\n<<< RESPONSE RECEIVED >>>\n"
|
218 |
-
. $responseXML;
|
219 |
-
} else {
|
220 |
-
$logMessage = "\n" . $exception->__toString();
|
221 |
-
}
|
222 |
-
|
223 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::WEBSERVICES_EXCEPTION_LOG_FILE;
|
224 |
Â
$this->log($logMessage, Zend_Log::ERR, $file, false, true);
|
225 |
-
|
226 |
Â
return $this;
|
227 |
Â
}
|
228 |
Â
}
|
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.
|
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 |
Â
* Helper class for CIF operations
|
42 |
Â
*/
|
47 |
Â
*/
|
48 |
Â
const XML_PATH_EXTENSIONCONTROL_UNIQUE_KEY = 'postnl/general/unique_key';
|
49 |
Â
const XML_PATH_EXTENSIONCONTROL_PRIVATE_KEY = 'postnl/general/private_key';
|
50 |
+
|
51 |
Â
/**
|
52 |
Â
* XML path to updateStatistics on/off switch
|
53 |
Â
*/
|
54 |
Â
const XML_PATH_SEND_STATISTICS = 'postnl/advanced/send_statistics';
|
55 |
+
|
56 |
Â
/**
|
57 |
Â
* XML path to receiveUpdates on/off switch
|
58 |
Â
*/
|
59 |
Â
const XML_PATH_RECEIVE_UPDATES = 'postnl/advanced/receive_updates';
|
60 |
+
|
61 |
Â
/**
|
62 |
Â
* Log filename to log all webservices exceptions
|
63 |
Â
*/
|
64 |
Â
const WEBSERVICES_EXCEPTION_LOG_FILE = 'TIG_PostNL_Webservices_Exception.log';
|
65 |
+
|
66 |
Â
/**
|
67 |
+
* Log filename to log webservices calls
|
68 |
Â
*/
|
69 |
Â
const WEBSERVICES_DEBUG_LOG_FILE = 'TIG_PostNL_Webservices_Debug.log';
|
70 |
+
|
71 |
Â
/**
|
72 |
Â
* Check if the extension has been activated with the extension control system by checking if the unique ket and private key
|
73 |
Â
* have been entered.
|
74 |
+
*
|
75 |
Â
* @param Mage_Core_Model_Website | null $website
|
76 |
+
*
|
77 |
Â
* @return boolean
|
78 |
Â
*/
|
79 |
Â
public function canSendStatistics($website = null)
|
80 |
Â
{
|
81 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
82 |
+
|
83 |
Â
/**
|
84 |
Â
* First check if sending statistics is enabled
|
85 |
Â
*/
|
94 |
Â
*/
|
95 |
Â
$sendStatistics = Mage::getStoreConfigFlag(self::XML_PATH_SEND_STATISTICS, $storeId);
|
96 |
Â
}
|
97 |
+
|
98 |
Â
if (!$sendStatistics) {
|
99 |
Â
return false;
|
100 |
Â
}
|
101 |
+
|
102 |
Â
/**
|
103 |
Â
* Check if the security keys have been entered.
|
104 |
Â
*/
|
105 |
Â
$privateKey = Mage::getStoreConfig(self::XML_PATH_EXTENSIONCONTROL_PRIVATE_KEY, $storeId);
|
106 |
Â
$uniqueKey = Mage::getStoreConfig(self::XML_PATH_EXTENSIONCONTROL_UNIQUE_KEY, $storeId);
|
107 |
+
|
108 |
Â
if (empty($privateKey) || empty($uniqueKey)) {
|
109 |
Â
return false;
|
110 |
Â
}
|
111 |
+
|
112 |
Â
return true;
|
113 |
Â
}
|
114 |
+
|
115 |
Â
/**
|
116 |
Â
* Checks whether the module may automatically receive updates regarding the module or promotions
|
117 |
+
*
|
118 |
Â
* @return boolean
|
119 |
Â
*/
|
120 |
Â
public function canReceiveUpdates()
|
121 |
Â
{
|
122 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
123 |
+
|
124 |
+
$receiveUpdates = Mage::getStoreConfigFlag(self::XML_PATH_RECEIVE_UPDATES, $storeId);
|
125 |
Â
if (!$receiveUpdates) {
|
126 |
Â
return false;
|
127 |
Â
}
|
128 |
+
|
129 |
Â
return true;
|
130 |
Â
}
|
131 |
+
|
132 |
Â
/**
|
133 |
Â
* Encrypts a value
|
134 |
+
*
|
135 |
Â
* @param string $value
|
136 |
+
*
|
137 |
Â
* @return string
|
138 |
Â
*/
|
139 |
Â
public function encryptValue($value)
|
140 |
Â
{
|
141 |
Â
$value = (string) $value;
|
142 |
+
|
143 |
Â
$encrypted = Mage::helper('core')->encrypt($value);
|
144 |
+
|
145 |
Â
return $encrypted;
|
146 |
Â
}
|
147 |
+
|
148 |
Â
/**
|
149 |
Â
* Logs a webservice request and response for debug purposes.
|
150 |
+
*
|
151 |
+
* @param Zend_Soap_Client $client
|
152 |
+
*
|
Â
|
|
Â
|
|
153 |
Â
* @return TIG_PostNL_Helper_Webservices
|
154 |
+
*
|
155 |
Â
* @see Mage::log()
|
Â
|
|
Â
|
|
Â
|
|
156 |
Â
*/
|
157 |
Â
public function logWebserviceCall($client)
|
158 |
Â
{
|
159 |
+
if (!$this->isLoggingEnabled()) {
|
160 |
Â
return $this;
|
161 |
Â
}
|
162 |
+
|
163 |
Â
$this->createLogDir();
|
164 |
+
|
165 |
Â
$requestXml = $this->formatXml($client->getLastRequest());
|
166 |
Â
$responseXML = $this->formatXml($client->getLastResponse());
|
167 |
+
|
168 |
Â
$logMessage = "Request sent:\n"
|
169 |
Â
. $requestXml
|
170 |
Â
. "\nResponse received:\n"
|
171 |
Â
. $responseXML;
|
172 |
+
|
173 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::WEBSERVICES_DEBUG_LOG_FILE;
|
174 |
Â
$this->log($logMessage, Zend_Log::DEBUG, $file);
|
175 |
+
|
176 |
Â
return $this;
|
177 |
Â
}
|
178 |
+
|
179 |
Â
/**
|
180 |
Â
* Logs a webservice exception in the database and/or a log file
|
181 |
+
*
|
182 |
+
* @param Mage_Core_Exception|TIG_PostNL_Exception|SoapFault $exception
|
183 |
+
*
|
Â
|
|
Â
|
|
184 |
Â
* @return TIG_PostNL_Helper_Webservices
|
185 |
+
*
|
186 |
Â
* @see Mage::logException()
|
Â
|
|
Â
|
|
187 |
Â
*/
|
188 |
Â
public function logWebserviceException($exception)
|
189 |
Â
{
|
190 |
Â
if (!$this->isExceptionLoggingEnabled()) {
|
191 |
Â
return $this;
|
192 |
Â
}
|
193 |
+
|
194 |
+
$logMessage = "\n" . $exception->__toString();
|
195 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
196 |
Â
$file = self::POSTNL_LOG_DIRECTORY . DS . self::WEBSERVICES_EXCEPTION_LOG_FILE;
|
197 |
Â
$this->log($logMessage, Zend_Log::ERR, $file, false, true);
|
198 |
+
|
199 |
Â
return $this;
|
200 |
Â
}
|
201 |
Â
}
|
@@ -0,0 +1,101 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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) 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_Model_AddressValidation_Cendris extends TIG_PostNL_Model_AddressValidation_Cendris_Abstract
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Xpaths to cendris username and password.
|
43 |
+
*/
|
44 |
+
const XPATH_USERNAME = 'postnl/cendris/username';
|
45 |
+
const XPATH_PASSWORD = 'postnl/cendris/password';
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Validates and enriches the postcode and housenumber with a city and streetname
|
49 |
+
*
|
50 |
+
* @param string $postcode
|
51 |
+
* @param string $housenumber
|
52 |
+
*
|
53 |
+
* @return StdClass
|
54 |
+
*/
|
55 |
+
public function getAdresxpressPostcode($postcode, $housenumber)
|
56 |
+
{
|
57 |
+
$username = $this->_getUsername();
|
58 |
+
$password = $this->_getPassword();
|
59 |
+
|
60 |
+
$soapParams = array(
|
61 |
+
'gebruikersnaam' => $username,
|
62 |
+
'wachtwoord' => $password,
|
63 |
+
'postcode' => $postcode,
|
64 |
+
'huisnummer' => $housenumber,
|
65 |
+
);
|
66 |
+
|
67 |
+
$result = $this->call('getAdresxpressPostcode', $soapParams);
|
68 |
+
|
69 |
+
if (is_array($result)) {
|
70 |
+
$result = current($result);
|
71 |
+
}
|
72 |
+
|
73 |
+
return $result;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Get the Cendris username.
|
78 |
+
*
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
protected function _getUsername()
|
82 |
+
{
|
83 |
+
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
84 |
+
$username = Mage::getStoreConfig(self::XPATH_USERNAME, $storeId);
|
85 |
+
|
86 |
+
return $username;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Get the Cendris password.
|
91 |
+
*
|
92 |
+
* @return string
|
93 |
+
*/
|
94 |
+
protected function _getPassword()
|
95 |
+
{
|
96 |
+
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
97 |
+
$password = Mage::getStoreConfig(self::XPATH_PASSWORD, $storeId);
|
98 |
+
|
99 |
+
return $password;
|
100 |
+
}
|
101 |
+
}
|
@@ -0,0 +1,113 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
advanced * 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 |
+
class TIG_PostNL_Model_AddressValidation_Cendris_Abstract extends Varien_Object
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Wsdl location
|
43 |
+
*/
|
44 |
+
const WEBSERVICE_WSDL_URL = 'http://www.cendris.nl/webservices/services/soap_rpcenc?wsdl';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Calls a webservice method
|
48 |
+
*
|
49 |
+
* @param string $method The method that will be called
|
50 |
+
* @param array $soapParams An array of parameters to be sent
|
51 |
+
*
|
52 |
+
* @throws Exception
|
53 |
+
* @throws SoapFault
|
54 |
+
*
|
55 |
+
* @return object
|
56 |
+
*/
|
57 |
+
public function call($method, $soapParams)
|
58 |
+
{
|
59 |
+
try {
|
60 |
+
$wsdl = self::WEBSERVICE_WSDL_URL;
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Array of soap options used when connecting to the webservice
|
64 |
+
*/
|
65 |
+
$soapOptions = array(
|
66 |
+
'soap_version' => SOAP_1_1,
|
67 |
+
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
|
68 |
+
);
|
69 |
+
|
70 |
+
/**
|
71 |
+
* try to create a new Zend_Soap_Client instance based on the supplied wsdl. if it fails, try again without using the
|
72 |
+
* wsdl cache.
|
73 |
+
*/
|
74 |
+
try {
|
75 |
+
$client = new Zend_Soap_Client(
|
76 |
+
$wsdl,
|
77 |
+
$soapOptions
|
78 |
+
);
|
79 |
+
} catch (Exception $e) {
|
80 |
+
/**
|
81 |
+
* Disable wsdl cache and try again
|
82 |
+
*/
|
83 |
+
$soapOptions['cache_wsdl'] = WSDL_CACHE_NONE;
|
84 |
+
|
85 |
+
$client = new Zend_Soap_Client(
|
86 |
+
$wsdl,
|
87 |
+
$soapOptions
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Call the SOAP method
|
93 |
+
*/
|
94 |
+
$response = $client->__call(
|
95 |
+
$method,
|
96 |
+
$soapParams
|
97 |
+
);
|
98 |
+
|
99 |
+
Mage::helper('postnl/addressValidation')->logCendrisCall($client);
|
100 |
+
return $response;
|
101 |
+
} catch(SoapFault $e) {
|
102 |
+
/**
|
103 |
+
* Log a possible SoapFault exception.
|
104 |
+
*/
|
105 |
+
if (!isset($client)) {
|
106 |
+
$client = false;
|
107 |
+
}
|
108 |
+
Mage::helper('postnl/addressValidation')->logCendrisException($e, $client);
|
109 |
+
|
110 |
+
throw $e;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
@@ -0,0 +1,110 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasAddressBlockClass()
|
40 |
+
* @method TIG_PostNL_Model_AddressValidation_Observer_AddressBook setAddressBlockClass(string $value)
|
41 |
+
*/
|
42 |
+
class TIG_PostNL_Model_AddressValidation_Observer_AddressBook extends Varien_Object
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* The block class that we want to edit
|
46 |
+
*/
|
47 |
+
const ADDRESS_COMMUNITY_BLOCK_NAME = 'customer/address_edit';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Current environment for the postcode check
|
51 |
+
*/
|
52 |
+
const POSTCODECHECK_ENV = 'addressbook';
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Gets the classname for the addressbook block that we want to edit.
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
public function getAddressBlockClass()
|
60 |
+
{
|
61 |
+
if ($this->hasAddressBlockClass()) {
|
62 |
+
return $this->_getData('address_block_class');
|
63 |
+
}
|
64 |
+
|
65 |
+
$blockClass = Mage::getConfig()->getBlockClassName(self::ADDRESS_COMMUNITY_BLOCK_NAME);
|
66 |
+
|
67 |
+
$this->setAddressBlockClass($blockClass);
|
68 |
+
return $blockClass;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Alters the template of the onepage checkout billing address block if the postcode check functionality is active.
|
73 |
+
*
|
74 |
+
* @param Varien_Event_Observer $observer
|
75 |
+
*
|
76 |
+
* @return TIG_PostNL_Model_AddressValidation_Observer_AddressBook
|
77 |
+
*
|
78 |
+
* @event core_block_abstract_to_html_before
|
79 |
+
*
|
80 |
+
* @observer checkout_onepage_billing_postcodecheck
|
81 |
+
*
|
82 |
+
*/
|
83 |
+
public function addressBookPostcodeCheck(Varien_Event_Observer $observer)
|
84 |
+
{
|
85 |
+
/**
|
86 |
+
* Check if the extension is active
|
87 |
+
*/
|
88 |
+
if (!Mage::helper('postnl/addressValidation')->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
89 |
+
return $this;
|
90 |
+
}
|
91 |
+
|
92 |
+
/**
|
93 |
+
* Checks if the current block is the one we want to edit.
|
94 |
+
*
|
95 |
+
* Unfortunately there is no unique event for this block.
|
96 |
+
*
|
97 |
+
* @var Mage_Customer_Block_Address_Edit $block
|
98 |
+
*/
|
99 |
+
$block = $observer->getBlock();
|
100 |
+
$blockClass = $this->getAddressBlockClass();
|
101 |
+
|
102 |
+
if (get_class($block) !== $blockClass) {
|
103 |
+
return $this;
|
104 |
+
}
|
105 |
+
|
106 |
+
$block->setTemplate('TIG/PostNL/address_validation/customer/address/edit.phtml');
|
107 |
+
|
108 |
+
return $this;
|
109 |
+
}
|
110 |
+
}
|
@@ -0,0 +1,129 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasAddressBlockClass()
|
40 |
+
* @method TIG_PostNL_Model_AddressValidation_Observer_OneStepCheckout setAddressBlockClass(string $value)
|
41 |
+
*/
|
42 |
+
class TIG_PostNL_Model_AddressValidation_Observer_OneStepCheckout extends Varien_Object
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* The block class that we want to edit
|
46 |
+
*/
|
47 |
+
const ADDRESS_BLOCK_NAME = 'onestepcheckout/fields';
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Block aliases used by OneStepCheckout.
|
51 |
+
*
|
52 |
+
* We use these to determine whether the block is for the billing or shipping address.
|
53 |
+
*/
|
54 |
+
const BILLING_ADDRESS_BLOCK_ALIAS = 'billing_address';
|
55 |
+
const SHIPPING_ADDRESS_BLOCK_ALIAS = 'shipping_address';
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Current environment for the postcode check
|
59 |
+
*/
|
60 |
+
const POSTCODECHECK_ENV = 'checkout';
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Gets the classname for the address block that we want to edit
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getAddressBlockClass()
|
68 |
+
{
|
69 |
+
if ($this->hasAddressBlockClass()) {
|
70 |
+
return $this->_getData('address_block_class');
|
71 |
+
}
|
72 |
+
|
73 |
+
$blockClass = Mage::getConfig()->getBlockClassName(self::ADDRESS_BLOCK_NAME);
|
74 |
+
|
75 |
+
$this->setAddressBlockClass($blockClass);
|
76 |
+
return $blockClass;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Alters the template of the OneStepCheckout address block if the postcode check functionality is active.
|
81 |
+
*
|
82 |
+
* @param Varien_Event_Observer $observer
|
83 |
+
*
|
84 |
+
* @return TIG_PostNL_Model_AddressValidation_Observer_OneStepCheckout
|
85 |
+
*
|
86 |
+
* @event core_block_abstract_to_html_before
|
87 |
+
*
|
88 |
+
* @observer customer_address_edit_postcodecheck
|
89 |
+
*/
|
90 |
+
public function addressPostcodeCheck(Varien_Event_Observer $observer)
|
91 |
+
{
|
92 |
+
/**
|
93 |
+
* Check if the extension is active
|
94 |
+
*/
|
95 |
+
if (!Mage::helper('postnl/addressValidation')->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Checks if the current block is the one we want to edit.
|
101 |
+
*
|
102 |
+
* Unfortunately there is no unique event for this block.
|
103 |
+
*
|
104 |
+
* @var Idev_OneStepCheckout_Block_Fields $block
|
105 |
+
*/
|
106 |
+
$block = $observer->getBlock();
|
107 |
+
$blockClass = $this->getAddressBlockClass();
|
108 |
+
|
109 |
+
if (get_class($block) !== $blockClass) {
|
110 |
+
return $this;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Get the blocks alias and alter it's template based on this
|
115 |
+
*/
|
116 |
+
$blockAlias = $block->getBlockAlias();
|
117 |
+
switch ($blockAlias) {
|
118 |
+
case self::BILLING_ADDRESS_BLOCK_ALIAS:
|
119 |
+
$block->setTemplate('TIG/PostNL/address_validation/onestepcheckout/billing_fields.phtml');
|
120 |
+
break;
|
121 |
+
case self::SHIPPING_ADDRESS_BLOCK_ALIAS:
|
122 |
+
$block->setTemplate('TIG/PostNL/address_validation/onestepcheckout/shipping_fields.phtml');
|
123 |
+
break;
|
124 |
+
//no default
|
125 |
+
}
|
126 |
+
|
127 |
+
return $this;
|
128 |
+
}
|
129 |
+
}
|
@@ -0,0 +1,170 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method boolean hasBillingAddressBlockClass()
|
40 |
+
* @method TIG_PostNL_Model_AddressValidation_Observer_Onepage setBillingAddressBlockClass(string $value)
|
41 |
+
* @method boolean hasShippingAddressBlockClass()
|
42 |
+
* @method TIG_PostNL_Model_AddressValidation_Observer_Onepage setShippingAddressBlockClass(string $value)
|
43 |
+
*/
|
44 |
+
class TIG_PostNL_Model_AddressValidation_Observer_Onepage extends Varien_Object
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* The block classes that we want to edit
|
48 |
+
*/
|
49 |
+
const BILLING_ADDRESS_BLOCK_NAME = 'checkout/onepage_billing';
|
50 |
+
const SHIPPING_ADDRESS_BLOCK_NAME = 'checkout/onepage_shipping';
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Current environment for the postcode check
|
54 |
+
*/
|
55 |
+
const POSTCODECHECK_ENV = 'checkout';
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Gets the classname for the onepage checkout billing address block that we want to alter
|
59 |
+
*
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getBillingAddressBlockClass()
|
63 |
+
{
|
64 |
+
if ($this->hasBillingAddressBlockClass()) {
|
65 |
+
return $this->_getData('billing_address_block_class');
|
66 |
+
}
|
67 |
+
|
68 |
+
$blockClass = Mage::getConfig()->getBlockClassName(self::BILLING_ADDRESS_BLOCK_NAME);
|
69 |
+
|
70 |
+
$this->setBillingAddressBlockClass($blockClass);
|
71 |
+
return $blockClass;
|
72 |
+
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Gets the classname for the onepage checkout shipping address block that we want to alter
|
76 |
+
*
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
public function getShippingAddressBlockClass()
|
80 |
+
{
|
81 |
+
if ($this->hasShippingAddressBlockClass()) {
|
82 |
+
return $this->_getData('shipping_address_block_class');
|
83 |
+
}
|
84 |
+
|
85 |
+
$blockClass = Mage::getConfig()->getBlockClassName(self::SHIPPING_ADDRESS_BLOCK_NAME);
|
86 |
+
|
87 |
+
$this->setShippingAddressBlockClass($blockClass);
|
88 |
+
return $blockClass;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Alters the template of the onepage checkout billing address block if the postcode check functionality is active.
|
93 |
+
*
|
94 |
+
* @param Varien_Event_Observer $observer
|
95 |
+
*
|
96 |
+
* @return TIG_PostNL_Model_AddressValidation_Observer_Onepage
|
97 |
+
*
|
98 |
+
* @event core_block_abstract_to_html_before
|
99 |
+
*
|
100 |
+
* @observer checkout_onepage_billing_postcodecheck
|
101 |
+
*
|
102 |
+
*/
|
103 |
+
public function billingAddressPostcodeCheck(Varien_Event_Observer $observer)
|
104 |
+
{
|
105 |
+
/**
|
106 |
+
* Check if the extension is active
|
107 |
+
*/
|
108 |
+
if (!Mage::helper('postnl/addressValidation')->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
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 |
+
* @var Mage_Checkout_Block_Onepage_Billing $block
|
118 |
+
*/
|
119 |
+
$block = $observer->getBlock();
|
120 |
+
$blockClass = $this->getBillingAddressBlockClass();
|
121 |
+
|
122 |
+
if (get_class($block) !== $blockClass) {
|
123 |
+
return $this;
|
124 |
+
}
|
125 |
+
|
126 |
+
$block->setTemplate('TIG/PostNL/address_validation/checkout/onepage/billing.phtml');
|
127 |
+
|
128 |
+
return $this;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Alters the template of the onepage checkout shipping address block if the postcode check functionality is active.
|
133 |
+
*
|
134 |
+
* @param Varien_Event_Observer $observer
|
135 |
+
*
|
136 |
+
* @return TIG_PostNL_Model_AddressValidation_Observer_Onepage
|
137 |
+
*
|
138 |
+
* @event core_block_abstract_to_html_before
|
139 |
+
*
|
140 |
+
* @observer checkout_onepage_shipping_postcodecheck
|
141 |
+
*
|
142 |
+
*/
|
143 |
+
public function shippingAddressPostcodeCheck(Varien_Event_Observer $observer)
|
144 |
+
{
|
145 |
+
/**
|
146 |
+
* Check if the extension is active
|
147 |
+
*/
|
148 |
+
if (!Mage::helper('postnl/addressValidation')->isPostcodeCheckEnabled(null, self::POSTCODECHECK_ENV)) {
|
149 |
+
return $this;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* Checks if the current block is the one we want to edit.
|
154 |
+
*
|
155 |
+
* Unfortunately there is no unique event for this block.
|
156 |
+
*
|
157 |
+
* @var Mage_Checkout_Block_Onepage_Shipping $block
|
158 |
+
*/
|
159 |
+
$block = $observer->getBlock();
|
160 |
+
$blockClass = $this->getShippingAddressBlockClass();
|
161 |
+
|
162 |
+
if (get_class($block) !== $blockClass) {
|
163 |
+
return $this;
|
164 |
+
}
|
165 |
+
|
166 |
+
$block->setTemplate('TIG/PostNL/address_validation/checkout/onepage/shipping.phtml');
|
167 |
+
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
}
|
@@ -0,0 +1,284 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Model_AddressValidation_System_Config_Backend_ValidateAccount extends Mage_Core_Model_Config_Data
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Xpaths used to get PostNL account credentials.
|
43 |
+
*/
|
44 |
+
const XPATH_MODE = 'postnl/cif/mode';
|
45 |
+
const XPATH_LIVE_USERNAME = 'postnl/cif/live_username';
|
46 |
+
const XPATH_LIVE_PASSWORD = 'postnl/cif/live_password';
|
47 |
+
const XPATH_TEST_USERNAME = 'postnl/cif/test_username';
|
48 |
+
const XPATH_TEST_PASSWORD = 'postnl/cif/test_password';
|
49 |
+
const XPATH_CUSTOMER_NUMBER = 'postnl/cif/customer_number';
|
50 |
+
const XPATH_CUSTOMER_CODE = 'postnl/cif/customer_code';
|
51 |
+
const XPATH_COLLECTION_LOCATION = 'postnl/cif/collection_location';
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Gets the store ID based on the current store scope.
|
55 |
+
*
|
56 |
+
* @return int
|
57 |
+
*/
|
58 |
+
public function getStoreId()
|
59 |
+
{
|
60 |
+
if ($this->hasStoreId()) {
|
61 |
+
return $this->getData('store_id');
|
62 |
+
}
|
63 |
+
|
64 |
+
$storeCode = $this->getStoreCode();
|
65 |
+
$storeId = Mage::getModel('core/store')->load($storeCode, 'code')->getId();
|
66 |
+
|
67 |
+
$this->setStoreId($storeId);
|
68 |
+
return $storeId;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Gets an instance of the current website scope.
|
73 |
+
*
|
74 |
+
* @return Mage_Core_Model_Website
|
75 |
+
*/
|
76 |
+
public function getWebsite()
|
77 |
+
{
|
78 |
+
if ($this->hasWebsite()) {
|
79 |
+
return $this->getData('website');
|
80 |
+
}
|
81 |
+
|
82 |
+
$websiteCode = $this->getWebsiteCode();
|
83 |
+
$website = Mage::getModel('core/website')->load($websiteCode, 'code');
|
84 |
+
|
85 |
+
$this->setWebsite($website);
|
86 |
+
return $website;
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Check that PostNL account settings have been entered and are valid before saving this field.
|
91 |
+
*
|
92 |
+
* @throws TIG_PostNL_Exception
|
93 |
+
*
|
94 |
+
* @return Mage_Core_Model_Abstract
|
95 |
+
*
|
96 |
+
* @see Mage_Core_Model_Abstract::_beforeSave()
|
97 |
+
*/
|
98 |
+
protected function _beforeSave()
|
99 |
+
{
|
100 |
+
/**
|
101 |
+
* If the value has not changed, we don't have to do anything.
|
102 |
+
*/
|
103 |
+
if (!$this->isValueChanged()) {
|
104 |
+
return parent::_beforeSave();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* If the setting has been disabled we also don't have to do anything.
|
109 |
+
*/
|
110 |
+
if (!$this->getValue()) {
|
111 |
+
return parent::_beforeSave();
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Check whether the extension is set to test mode and get the username and password for that mode.
|
116 |
+
*/
|
117 |
+
$testMode = $this->_getIsTestMode();
|
118 |
+
if ($testMode) {
|
119 |
+
$username = $this->_getConfigValue(self::XPATH_TEST_USERNAME);
|
120 |
+
$password = $this->_getConfigValue(self::XPATH_TEST_PASSWORD);
|
121 |
+
} else {
|
122 |
+
$username = $this->_getConfigValue(self::XPATH_LIVE_USERNAME);
|
123 |
+
$password = $this->_getConfigValue(self::XPATH_LIVE_PASSWORD);
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Get other PostNL account settings.
|
128 |
+
*/
|
129 |
+
$customerNumber = $this->_getConfigValue(self::XPATH_CUSTOMER_NUMBER);
|
130 |
+
$customerCode = $this->_getConfigValue(self::XPATH_CUSTOMER_CODE);
|
131 |
+
$locationCode = $this->_getConfigValue(self::XPATH_COLLECTION_LOCATION);
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Decrypt and then hash the password.
|
135 |
+
*/
|
136 |
+
$password = trim($password);
|
137 |
+
$password = sha1(Mage::helper('core')->decrypt($password));
|
138 |
+
|
139 |
+
/**
|
140 |
+
* Put all credentials into an array.
|
141 |
+
*/
|
142 |
+
$data = array(
|
143 |
+
'password' => $password,
|
144 |
+
'username' => $username,
|
145 |
+
'customerNumber' => $customerNumber,
|
146 |
+
'customerCode' => $customerCode,
|
147 |
+
'locationCode' => $locationCode,
|
148 |
+
);
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Load the CIF model and set to test mode to false
|
152 |
+
*/
|
153 |
+
$cif = Mage::getModel('postnl_core/cif')
|
154 |
+
->setTestMode($testMode);
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Attempt to generate a barcode to test the account settings. This will result in an exception if the settings
|
158 |
+
* are invalid.
|
159 |
+
*/
|
160 |
+
try {
|
161 |
+
$response = $cif->generateBarcodePing($data);
|
162 |
+
} catch (Exception $e) {
|
163 |
+
$errorMessage = $this->_getErrorMessage();
|
164 |
+
|
165 |
+
throw new TIG_PostNL_Exception($errorMessage, 'POSTNL-0114');
|
166 |
+
}
|
167 |
+
|
168 |
+
/**
|
169 |
+
* The result should be a barcode.
|
170 |
+
*/
|
171 |
+
if (!is_string($response)) {
|
172 |
+
$errorMessage = $this->_getErrorMessage();
|
173 |
+
|
174 |
+
throw new TIG_PostNL_Exception($errorMessage, 'POSTNL-0114');
|
175 |
+
}
|
176 |
+
|
177 |
+
return parent::_beforeSave();
|
178 |
+
}
|
179 |
+
|
180 |
+
/**
|
181 |
+
* gets whether the extension is set to test mode.
|
182 |
+
*
|
183 |
+
* @return boolean
|
184 |
+
*/
|
185 |
+
protected function _getIsTestMode()
|
186 |
+
{
|
187 |
+
$cifTestMode = (bool) $this->_getConfigValue(self::XPATH_MODE);
|
188 |
+
|
189 |
+
return $cifTestMode;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Gets a config value. First we try to get the value from the fields we are currently trying to save. if the path
|
194 |
+
* is not among the fields we're saving, get it from the database for the current scope.
|
195 |
+
*
|
196 |
+
* @param string $path An xpath to the setting we're trying to retreive
|
197 |
+
*
|
198 |
+
* @return string|null
|
199 |
+
*
|
200 |
+
* @throws InvalidArgumentException
|
201 |
+
*/
|
202 |
+
protected function _getConfigValue($path)
|
203 |
+
{
|
204 |
+
$groups = $this->getGroups();
|
205 |
+
$pathParts = explode('/', $path);
|
206 |
+
if (count($pathParts) !== 3) {
|
207 |
+
throw new InvalidArgumentException(
|
208 |
+
'Invalid argument: $path should be a valid xpath.'
|
209 |
+
);
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Check if the value is among the fields we're currently saving.
|
214 |
+
*
|
215 |
+
* In the case of password fields, the value '******' might be used. This is not a valid value and should be
|
216 |
+
* ignored.
|
217 |
+
*/
|
218 |
+
if (isset($groups[$pathParts[1]]['fields'][$pathParts[2]]['value'])
|
219 |
+
&& $groups[$pathParts[1]]['fields'][$pathParts[2]]['value'] != '******'
|
220 |
+
) {
|
221 |
+
return $groups[$pathParts[1]]['fields'][$pathParts[2]]['value'];
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Get the value based on the current scope.
|
226 |
+
*/
|
227 |
+
$scope = $this->getScope();
|
228 |
+
switch ($scope) {
|
229 |
+
case 'stores':
|
230 |
+
$storeId = $this->getStoreId();
|
231 |
+
$value = Mage::getStoreConfig($path, $storeId);
|
232 |
+
break;
|
233 |
+
case 'websites':
|
234 |
+
$website = $this->getWebsite();
|
235 |
+
$value = $website->getConfig($path);
|
236 |
+
break;
|
237 |
+
default:
|
238 |
+
$value = Mage::getStoreConfig($path, Mage_Core_Model_App::ADMIN_STORE_ID);
|
239 |
+
break;
|
240 |
+
}
|
241 |
+
|
242 |
+
return $value;
|
243 |
+
}
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Get the error message in case the PostNL account credentials could not be validated. Normally the controller
|
247 |
+
* would catch an exception and parse it to create this message, however we have no control over the system_config
|
248 |
+
* controller, so we need to format the message in advance.
|
249 |
+
*
|
250 |
+
* @return string
|
251 |
+
*/
|
252 |
+
protected function _getErrorMessage()
|
253 |
+
{
|
254 |
+
$helper = Mage::helper('postnl');
|
255 |
+
|
256 |
+
/**
|
257 |
+
* Get the error from the extension's config.xml
|
258 |
+
*/
|
259 |
+
$error = Mage::getConfig()->getNode('tig/errors/POSTNL-0114');
|
260 |
+
$link = (string) $error->url;
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Form the base error message.
|
264 |
+
*/
|
265 |
+
$errorMessage = '[PostNL-0114] ';
|
266 |
+
$errorMessage .= $helper->__(
|
267 |
+
'Your PostNL account credentials could not be validated.'
|
268 |
+
. ' Please enter valid PostNL account credentials before activating the postcode check functionality.'
|
269 |
+
);
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Append a link to the TiG knowledgebase if available.
|
273 |
+
*/
|
274 |
+
if ($link) {
|
275 |
+
$errorMessage .= ' <a href="'
|
276 |
+
. $link
|
277 |
+
. '" target="_blank" class="postnl-message">'
|
278 |
+
. $helper->__('Click here for more information from the TiG knowledgebase.')
|
279 |
+
. '</a>';
|
280 |
+
}
|
281 |
+
|
282 |
+
return $errorMessage;
|
283 |
+
}
|
284 |
+
}
|
@@ -0,0 +1,66 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Model_Admin_Logging_Handler_Postnl extends Enterprise_Logging_Model_Handler_Controllers
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* PostNL mass action postDispatch handler.
|
43 |
+
*
|
44 |
+
* @param Varien_Simplexml_Element $config
|
45 |
+
* @param Enterprise_Logging_Model_Event $eventModel
|
46 |
+
*
|
47 |
+
* @return boolean
|
48 |
+
*/
|
49 |
+
public function postDispatchSaveMassAction($config, $eventModel)
|
50 |
+
{
|
51 |
+
$request = Mage::app()->getRequest();
|
52 |
+
if ($request->getParam('shipment_ids')) {
|
53 |
+
$eventModel->setInfo($request->getParam('shipment_ids'));
|
54 |
+
|
55 |
+
return true;
|
56 |
+
}
|
57 |
+
|
58 |
+
if ($request->getParam('order_ids')) {
|
59 |
+
$eventModel->setInfo($request->getParam('order_ids'));
|
60 |
+
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
|
64 |
+
return true;
|
65 |
+
}
|
66 |
+
}
|
@@ -0,0 +1,67 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Model_Admin_Logging_Observer
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Check if the Enterprise Logging extension is present and if so, call it's observer method. This prevents errors
|
43 |
+
* in Magento community edition.
|
44 |
+
*
|
45 |
+
* @param Varien_Event_Observer $observer
|
46 |
+
*
|
47 |
+
* @return $this
|
48 |
+
*
|
49 |
+
* @see Enterprise_Logging_Model_Observer::controllerPostdispatch()
|
50 |
+
*/
|
51 |
+
public function controllerPostdispatch(Varien_Event_Observer $observer)
|
52 |
+
{
|
53 |
+
$loggingObserverClassName = Mage::getConfig()->getModelClassName('enterprise_logging/observer');
|
54 |
+
$found = mageFindClassFile($loggingObserverClassName);
|
55 |
+
|
56 |
+
/**
|
57 |
+
* If we can't find the model, there's nothing that can be logged.
|
58 |
+
*/
|
59 |
+
if ($found === false) {
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
Mage::getModel('enterprise_logging/observer')->controllerPostdispatch($observer);
|
64 |
+
|
65 |
+
return $this;
|
66 |
+
}
|
67 |
+
}
|
@@ -33,15 +33,15 @@
|
|
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)
|
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
|
42 |
-
* @method
|
43 |
-
* @method TIG_PostNL_Model_Adminhtml_Observer_OrderGrid
|
44 |
-
* @method
|
45 |
Â
*/
|
46 |
Â
class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
47 |
Â
{
|
@@ -177,10 +177,12 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
177 |
Â
* Join tig_postnl_order table
|
178 |
Â
*/
|
179 |
Â
$select->joinLeft(
|
180 |
-
array('postnl_order' => $resource->getTableName('
|
181 |
Â
'`main_table`.`entity_id`=`postnl_order`.`order_id`',
|
182 |
Â
array(
|
183 |
-
'is_pakje_gemak'
|
Â
|
|
Â
|
|
184 |
Â
)
|
185 |
Â
);
|
186 |
Â
|
@@ -264,14 +266,17 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
264 |
Â
'index' => 'country_id',
|
265 |
Â
'type' => 'options',
|
266 |
Â
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shipmentType',
|
267 |
-
'width' => '
|
268 |
Â
'filter_condition_callback' => array($this, '_filterShipmentType'),
|
269 |
Â
'sortable' => false,
|
270 |
Â
'options' => array(
|
271 |
-
'nl'
|
272 |
-
'pakje_gemak'
|
273 |
-
'eu'
|
274 |
-
'global'
|
Â
|
|
Â
|
|
Â
|
|
275 |
Â
),
|
276 |
Â
);
|
277 |
Â
|
@@ -309,12 +314,21 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
309 |
Â
*/
|
310 |
Â
protected function _addMassaction($block)
|
311 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
312 |
Â
/**
|
313 |
Â
* Build an array of options for the massaction item
|
314 |
Â
*/
|
315 |
Â
$massActionData = array(
|
316 |
-
'label'=>
|
317 |
-
'url' => Mage::helper('adminhtml')->getUrl('
|
318 |
Â
);
|
319 |
Â
|
320 |
Â
$showOptions = Mage::getStoreConfig(self::XML_PATH_SHOW_OPTIONS, Mage_Core_Model_App::ADMIN_STORE_ID);
|
@@ -328,9 +342,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
328 |
Â
'name' => 'product_options',
|
329 |
Â
'type' => 'select',
|
330 |
Â
'class' => 'required-entry',
|
331 |
-
'label' =>
|
332 |
Â
'values' => Mage::getModel('postnl_core/system_config_source_allProductOptions')
|
333 |
-
->getAvailableOptions(true, true),
|
334 |
Â
),
|
335 |
Â
);
|
336 |
Â
}
|
@@ -350,7 +364,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
350 |
Â
/**
|
351 |
Â
* Applies sorting and filtering to the collection
|
352 |
Â
*
|
353 |
-
* @param
|
354 |
Â
*
|
355 |
Â
* @return $this
|
356 |
Â
*/
|
@@ -417,20 +431,78 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
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 |
Â
}
|
@@ -480,7 +552,11 @@ class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
|
480 |
Â
|
481 |
Â
$cond = $column->getFilter()->getCondition();
|
482 |
Â
if ($field && isset($cond)) {
|
483 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
484 |
Â
}
|
485 |
Â
|
486 |
Â
return $this;
|
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 |
Â
* Observer to edit the sales > order grid
|
40 |
Â
*
|
41 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_OrderGrid setCollection(TIG_PostNL_Model_Resource_Order_Grid_Collection $value)
|
42 |
+
* @method TIG_PostNL_Model_Resource_Order_Grid_Collection getCollection()
|
43 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_OrderGrid setBlock(Mage_Adminhtml_Block_Sales_Order_Grid $value)
|
44 |
+
* @method Mage_Adminhtml_Block_Sales_Order_Grid getBlock()
|
45 |
Â
*/
|
46 |
Â
class TIG_PostNL_Model_Adminhtml_Observer_OrderGrid extends Varien_Object
|
47 |
Â
{
|
177 |
Â
* Join tig_postnl_order table
|
178 |
Â
*/
|
179 |
Â
$select->joinLeft(
|
180 |
+
array('postnl_order' => $resource->getTableName('postnl_core/order')),
|
181 |
Â
'`main_table`.`entity_id`=`postnl_order`.`order_id`',
|
182 |
Â
array(
|
183 |
+
'is_pakje_gemak' => 'postnl_order.is_pakje_gemak',
|
184 |
+
'is_pakketautomaat' => 'postnl_order.is_pakketautomaat',
|
185 |
+
'delivery_option_type' => 'postnl_order.type',
|
186 |
Â
)
|
187 |
Â
);
|
188 |
Â
|
266 |
Â
'index' => 'country_id',
|
267 |
Â
'type' => 'options',
|
268 |
Â
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shipmentType',
|
269 |
+
'width' => '110px',
|
270 |
Â
'filter_condition_callback' => array($this, '_filterShipmentType'),
|
271 |
Â
'sortable' => false,
|
272 |
Â
'options' => array(
|
273 |
+
'nl' => $helper->__('Domestic'),
|
274 |
+
'pakje_gemak' => $helper->__('Post Office'),
|
275 |
+
'eu' => $helper->__('EPS'),
|
276 |
+
'global' => $helper->__('GlobalPack'),
|
277 |
+
'pakketautomaat' => $helper->__('Parcel Dispenser'),
|
278 |
+
'avond' => $helper->__('Evening Delivery'),
|
279 |
+
'pakje_gemak_express' => $helper->__('Early Pickup'),
|
280 |
Â
),
|
281 |
Â
);
|
282 |
Â
|
314 |
Â
*/
|
315 |
Â
protected function _addMassaction($block)
|
316 |
Â
{
|
317 |
+
$helper = Mage::helper('postnl');
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Make sure the admin is allowed ship orders.
|
321 |
+
*/
|
322 |
+
if (!$helper->checkIsPostnlActionAllowed('create_shipment')) {
|
323 |
+
return $this;
|
324 |
+
}
|
325 |
+
|
326 |
Â
/**
|
327 |
Â
* Build an array of options for the massaction item
|
328 |
Â
*/
|
329 |
Â
$massActionData = array(
|
330 |
+
'label'=> $helper->__('PostNL - Create Shipments'),
|
331 |
+
'url' => Mage::helper('adminhtml')->getUrl('postnl_admin/adminhtml_shipment/massCreateShipments'),
|
332 |
Â
);
|
333 |
Â
|
334 |
Â
$showOptions = Mage::getStoreConfig(self::XML_PATH_SHOW_OPTIONS, Mage_Core_Model_App::ADMIN_STORE_ID);
|
342 |
Â
'name' => 'product_options',
|
343 |
Â
'type' => 'select',
|
344 |
Â
'class' => 'required-entry',
|
345 |
+
'label' => $helper->__('Product options'),
|
346 |
Â
'values' => Mage::getModel('postnl_core/system_config_source_allProductOptions')
|
347 |
+
->getAvailableOptions(true, true, false, false, false, true, true),
|
348 |
Â
),
|
349 |
Â
);
|
350 |
Â
}
|
364 |
Â
/**
|
365 |
Â
* Applies sorting and filtering to the collection
|
366 |
Â
*
|
367 |
+
* @param TIG_PostNL_Model_Resource_Order_Grid_Collection $collection
|
368 |
Â
*
|
369 |
Â
* @return $this
|
370 |
Â
*/
|
431 |
Â
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
432 |
Â
$collection->addFieldToFilter('order.shipping_method', array('in' => $postnlShippingMethods));
|
433 |
Â
|
434 |
+
/**
|
435 |
+
* If the filter condition is PakjeGemak Express, filter out all non-PakjeGemak Express orders
|
436 |
+
*/
|
437 |
+
if ($filterCond == 'pakje_gemak_express') {
|
438 |
+
$collection->addFieldToFilter('postnl_order.type', array('eq' => 'PGE'));
|
439 |
+
|
440 |
+
return $this;
|
441 |
+
}
|
442 |
+
|
443 |
+
/**
|
444 |
+
* If the filter condition is evening delivery, filter out all other orders
|
445 |
+
*/
|
446 |
+
if ($filterCond == 'avond') {
|
447 |
+
$collection->addFieldToFilter('postnl_order.type', array('eq' => 'Avond'));
|
448 |
+
|
449 |
+
return $this;
|
450 |
+
}
|
451 |
+
|
452 |
Â
/**
|
453 |
Â
* If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
|
454 |
Â
*/
|
455 |
Â
if ($filterCond == 'pakje_gemak') {
|
456 |
Â
$collection->addFieldToFilter('is_pakje_gemak', array('eq' => 1));
|
457 |
+
$collection->addFieldToFilter('postnl_order.type', array(array('eq' => 'PG'), array('null' => true)));
|
458 |
+
|
459 |
+
return $this;
|
460 |
+
}
|
461 |
+
|
462 |
+
/**
|
463 |
+
* If the filter condition is Pakket Automaat, filter out all non-Pakket Automaat orders
|
464 |
+
*/
|
465 |
+
if ($filterCond == 'pakketautomaat') {
|
466 |
+
$collection->addFieldToFilter('is_pakketautomaat', array('eq' => 1));
|
467 |
+
$collection->addFieldToFilter(
|
468 |
+
'postnl_order.type',
|
469 |
+
array(
|
470 |
+
array('eq' => 'PA'),
|
471 |
+
array('null' => true)
|
472 |
+
)
|
473 |
+
);
|
474 |
Â
|
475 |
Â
return $this;
|
476 |
Â
}
|
477 |
Â
|
478 |
Â
/**
|
479 |
+
* If the filter condition is NL, filter out all orders not being shipped to the Netherlands. PakjeGemak,
|
480 |
+
* PakjeGmak Express, evening delivery and pakketautomaat shipments are also shipped to the Netherlands so we
|
481 |
+
* need to explicitely filter those as well.
|
482 |
Â
*/
|
483 |
Â
if ($filterCond == 'nl') {
|
484 |
Â
$collection->addFieldToFilter('country_id', $cond);
|
485 |
+
$collection->addFieldToFilter(
|
486 |
+
'postnl_order.type',
|
487 |
+
array(
|
488 |
+
array('eq' => 'Overdag'),
|
489 |
+
array('null' => true)
|
490 |
+
)
|
491 |
+
);
|
492 |
+
$collection->addFieldToFilter(
|
493 |
+
'is_pakje_gemak',
|
494 |
+
array(
|
495 |
+
array('eq' => 0),
|
496 |
+
array('null' => true)
|
497 |
+
)
|
498 |
+
);
|
499 |
+
$collection->addFieldToFilter(
|
500 |
+
'is_pakketautomaat',
|
501 |
+
array(
|
502 |
+
array('eq' => 0),
|
503 |
+
array('null' => true)
|
504 |
+
)
|
505 |
+
);
|
506 |
Â
|
507 |
Â
return $this;
|
508 |
Â
}
|
552 |
Â
|
553 |
Â
$cond = $column->getFilter()->getCondition();
|
554 |
Â
if ($field && isset($cond)) {
|
555 |
+
/**
|
556 |
+
* @var TIG_PostNL_Model_Resource_Order_Grid_Collection $collection
|
557 |
+
*/
|
558 |
+
$collection = $this->getCollection();
|
559 |
+
$collection->addFieldToFilter($field , $cond);
|
560 |
Â
}
|
561 |
Â
|
562 |
Â
return $this;
|
@@ -33,10 +33,17 @@
|
|
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)
|
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
|
42 |
Â
{
|
@@ -70,10 +77,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
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
|
77 |
Â
*/
|
78 |
Â
public function getOptionalColumnsToDisplay()
|
79 |
Â
{
|
@@ -85,6 +97,23 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
85 |
Â
return $columnsToDisplay;
|
86 |
Â
}
|
87 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
88 |
Â
/**
|
89 |
Â
* Observer that adds columns to the grid and allows these to be sorted and filtered properly
|
90 |
Â
*
|
@@ -115,18 +144,20 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
115 |
Â
$block = $observer->getBlock();
|
116 |
Â
$shipmentGridClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_GRID_BLOCK_NAME);
|
117 |
Â
|
118 |
-
if (
|
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)
|
@@ -190,12 +221,15 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
190 |
Â
array('postnl_shipment' => $resource->getTableName('postnl_core/shipment')),
|
191 |
Â
'`main_table`.`entity_id`=`postnl_shipment`.`shipment_id`',
|
192 |
Â
array(
|
193 |
-
'confirm_date'
|
194 |
-
'main_barcode'
|
195 |
-
'confirm_status'
|
196 |
-
'labels_printed'
|
197 |
-
'shipping_phase'
|
198 |
-
'parcel_count'
|
Â
|
|
Â
|
|
Â
|
|
199 |
Â
)
|
200 |
Â
);
|
201 |
Â
|
@@ -203,10 +237,13 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
203 |
Â
* Join tig_postnl_order table
|
204 |
Â
*/
|
205 |
Â
$select->joinLeft(
|
206 |
-
array('postnl_order' => $resource->getTableName('
|
207 |
Â
'`main_table`.`order_id`=`postnl_order`.`order_id`',
|
208 |
Â
array(
|
209 |
-
'is_pakje_gemak'
|
Â
|
|
Â
|
|
Â
|
|
210 |
Â
)
|
211 |
Â
);
|
212 |
Â
|
@@ -276,9 +313,13 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
276 |
Â
$block->addColumnAfter(
|
277 |
Â
'shipping_description',
|
278 |
Â
array(
|
279 |
-
'header'
|
280 |
-
'align'
|
281 |
-
'index'
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
282 |
Â
),
|
283 |
Â
$after
|
284 |
Â
);
|
@@ -299,10 +340,13 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
299 |
Â
'filter_condition_callback' => array($this, '_filterShipmentType'),
|
300 |
Â
'sortable' => false,
|
301 |
Â
'options' => array(
|
302 |
-
'nl'
|
303 |
-
'pakje_gemak'
|
304 |
-
'eu'
|
305 |
-
'global'
|
Â
|
|
Â
|
|
Â
|
|
306 |
Â
),
|
307 |
Â
),
|
308 |
Â
$after
|
@@ -311,6 +355,40 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
311 |
Â
$after = 'shipment_type';
|
312 |
Â
}
|
313 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
314 |
Â
if (in_array('confirm_date', $columnsToDisplay)) {
|
315 |
Â
$block->addColumnAfter(
|
316 |
Â
'confirm_date',
|
@@ -329,7 +407,28 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
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(
|
@@ -356,11 +455,11 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
356 |
Â
$block->addColumnAfter(
|
357 |
Â
'labels_printed',
|
358 |
Â
array(
|
359 |
-
'header' => $helper->__('Labels
|
360 |
Â
'type' => 'options',
|
361 |
Â
'index' => 'labels_printed',
|
362 |
Â
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_yesNo',
|
363 |
-
'frame_callback' => array($this, '
|
364 |
Â
'options' => array(
|
365 |
Â
1 => $helper->__('Yes'),
|
366 |
Â
0 => $helper->__('No'),
|
@@ -372,6 +471,27 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
372 |
Â
$after = 'labels_printed';
|
373 |
Â
}
|
374 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
375 |
Â
if (in_array('barcode', $columnsToDisplay)) {
|
376 |
Â
$block->addColumnAfter(
|
377 |
Â
'barcode',
|
@@ -408,19 +528,24 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
408 |
Â
$actionColumn = $block->getColumn('action');
|
409 |
Â
$actions = $actionColumn->getActions();
|
410 |
Â
|
411 |
-
$
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
Â
|
|
Â
|
|
417 |
Â
|
418 |
-
$
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
Â
|
|
Â
|
|
Â
|
|
424 |
Â
|
425 |
Â
$actionColumn->setActions($actions)
|
426 |
Â
->setWidth('150px')
|
@@ -434,10 +559,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
434 |
Â
/**
|
435 |
Â
* Decorates the confirm_sate column
|
436 |
Â
*
|
437 |
-
* @param string
|
438 |
-
* @param Mage_Sales_Model_Order_Shipment
|
439 |
Â
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
440 |
-
* @param boolean
|
441 |
Â
*
|
442 |
Â
* @return string
|
443 |
Â
*/
|
@@ -447,32 +572,54 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
447 |
Â
return $value;
|
448 |
Â
}
|
449 |
Â
|
450 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
451 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
452 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
453 |
Â
|
454 |
-
$
|
Â
|
|
Â
|
|
455 |
Â
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
456 |
-
|
457 |
Â
}
|
458 |
Â
|
459 |
Â
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRM_EXPIRED) {
|
460 |
-
|
461 |
Â
}
|
462 |
Â
|
463 |
Â
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED
|
464 |
-
&& date('Ymd',
|
465 |
Â
) {
|
466 |
-
|
467 |
-
}
|
468 |
-
|
Â
|
|
Â
|
|
469 |
Â
) {
|
470 |
-
|
471 |
-
} elseif ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
|
472 |
-
$class = 'grid-severity-minor';
|
473 |
Â
}
|
474 |
Â
|
475 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
476 |
Â
}
|
477 |
Â
|
478 |
Â
/**
|
@@ -491,6 +638,9 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
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)
|
@@ -520,7 +670,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
520 |
Â
*
|
521 |
Â
* @return string
|
522 |
Â
*/
|
523 |
-
public function
|
524 |
Â
{
|
525 |
Â
if ($isExport) {
|
526 |
Â
return $value;
|
@@ -559,9 +709,11 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
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
|
567 |
Â
$class = '';
|
@@ -593,26 +745,58 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
593 |
Â
*/
|
594 |
Â
protected function _addMassaction($block)
|
595 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
596 |
Â
$massactionBlock = $block->getMassactionBlock();
|
597 |
Â
|
598 |
Â
/**
|
599 |
Â
* Build all the mass action option arrays
|
600 |
Â
*/
|
601 |
Â
$printAndConfirmOptions = array(
|
602 |
-
'label'=>
|
603 |
-
'url'
|
604 |
Â
);
|
605 |
Â
|
606 |
Â
$printOptions = array(
|
607 |
-
'label'=>
|
608 |
-
'url'
|
609 |
Â
);
|
610 |
Â
|
611 |
Â
$confirmOptions = array(
|
612 |
-
'label'=>
|
613 |
-
'url'
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
614 |
Â
);
|
615 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
616 |
Â
/**
|
617 |
Â
* Check which mass action should be selected by default
|
618 |
Â
*/
|
@@ -634,26 +818,47 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
634 |
Â
case 'postnl_confirm_shipments':
|
635 |
Â
$confirmOptions['selected'] = true;
|
636 |
Â
break;
|
Â
|
|
Â
|
|
Â
|
|
637 |
Â
// no default
|
638 |
Â
}
|
639 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
640 |
Â
/**
|
641 |
-
* Add the mass actions to the grid
|
642 |
Â
*/
|
643 |
-
$
|
644 |
-
|
645 |
-
|
646 |
-
|
Â
|
|
Â
|
|
647 |
Â
|
648 |
-
$
|
649 |
-
|
650 |
-
|
651 |
-
|
Â
|
|
Â
|
|
652 |
Â
|
653 |
-
$
|
654 |
-
|
655 |
-
|
656 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
657 |
Â
|
658 |
Â
return $this;
|
659 |
Â
}
|
@@ -718,7 +923,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
718 |
Â
* @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
|
719 |
Â
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
720 |
Â
*
|
721 |
-
* @return
|
722 |
Â
*/
|
723 |
Â
protected function _filterShipmentType($collection, $column)
|
724 |
Â
{
|
@@ -731,20 +936,78 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
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('
|
Â
|
|
739 |
Â
|
740 |
Â
return $this;
|
741 |
Â
}
|
742 |
Â
|
743 |
Â
/**
|
744 |
-
* If the filter condition is
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
745 |
Â
*/
|
746 |
Â
if ($filterCond == 'nl') {
|
747 |
Â
$collection->addFieldToFilter('country_id', $cond);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
748 |
Â
|
749 |
Â
return $this;
|
750 |
Â
}
|
@@ -762,7 +1025,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
|
762 |
Â
}
|
763 |
Â
|
764 |
Â
/**
|
765 |
-
* Lastly, filter out all orders
|
766 |
Â
*/
|
767 |
Â
$collection->addFieldToFilter('country_id', array('neq' => 'NL'));
|
768 |
Â
$collection->addFieldToFilter('country_id', array('nin' => $euCountries));
|
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 |
Â
* Observer to edit the sales > shipments grid
|
40 |
+
*
|
41 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid setCollection(Mage_Sales_Model_Resource_Order_Shipment_Collection $value)
|
42 |
+
* @method Mage_Sales_Model_Resource_Order_Shipment_Collection getCollection()
|
43 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid setBlock(Mage_Adminhtml_Block_Sales_Shipment_Grid $value)
|
44 |
+
* @method Mage_Adminhtml_Block_Sales_Shipment_Grid getBlock()
|
45 |
+
* @method TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid setLabelSize(string $value)
|
46 |
+
* @method boolean hasLabelSize()
|
47 |
Â
*/
|
48 |
Â
class TIG_PostNL_Model_Adminhtml_Observer_ShipmentGrid extends Varien_Object
|
49 |
Â
{
|
77 |
Â
*/
|
78 |
Â
const XML_PATH_SHIPPING_GRID_MASSACTION_DEFAULT = 'postnl/cif_labels_and_confirming/shipping_grid_massaction_default';
|
79 |
Â
|
80 |
+
/**
|
81 |
+
* Xpath to label size setting.
|
82 |
+
*/
|
83 |
+
const XPATH_LABEL_SIZE = 'postnl/cif_labels_and_confirming/label_size';
|
84 |
+
|
85 |
Â
/**
|
86 |
Â
* Gets an array of optional columns to display
|
87 |
Â
*
|
88 |
+
* @return array
|
89 |
Â
*/
|
90 |
Â
public function getOptionalColumnsToDisplay()
|
91 |
Â
{
|
97 |
Â
return $columnsToDisplay;
|
98 |
Â
}
|
99 |
Â
|
100 |
+
/**
|
101 |
+
* Get the configured label size.
|
102 |
+
*
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
public function getLabelSize()
|
106 |
+
{
|
107 |
+
if ($this->hasLabelSize()) {
|
108 |
+
return $this->_getData('label_size');
|
109 |
+
}
|
110 |
+
|
111 |
+
$labelSize = Mage::getStoreConfig(self::XPATH_LABEL_SIZE, Mage_Core_Model_App::ADMIN_STORE_ID);
|
112 |
+
|
113 |
+
$this->setLabelSize($labelSize);
|
114 |
+
return $labelSize;
|
115 |
+
}
|
116 |
+
|
117 |
Â
/**
|
118 |
Â
* Observer that adds columns to the grid and allows these to be sorted and filtered properly
|
119 |
Â
*
|
144 |
Â
$block = $observer->getBlock();
|
145 |
Â
$shipmentGridClass = Mage::getConfig()->getBlockClassName(self::SHIPMENT_GRID_BLOCK_NAME);
|
146 |
Â
|
147 |
+
if (!($block instanceof $shipmentGridClass)) {
|
148 |
Â
return $this;
|
149 |
Â
}
|
150 |
Â
|
151 |
+
/**
|
152 |
+
* @var Mage_Adminhtml_Block_Sales_Shipment_Grid $block
|
153 |
+
* @var Mage_Sales_Model_Resource_Order_Shipment_Collection $currentCollection
|
154 |
+
*/
|
155 |
Â
$currentCollection = $block->getCollection();
|
156 |
Â
$select = $currentCollection->getSelect()->reset(Zend_Db_Select::WHERE);
|
157 |
Â
|
158 |
Â
/**
|
159 |
Â
* replace the collection as the default collection has a bug preventing it from being reset.
|
160 |
+
* Without being able to reset it, we can't edit it. Therefore we are forced to replace it altogether.
|
Â
|
|
Â
|
|
161 |
Â
*/
|
162 |
Â
$collection = Mage::getResourceModel('postnl/order_shipment_grid_collection');
|
163 |
Â
$collection->setSelect($select)
|
221 |
Â
array('postnl_shipment' => $resource->getTableName('postnl_core/shipment')),
|
222 |
Â
'`main_table`.`entity_id`=`postnl_shipment`.`shipment_id`',
|
223 |
Â
array(
|
224 |
+
'confirm_date' => 'postnl_shipment.confirm_date',
|
225 |
+
'main_barcode' => 'postnl_shipment.main_barcode',
|
226 |
+
'confirm_status' => 'postnl_shipment.confirm_status',
|
227 |
+
'labels_printed' => 'postnl_shipment.labels_printed',
|
228 |
+
'shipping_phase' => 'postnl_shipment.shipping_phase',
|
229 |
+
'parcel_count' => 'postnl_shipment.parcel_count',
|
230 |
+
'is_parcelware_exported' => 'postnl_shipment.is_parcelware_exported',
|
231 |
+
'product_code' => 'postnl_shipment.product_code',
|
232 |
+
'extra_cover_amount' => 'postnl_shipment.extra_cover_amount',
|
233 |
Â
)
|
234 |
Â
);
|
235 |
Â
|
237 |
Â
* Join tig_postnl_order table
|
238 |
Â
*/
|
239 |
Â
$select->joinLeft(
|
240 |
+
array('postnl_order' => $resource->getTableName('postnl_core/order')),
|
241 |
Â
'`main_table`.`order_id`=`postnl_order`.`order_id`',
|
242 |
Â
array(
|
243 |
+
'is_pakje_gemak' => 'postnl_order.is_pakje_gemak',
|
244 |
+
'delivery_date' => 'postnl_order.delivery_date',
|
245 |
+
'is_pakketautomaat' => 'postnl_order.is_pakketautomaat',
|
246 |
+
'delivery_option_type' => 'postnl_order.type',
|
247 |
Â
)
|
248 |
Â
);
|
249 |
Â
|
313 |
Â
$block->addColumnAfter(
|
314 |
Â
'shipping_description',
|
315 |
Â
array(
|
316 |
+
'header' => $helper->__('Shipping Method'),
|
317 |
+
'align' => 'left',
|
318 |
+
'index' => 'shipping_description',
|
319 |
+
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_shippingDescription',
|
320 |
+
'column_css_class' => 'nobr',
|
321 |
+
'options' => Mage::getModel('postnl_core/system_config_source_allProductOptions')
|
322 |
+
->getAvailableOptions(false, true, false, false, true, false),
|
323 |
Â
),
|
324 |
Â
$after
|
325 |
Â
);
|
340 |
Â
'filter_condition_callback' => array($this, '_filterShipmentType'),
|
341 |
Â
'sortable' => false,
|
342 |
Â
'options' => array(
|
343 |
+
'nl' => $helper->__('Domestic'),
|
344 |
+
'pakje_gemak' => $helper->__('PakjeGemak'),
|
345 |
+
'eu' => $helper->__('EPS'),
|
346 |
+
'global' => $helper->__('GlobalPack'),
|
347 |
+
'pakketautomaat' => $helper->__('Parcel Dispenser'),
|
348 |
+
'avond' => $helper->__('Evening Delivery'),
|
349 |
+
'pakje_gemak_express' => $helper->__('Early Pickup'),
|
350 |
Â
),
|
351 |
Â
),
|
352 |
Â
$after
|
355 |
Â
$after = 'shipment_type';
|
356 |
Â
}
|
357 |
Â
|
358 |
+
if (in_array('product_code', $columnsToDisplay)) {
|
359 |
+
$block->addColumnAfter(
|
360 |
+
'product_code',
|
361 |
+
array(
|
362 |
+
'header' => $helper->__('Shipping Product'),
|
363 |
+
'align' => 'left',
|
364 |
+
'index' => 'product_code',
|
365 |
+
'type' => 'options',
|
366 |
+
'column_css_class' => 'nobr',
|
367 |
+
'options' => Mage::getModel('postnl_core/system_config_source_allProductOptions')
|
368 |
+
->getAvailableOptions(false, true, false, false, true, false),
|
369 |
+
),
|
370 |
+
$after
|
371 |
+
);
|
372 |
+
|
373 |
+
$after = 'product_code';
|
374 |
+
}
|
375 |
+
|
376 |
+
if (in_array('extra_cover_amount', $columnsToDisplay)) {
|
377 |
+
$block->addColumnAfter(
|
378 |
+
'extra_cover_amount',
|
379 |
+
array(
|
380 |
+
'header' => $helper->__('Extra Cover'),
|
381 |
+
'align' => 'left',
|
382 |
+
'index' => 'extra_cover_amount',
|
383 |
+
'type' => 'currency',
|
384 |
+
'currency_code' => Mage::app()->getStore()->getBaseCurrencyCode(), //returns the base currency code for the admin store
|
385 |
+
),
|
386 |
+
$after
|
387 |
+
);
|
388 |
+
|
389 |
+
$after = 'extra_cover_amount';
|
390 |
+
}
|
391 |
+
|
392 |
Â
if (in_array('confirm_date', $columnsToDisplay)) {
|
393 |
Â
$block->addColumnAfter(
|
394 |
Â
'confirm_date',
|
407 |
Â
$after = 'confirm_date';
|
408 |
Â
}
|
409 |
Â
|
410 |
+
if (in_array('delivery_date', $columnsToDisplay)) {
|
411 |
+
$block->addColumnAfter(
|
412 |
+
'delivery_date',
|
413 |
+
array(
|
414 |
+
'type' => 'date',
|
415 |
+
'header' => $helper->__('Delivery Date'),
|
416 |
+
'index' => 'delivery_date',
|
417 |
+
'filter_index' => 'postnl_order.delivery_date',
|
418 |
+
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_deliveryDate',
|
419 |
+
'width' => '100px',
|
420 |
+
'filter' => false,
|
421 |
+
),
|
422 |
+
$after
|
423 |
+
);
|
424 |
+
|
425 |
+
$after = 'delivery_date';
|
426 |
+
}
|
427 |
+
|
428 |
Â
if (in_array('confirm_status', $columnsToDisplay)) {
|
429 |
+
/**
|
430 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
431 |
+
*/
|
432 |
Â
$postnlShipmentClass = Mage::app()->getConfig()->getModelClassName('postnl_core/shipment');
|
433 |
Â
|
434 |
Â
$block->addColumnAfter(
|
455 |
Â
$block->addColumnAfter(
|
456 |
Â
'labels_printed',
|
457 |
Â
array(
|
458 |
+
'header' => $helper->__('Labels Printed'),
|
459 |
Â
'type' => 'options',
|
460 |
Â
'index' => 'labels_printed',
|
461 |
Â
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_yesNo',
|
462 |
+
'frame_callback' => array($this, 'decorateYesNo'),
|
463 |
Â
'options' => array(
|
464 |
Â
1 => $helper->__('Yes'),
|
465 |
Â
0 => $helper->__('No'),
|
471 |
Â
$after = 'labels_printed';
|
472 |
Â
}
|
473 |
Â
|
474 |
+
if (in_array('is_parcelware_exported', $columnsToDisplay)) {
|
475 |
+
$block->addColumnAfter(
|
476 |
+
'is_parcelware_exported',
|
477 |
+
array(
|
478 |
+
'header' => $helper->__('Exported to Parcelware'),
|
479 |
+
'align' => 'left',
|
480 |
+
'type' => 'options',
|
481 |
+
'index' => 'is_parcelware_exported',
|
482 |
+
'renderer' => 'postnl_adminhtml/widget_grid_column_renderer_yesNo',
|
483 |
+
'frame_callback' => array($this, 'decorateYesNo'),
|
484 |
+
'options' => array(
|
485 |
+
1 => $helper->__('Yes'),
|
486 |
+
0 => $helper->__('No'),
|
487 |
+
),
|
488 |
+
),
|
489 |
+
$after
|
490 |
+
);
|
491 |
+
|
492 |
+
$after = 'is_parcelware_exported';
|
493 |
+
}
|
494 |
+
|
495 |
Â
if (in_array('barcode', $columnsToDisplay)) {
|
496 |
Â
$block->addColumnAfter(
|
497 |
Â
'barcode',
|
528 |
Â
$actionColumn = $block->getColumn('action');
|
529 |
Â
$actions = $actionColumn->getActions();
|
530 |
Â
|
531 |
+
if ($helper->checkIsPostnlActionAllowed('print_label')) {
|
532 |
+
$actions[] = array(
|
533 |
+
'caption' => $helper->__('Print label'),
|
534 |
+
'style' => 'cursor:pointer;',
|
535 |
+
'is_postnl' => true, //custom flag for renderer
|
536 |
+
'code' => 'postnl_print_label',
|
537 |
+
);
|
538 |
+
}
|
539 |
Â
|
540 |
+
if ($helper->checkIsPostnlActionAllowed('confirm')) {
|
541 |
+
$actions[] = array(
|
542 |
+
'caption' => $helper->__('Confirm'),
|
543 |
+
'url' => array('base' => 'postnl/adminhtml_shipment/confirm'),
|
544 |
+
'field' => 'shipment_id',
|
545 |
+
'is_postnl' => true, //custom flag for renderer
|
546 |
+
'code' => 'postnl_confirm',
|
547 |
+
);
|
548 |
+
}
|
549 |
Â
|
550 |
Â
$actionColumn->setActions($actions)
|
551 |
Â
->setWidth('150px')
|
559 |
Â
/**
|
560 |
Â
* Decorates the confirm_sate column
|
561 |
Â
*
|
562 |
+
* @param string|null $value
|
563 |
+
* @param Mage_Sales_Model_Order_Shipment $row
|
564 |
Â
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
565 |
+
* @param boolean $isExport
|
566 |
Â
*
|
567 |
Â
* @return string
|
568 |
Â
*/
|
572 |
Â
return $value;
|
573 |
Â
}
|
574 |
Â
|
575 |
+
$class = $this->_getConfirmDateClass($row, $column);
|
576 |
+
|
577 |
+
return '<span class="'.$class.'"><span>'.$value.'</span></span>';
|
578 |
+
}
|
579 |
Â
|
580 |
+
/**
|
581 |
+
* Gets classname for the confirmDate column of the current row.
|
582 |
+
*
|
583 |
+
* @param Mage_Sales_Model_Order_Shipment $row
|
584 |
+
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
585 |
+
*
|
586 |
+
* @return string
|
587 |
+
*/
|
588 |
+
protected function _getConfirmDateClass($row, $column)
|
589 |
+
{
|
590 |
+
/**
|
591 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
592 |
+
*/
|
593 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
594 |
Â
|
595 |
+
$origValue = $row->getData($column->getIndex());
|
596 |
+
$dateModel = Mage::getModel('core/date');
|
597 |
+
|
598 |
Â
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRMED) {
|
599 |
+
return 'grid-severity-notice';
|
600 |
Â
}
|
601 |
Â
|
602 |
Â
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_CONFIRM_EXPIRED) {
|
603 |
+
return 'grid-severity-critical';
|
604 |
Â
}
|
605 |
Â
|
606 |
Â
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED
|
607 |
+
&& date('Ymd', $dateModel->gmtTimestamp()) == date('Ymd', strtotime($origValue))
|
608 |
Â
) {
|
609 |
+
return 'grid-severity-major';
|
610 |
+
}
|
611 |
+
|
612 |
+
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED
|
613 |
+
&& $dateModel->gmtTimestamp() > strtotime($origValue)
|
614 |
Â
) {
|
615 |
+
return 'grid-severity-critical';
|
Â
|
|
Â
|
|
616 |
Â
}
|
617 |
Â
|
618 |
+
if ($row->getData('confirm_status') == $postnlShipmentClass::CONFIRM_STATUS_UNCONFIRMED) {
|
619 |
+
return 'grid-severity-minor';
|
620 |
+
}
|
621 |
+
|
622 |
+
return '';
|
623 |
Â
}
|
624 |
Â
|
625 |
Â
/**
|
638 |
Â
return $value;
|
639 |
Â
}
|
640 |
Â
|
641 |
+
/**
|
642 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
643 |
+
*/
|
644 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
645 |
Â
switch ($row->getData($column->getIndex())) {
|
646 |
Â
case null: //rows with no value (non-PostNL shipments)
|
670 |
Â
*
|
671 |
Â
* @return string
|
672 |
Â
*/
|
673 |
+
public function decorateYesNo($value, $row, $column, $isExport)
|
674 |
Â
{
|
675 |
Â
if ($isExport) {
|
676 |
Â
return $value;
|
709 |
Â
return $value;
|
710 |
Â
}
|
711 |
Â
|
712 |
+
/**
|
713 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipmentClass
|
714 |
+
*/
|
715 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
716 |
Â
|
Â
|
|
717 |
Â
switch ($row->getData($column->getIndex())) {
|
718 |
Â
case null: //rows with no value (non-PostNL shipments) or unconfirmed shipments
|
719 |
Â
$class = '';
|
745 |
Â
*/
|
746 |
Â
protected function _addMassaction($block)
|
747 |
Â
{
|
748 |
+
$helper = Mage::helper('postnl/parcelware');
|
749 |
+
$adminhtmlHelper = Mage::helper('adminhtml');
|
750 |
+
|
751 |
Â
$massactionBlock = $block->getMassactionBlock();
|
752 |
Â
|
753 |
Â
/**
|
754 |
Â
* Build all the mass action option arrays
|
755 |
Â
*/
|
756 |
Â
$printAndConfirmOptions = array(
|
757 |
+
'label' => $helper->__('PostNL - Print shipping labels & confirm shipment'),
|
758 |
+
'url' => $adminhtmlHelper->getUrl('postnl_admin/adminhtml_shipment/massPrintLabelsAndConfirm'),
|
759 |
Â
);
|
760 |
Â
|
761 |
Â
$printOptions = array(
|
762 |
+
'label' => $helper->__('PostNL - Print shipping labels'),
|
763 |
+
'url' => $adminhtmlHelper->getUrl('postnl_admin/adminhtml_shipment/massPrintLabels'),
|
764 |
Â
);
|
765 |
Â
|
766 |
Â
$confirmOptions = array(
|
767 |
+
'label' => $helper->__('PostNL - Confirm shipments'),
|
768 |
+
'url' => $adminhtmlHelper->getUrl('postnl_admin/adminhtml_shipment/massConfirm'),
|
769 |
+
);
|
770 |
+
|
771 |
+
$parcelWareOptions = array(
|
772 |
+
'label' => $helper->__('PostNL - Create Parcelware export'),
|
773 |
+
'url' => $adminhtmlHelper->getUrl('postnl_admin/adminhtml_shipment/massCreateParcelwareExport')
|
774 |
Â
);
|
775 |
Â
|
776 |
+
/**
|
777 |
+
* Add an additional option to the 'label printing' mass actions if the configured label size is A4.
|
778 |
+
*/
|
779 |
+
if ($this->getLabelSize() == 'A4') {
|
780 |
+
/**
|
781 |
+
* Get the additional options block for 'label printing' mass actions.
|
782 |
+
*/
|
783 |
+
$printAdditional = Mage::app()->getLayout()
|
784 |
+
->createBlock('postnl_adminhtml/widget_grid_massaction_labelStartPos');
|
785 |
+
|
786 |
+
$printAdditional->setData(
|
787 |
+
array(
|
788 |
+
'name' => 'print_start_pos',
|
789 |
+
'label' => $helper->__('Choose printing start position'),
|
790 |
+
)
|
791 |
+
);
|
792 |
+
|
793 |
+
/**
|
794 |
+
* Add the additional option block.
|
795 |
+
*/
|
796 |
+
$printAndConfirmOptions['additional'] = $printAdditional;
|
797 |
+
$printOptions['additional'] = $printAdditional;
|
798 |
+
}
|
799 |
+
|
800 |
Â
/**
|
801 |
Â
* Check which mass action should be selected by default
|
802 |
Â
*/
|
818 |
Â
case 'postnl_confirm_shipments':
|
819 |
Â
$confirmOptions['selected'] = true;
|
820 |
Â
break;
|
821 |
+
case 'postnl_parcelware_export':
|
822 |
+
$parcelWareOptions['selected'] = true;
|
823 |
+
break;
|
824 |
Â
// no default
|
825 |
Â
}
|
826 |
Â
|
827 |
+
$printAllowed = $helper->checkIsPostnlActionAllowed('print_label');
|
828 |
+
$confirmAllowed = $helper->checkIsPostnlActionAllowed('confirm');
|
829 |
+
$exportAllowed = $helper->checkIsPostnlActionAllowed('create_parcelware_export');
|
830 |
+
|
831 |
Â
/**
|
832 |
+
* Add the mass actions to the grid if the current admin user is allowed to use them.
|
833 |
Â
*/
|
834 |
+
if ($printAllowed && $confirmAllowed) {
|
835 |
+
$massactionBlock->addItem(
|
836 |
+
'postnl_print_labels_and_confirm',
|
837 |
+
$printAndConfirmOptions
|
838 |
+
);
|
839 |
+
}
|
840 |
Â
|
841 |
+
if ($printAllowed) {
|
842 |
+
$massactionBlock->addItem(
|
843 |
+
'postnl_print_labels',
|
844 |
+
$printOptions
|
845 |
+
);
|
846 |
+
}
|
847 |
Â
|
848 |
+
if ($confirmAllowed) {
|
849 |
+
$massactionBlock->addItem(
|
850 |
+
'postnl_confirm_shipments',
|
851 |
+
$confirmOptions
|
852 |
+
);
|
853 |
+
}
|
854 |
+
|
855 |
+
$parcelwareExportEnabled = $helper->isParcelwareExportEnabled();
|
856 |
+
if ($parcelwareExportEnabled && $exportAllowed) {
|
857 |
+
$massactionBlock->addItem(
|
858 |
+
'postnl_parcelware_export',
|
859 |
+
$parcelWareOptions
|
860 |
+
);
|
861 |
+
}
|
862 |
Â
|
863 |
Â
return $this;
|
864 |
Â
}
|
923 |
Â
* @param TIG_PostNL_Model_Resource_Order_Shipment_Grid_Collection $collection
|
924 |
Â
* @param Mage_Adminhtml_Block_Widget_Grid_Column $column
|
925 |
Â
*
|
926 |
+
* @return $this
|
927 |
Â
*/
|
928 |
Â
protected function _filterShipmentType($collection, $column)
|
929 |
Â
{
|
936 |
Â
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
937 |
Â
$collection->addFieldToFilter('order.shipping_method', array('in' => $postnlShippingMethods));
|
938 |
Â
|
939 |
+
/**
|
940 |
+
* If the filter condition is PakjeGemak Express, filter out all non-PakjeGemak Express orders
|
941 |
+
*/
|
942 |
+
if ($filterCond == 'pakje_gemak_express') {
|
943 |
+
$collection->addFieldToFilter('postnl_order.type', array('eq' => 'PGE'));
|
944 |
+
|
945 |
+
return $this;
|
946 |
+
}
|
947 |
+
|
948 |
+
/**
|
949 |
+
* If the filter condition is evening delivery, filter out all other orders
|
950 |
+
*/
|
951 |
+
if ($filterCond == 'avond') {
|
952 |
+
$collection->addFieldToFilter('postnl_order.type', array('eq' => 'Avond'));
|
953 |
+
|
954 |
+
return $this;
|
955 |
+
}
|
956 |
+
|
957 |
Â
/**
|
958 |
Â
* If the filter condition is PakjeGemak, filter out all non-PakjeGemak orders
|
959 |
Â
*/
|
960 |
Â
if ($filterCond == 'pakje_gemak') {
|
961 |
+
$collection->addFieldToFilter('is_pakje_gemak', array('eq' => 1));
|
962 |
+
$collection->addFieldToFilter('postnl_order.type', array(array('eq' => 'PG'), array('null' => true)));
|
963 |
Â
|
964 |
Â
return $this;
|
965 |
Â
}
|
966 |
Â
|
967 |
Â
/**
|
968 |
+
* If the filter condition is Pakket Automaat, filter out all non-Pakket Automaat orders
|
969 |
+
*/
|
970 |
+
if ($filterCond == 'pakketautomaat') {
|
971 |
+
$collection->addFieldToFilter('is_pakketautomaat', array('eq' => 1));
|
972 |
+
$collection->addFieldToFilter(
|
973 |
+
'postnl_order.type',
|
974 |
+
array(
|
975 |
+
array('eq' => 'PA'),
|
976 |
+
array('null' => true)
|
977 |
+
)
|
978 |
+
);
|
979 |
+
|
980 |
+
return $this;
|
981 |
+
}
|
982 |
+
|
983 |
+
/**
|
984 |
+
* If the filter condition is NL, filter out all orders not being shipped to the Netherlands. PakjeGemak,
|
985 |
+
* PakjeGmak Express, evening delivery and pakketautomaat shipments are also shipped to the Netherlands so we
|
986 |
+
* need to explicitely filter those as well.
|
987 |
Â
*/
|
988 |
Â
if ($filterCond == 'nl') {
|
989 |
Â
$collection->addFieldToFilter('country_id', $cond);
|
990 |
+
$collection->addFieldToFilter(
|
991 |
+
'postnl_order.type',
|
992 |
+
array(
|
993 |
+
array('eq' => 'Overdag'),
|
994 |
+
array('null' => true)
|
995 |
+
)
|
996 |
+
);
|
997 |
+
$collection->addFieldToFilter(
|
998 |
+
'is_pakje_gemak',
|
999 |
+
array(
|
1000 |
+
array('eq' => 0),
|
1001 |
+
array('null' => true)
|
1002 |
+
)
|
1003 |
+
);
|
1004 |
+
$collection->addFieldToFilter(
|
1005 |
+
'is_pakketautomaat',
|
1006 |
+
array(
|
1007 |
+
array('eq' => 0),
|
1008 |
+
array('null' => true)
|
1009 |
+
)
|
1010 |
+
);
|
1011 |
Â
|
1012 |
Â
return $this;
|
1013 |
Â
}
|
1025 |
Â
}
|
1026 |
Â
|
1027 |
Â
/**
|
1028 |
+
* Lastly, filter out all orders who are being shipped to the Netherlands or other EU countries
|
1029 |
Â
*/
|
1030 |
Â
$collection->addFieldToFilter('country_id', array('neq' => 'NL'));
|
1031 |
Â
$collection->addFieldToFilter('country_id', array('nin' => $euCountries));
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*
|
39 |
Â
* Observer to edit the shipment view
|
@@ -41,12 +41,12 @@
|
|
41 |
Â
class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
42 |
Â
{
|
43 |
Â
/**
|
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 |
Â
*
|
@@ -70,7 +70,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
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);
|
@@ -91,25 +91,55 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
91 |
Â
return $this;
|
92 |
Â
}
|
93 |
Â
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
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 '
|
@@ -120,10 +150,10 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
120 |
Â
$block->addButton('reset_confirmation', array(
|
121 |
Â
'label' => $helper->__('PostNL - Change Confirmation'),
|
122 |
Â
'onclick' => "deleteConfirm('"
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
Â
'class' => 'delete',
|
128 |
Â
));
|
129 |
Â
}
|
@@ -131,20 +161,21 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
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 |
-
|
140 |
-
|
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 "
|
@@ -162,6 +193,19 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
162 |
Â
));
|
163 |
Â
}
|
164 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
165 |
Â
return $this;
|
166 |
Â
}
|
167 |
Â
|
@@ -175,7 +219,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
175 |
Â
public function getPrintShippingLabelUrl($shipmentId)
|
176 |
Â
{
|
177 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
178 |
-
'
|
179 |
Â
array('shipment_id' => $shipmentId)
|
180 |
Â
);
|
181 |
Â
|
@@ -192,7 +236,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
192 |
Â
public function getResetConfirmationUrl($shipmentId)
|
193 |
Â
{
|
194 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
195 |
-
'
|
196 |
Â
array('shipment_id' => $shipmentId)
|
197 |
Â
);
|
198 |
Â
|
@@ -209,7 +253,7 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
209 |
Â
public function getRemoveLabelsUrl($shipmentId)
|
210 |
Â
{
|
211 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
212 |
-
'
|
213 |
Â
array('shipment_id' => $shipmentId)
|
214 |
Â
);
|
215 |
Â
|
@@ -226,10 +270,30 @@ class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
|
226 |
Â
public function getResendTrackAndTraceUrl($shipmentId)
|
227 |
Â
{
|
228 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
229 |
-
'
|
230 |
Â
array('shipment_id' => $shipmentId)
|
231 |
Â
);
|
232 |
Â
|
233 |
Â
return $url;
|
234 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
235 |
Â
}
|
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 |
Â
* Observer to edit the shipment view
|
41 |
Â
class TIG_PostNL_Model_Adminhtml_Observer_ShipmentView
|
42 |
Â
{
|
43 |
Â
/**
|
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 |
Â
*
|
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);
|
91 |
Â
return $this;
|
92 |
Â
}
|
93 |
Â
|
94 |
+
$this->addPostnlButtons($block, $shipment);
|
95 |
+
|
96 |
+
return $this;
|
97 |
+
}
|
98 |
+
|
99 |
+
/**
|
100 |
+
* Add new PostNL buttons to the page.
|
101 |
+
*
|
102 |
+
* @param Mage_Adminhtml_BLock_Sales_Order_Shipment_View $block
|
103 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
104 |
+
*
|
105 |
+
* @return $this
|
106 |
+
*/
|
107 |
+
public function addPostnlButtons(Mage_Adminhtml_BLock_Sales_Order_Shipment_View $block,
|
108 |
+
Mage_Sales_Model_Order_Shipment $shipment)
|
109 |
+
{
|
110 |
+
$helper = Mage::helper('postnl');
|
111 |
Â
|
112 |
Â
/**
|
113 |
Â
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
114 |
Â
*/
|
115 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getId(), 'shipment_id');
|
116 |
Â
|
117 |
+
/**
|
118 |
+
* Check which actions are allowed.
|
119 |
+
*/
|
120 |
+
$confirmAllowed = $helper->checkIsPostnlActionAllowed('confirm');
|
121 |
+
$printAllowed = $helper->checkIsPostnlActionAllowed('print_label');
|
122 |
+
$deleteLabelsAllowed = $helper->checkIsPostnlActionAllowed('delete_labels');
|
123 |
+
$resetConfirmAllowed = $helper->checkIsPostnlActionAllowed(array('reset_confirmation', 'delete_labels'));
|
124 |
+
$sendTrackAndTraceAllowed = $helper->checkIsPostnlActionAllowed('send_track_and_trace');
|
125 |
+
|
126 |
+
/**
|
127 |
+
* Add a button to print this shipment's shipping labels
|
128 |
+
*/
|
129 |
+
if ($printAllowed) {
|
130 |
+
$printShippingLabelUrl = $this->getPrintShippingLabelUrl($shipment->getId());
|
131 |
+
|
132 |
+
$block->addButton('print_shipping_label', array(
|
133 |
+
'label' => $helper->__('PostNL - Print Shipping Label'),
|
134 |
+
'onclick' => "printLabel('{$printShippingLabelUrl}')",
|
135 |
+
'class' => 'download',
|
136 |
+
));
|
137 |
+
}
|
138 |
+
|
139 |
Â
/**
|
140 |
Â
* Add a button to reset the shipment's confirmation status
|
141 |
Â
*/
|
142 |
+
if ($postnlShipment->canResetConfirmation() && $resetConfirmAllowed) {
|
143 |
Â
$resetConfirmationUrl = $this->getResetConfirmationUrl($shipment->getId());
|
144 |
Â
$resetWarningMessage = $helper->__(
|
145 |
Â
'Are you sure that you wish to reset the confirmation status of this shipment? You will need to '
|
150 |
Â
$block->addButton('reset_confirmation', array(
|
151 |
Â
'label' => $helper->__('PostNL - Change Confirmation'),
|
152 |
Â
'onclick' => "deleteConfirm('"
|
153 |
+
. $resetWarningMessage
|
154 |
+
. "', '"
|
155 |
+
. $resetConfirmationUrl
|
156 |
+
. "')",
|
157 |
Â
'class' => 'delete',
|
158 |
Â
));
|
159 |
Â
}
|
161 |
Â
/**
|
162 |
Â
* Update the send tracking info button so that it sends our info, instead of the default
|
163 |
Â
*/
|
164 |
+
if ($postnlShipment->isConfirmed() && $sendTrackAndTraceAllowed) {
|
165 |
Â
$resendTrackAndTraceUrl = $this->getResendTrackAndTraceUrl($shipment->getId());
|
166 |
+
|
167 |
Â
$block->updateButton('save', 'label', $helper->__('PostNL - Send Tracking Information'));
|
168 |
Â
$block->updateButton('save', 'onclick',
|
169 |
Â
"deleteConfirm('"
|
170 |
+
. $helper->__('Are you sure you want to send PostNL tracking information to the customer?')
|
171 |
+
. "', '" . $resendTrackAndTraceUrl . "')"
|
172 |
Â
);
|
173 |
Â
}
|
174 |
Â
|
175 |
Â
/**
|
176 |
Â
* Add a button to remove any stored shipping labels for this shipment.
|
177 |
Â
*/
|
178 |
+
if ($postnlShipment->hasLabels() && !$postnlShipment->isConfirmed() && $deleteLabelsAllowed) {
|
179 |
Â
$removeLabelsUrl = $this->getRemoveLabelsUrl($shipment->getId());
|
180 |
Â
$removeLabelsWarningMessage = $helper->__(
|
181 |
Â
"Are you sure that you wish to remove this shipment\'s shipping label? You will need to print a new "
|
193 |
Â
));
|
194 |
Â
}
|
195 |
Â
|
196 |
+
/**
|
197 |
+
* Add a button to confirm this shipment.
|
198 |
+
*/
|
199 |
+
if (!$postnlShipment->isConfirmed() && $confirmAllowed) {
|
200 |
+
$confirmUrl = $this->getConfirmUrl($shipment->getId());
|
201 |
+
|
202 |
+
$block->addButton('confirm_shipment', array(
|
203 |
+
'label' => $helper->__('PostNL - Confirm Shipment'),
|
204 |
+
'onclick' => "setLocation('{$confirmUrl}')",
|
205 |
+
'class' => 'save',
|
206 |
+
));
|
207 |
+
}
|
208 |
+
|
209 |
Â
return $this;
|
210 |
Â
}
|
211 |
Â
|
219 |
Â
public function getPrintShippingLabelUrl($shipmentId)
|
220 |
Â
{
|
221 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
222 |
+
'postnl_admin/adminhtml_shipment/printLabel',
|
223 |
Â
array('shipment_id' => $shipmentId)
|
224 |
Â
);
|
225 |
Â
|
236 |
Â
public function getResetConfirmationUrl($shipmentId)
|
237 |
Â
{
|
238 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
239 |
+
'postnl_admin/adminhtml_shipment/resetConfirmation',
|
240 |
Â
array('shipment_id' => $shipmentId)
|
241 |
Â
);
|
242 |
Â
|
253 |
Â
public function getRemoveLabelsUrl($shipmentId)
|
254 |
Â
{
|
255 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
256 |
+
'postnl_admin/adminhtml_shipment/removeLabels',
|
257 |
Â
array('shipment_id' => $shipmentId)
|
258 |
Â
);
|
259 |
Â
|
270 |
Â
public function getResendTrackAndTraceUrl($shipmentId)
|
271 |
Â
{
|
272 |
Â
$url = Mage::helper('adminhtml')->getUrl(
|
273 |
+
'postnl_admin/adminhtml_shipment/sendTrackAndTrace',
|
274 |
Â
array('shipment_id' => $shipmentId)
|
275 |
Â
);
|
276 |
Â
|
277 |
Â
return $url;
|
278 |
Â
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Get adminhtml url for PostNL confirm shipment action
|
282 |
+
*
|
283 |
+
* @param int $shipmentId The ID of the current shipment
|
284 |
+
*
|
285 |
+
* @return string
|
286 |
+
*/
|
287 |
+
public function getConfirmUrl($shipmentId)
|
288 |
+
{
|
289 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
290 |
+
'postnl_admin/adminhtml_shipment/confirm',
|
291 |
+
array(
|
292 |
+
'shipment_id' => $shipmentId,
|
293 |
+
'return_to_view' => true,
|
294 |
+
)
|
295 |
+
);
|
296 |
+
|
297 |
+
return $url;
|
298 |
+
}
|
299 |
Â
}
|
@@ -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.
|
@@ -33,14 +33,14 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for optional shipment grid columns
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -59,10 +59,22 @@ class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
|
59 |
Â
'value' => 'shipment_type',
|
60 |
Â
'label' => $helper->__('Shipment Type')
|
61 |
Â
),
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
62 |
Â
array(
|
63 |
Â
'value' => 'confirm_date',
|
64 |
Â
'label' => $helper->__('Send Date')
|
65 |
Â
),
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
66 |
Â
array(
|
67 |
Â
'value' => 'confirm_status',
|
68 |
Â
'label' => $helper->__('Confirm Status')
|
@@ -71,6 +83,10 @@ class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
|
71 |
Â
'value' => 'labels_printed',
|
72 |
Â
'label' => $helper->__('Labels Printed')
|
73 |
Â
),
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
74 |
Â
array(
|
75 |
Â
'value' => 'barcode',
|
76 |
Â
'label' => $helper->__('Barcode')
|
@@ -80,7 +96,7 @@ class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
|
80 |
Â
'label' => $helper->__('Shipping Phase')
|
81 |
Â
),
|
82 |
Â
);
|
83 |
-
|
84 |
Â
return $columns;
|
85 |
Â
}
|
86 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridColumns
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for optional shipment grid columns
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
59 |
Â
'value' => 'shipment_type',
|
60 |
Â
'label' => $helper->__('Shipment Type')
|
61 |
Â
),
|
62 |
+
array(
|
63 |
+
'value' => 'product_code',
|
64 |
+
'label' => $helper->__('Shipping Product')
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'value' => 'extra_cover_amount',
|
68 |
+
'label' => $helper->__('Extra Cover')
|
69 |
+
),
|
70 |
Â
array(
|
71 |
Â
'value' => 'confirm_date',
|
72 |
Â
'label' => $helper->__('Send Date')
|
73 |
Â
),
|
74 |
+
array(
|
75 |
+
'value' => 'delivery_date',
|
76 |
+
'label' => $helper->__('Delivery Date')
|
77 |
+
),
|
78 |
Â
array(
|
79 |
Â
'value' => 'confirm_status',
|
80 |
Â
'label' => $helper->__('Confirm Status')
|
83 |
Â
'value' => 'labels_printed',
|
84 |
Â
'label' => $helper->__('Labels Printed')
|
85 |
Â
),
|
86 |
+
array(
|
87 |
+
'value' => 'is_parcelware_exported',
|
88 |
+
'label' => $helper->__('Exported to Parcelware')
|
89 |
+
),
|
90 |
Â
array(
|
91 |
Â
'value' => 'barcode',
|
92 |
Â
'label' => $helper->__('Barcode')
|
96 |
Â
'label' => $helper->__('Shipping Phase')
|
97 |
Â
),
|
98 |
Â
);
|
99 |
+
|
100 |
Â
return $columns;
|
101 |
Â
}
|
102 |
Â
}
|
@@ -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.
|
@@ -33,14 +33,14 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for available shipment grid mass actions
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -59,8 +59,12 @@ class TIG_PostNL_Model_Core_System_Config_Source_ShipmentGridMassAction
|
|
59 |
Â
'value' => 'postnl_confirm_shipments',
|
60 |
Â
'label' => $helper->__('Confirm shipments'),
|
61 |
Â
),
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
62 |
Â
);
|
63 |
-
|
64 |
Â
return $options;
|
65 |
Â
}
|
66 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Model_Adminhtml_System_Config_Source_ShipmentGridMassAction
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for available shipment grid mass actions
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
59 |
Â
'value' => 'postnl_confirm_shipments',
|
60 |
Â
'label' => $helper->__('Confirm shipments'),
|
61 |
Â
),
|
62 |
+
array(
|
63 |
+
'value' => 'postnl_parcelware_export',
|
64 |
+
'label' => $helper->__('Parcelware export'),
|
65 |
+
),
|
66 |
Â
);
|
67 |
+
|
68 |
Â
return $options;
|
69 |
Â
}
|
70 |
Â
}
|
@@ -33,21 +33,31 @@
|
|
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)
|
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 |
-
* @
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
44 |
Â
*/
|
45 |
-
class TIG_PostNL_Model_Carrier_Postnl
|
46 |
-
extends Mage_Shipping_Model_Carrier_Abstract
|
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 |
Â
*
|
@@ -61,18 +71,63 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
61 |
Â
* @var boolean
|
62 |
Â
*/
|
63 |
Â
protected $_isFixed = true;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
64 |
Â
protected $_default_condition_name = 'package_weight';
|
65 |
Â
|
Â
|
|
Â
|
|
Â
|
|
66 |
Â
protected $_conditionNames = array();
|
67 |
Â
|
Â
|
|
Â
|
|
Â
|
|
68 |
Â
public function __construct()
|
69 |
Â
{
|
70 |
Â
parent::__construct();
|
71 |
-
foreach ($this->getCode('condition_name') as $k
|
72 |
Â
$this->_conditionNames[] = $k;
|
73 |
Â
}
|
74 |
Â
}
|
75 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
/**
|
77 |
Â
* get PostNL Carrier helper
|
78 |
Â
*
|
@@ -80,7 +135,7 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
80 |
Â
*/
|
81 |
Â
public function getHelper()
|
82 |
Â
{
|
83 |
-
if ($this->
|
84 |
Â
return $this->getData('helper');
|
85 |
Â
}
|
86 |
Â
|
@@ -103,8 +158,9 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
103 |
Â
/**
|
104 |
Â
* Collect shipping rate
|
105 |
Â
*
|
106 |
-
* @param Mage_Shipping_Model_Rate_Request $
|
107 |
Â
*
|
Â
|
|
108 |
Â
* @return Mage_Shipping_Model_Rate_Result|void
|
109 |
Â
*/
|
110 |
Â
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
@@ -141,25 +197,31 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
141 |
Â
}
|
142 |
Â
}
|
143 |
Â
|
144 |
-
|
145 |
Â
$rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, Mage::app()->getStore()->getId());
|
146 |
Â
|
147 |
Â
if ($rateType == 'flat') {
|
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 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
161 |
Â
}
|
162 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
163 |
Â
protected function _getFlatRate($request)
|
164 |
Â
{
|
165 |
Â
$freeBoxes = 0;
|
@@ -187,7 +249,8 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
187 |
Â
if ($this->getConfigData('type') == 'O') { // per order
|
188 |
Â
$shippingPrice = $this->getConfigData('price');
|
189 |
Â
} elseif ($this->getConfigData('type') == 'I') { // per item
|
190 |
-
$shippingPrice = ($request->getPackageQty() * $this->getConfigData('price'))
|
Â
|
|
191 |
Â
} else {
|
192 |
Â
$shippingPrice = false;
|
193 |
Â
}
|
@@ -207,6 +270,7 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
207 |
Â
$shippingPrice = '0.00';
|
208 |
Â
}
|
209 |
Â
|
Â
|
|
210 |
Â
|
211 |
Â
$method->setPrice($shippingPrice);
|
212 |
Â
$method->setCost($shippingPrice);
|
@@ -217,7 +281,12 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
217 |
Â
return $result;
|
218 |
Â
}
|
219 |
Â
|
220 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
221 |
Â
{
|
222 |
Â
// exclude Virtual products price from Package value if pre-configured
|
223 |
Â
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
|
@@ -239,6 +308,7 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
239 |
Â
|
240 |
Â
// Free shipping by qty
|
241 |
Â
$freeQty = 0;
|
Â
|
|
242 |
Â
if ($request->getAllItems()) {
|
243 |
Â
$freePackageValue = 0;
|
244 |
Â
foreach ($request->getAllItems() as $item) {
|
@@ -266,7 +336,7 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
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 |
Â
|
@@ -283,25 +353,18 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
283 |
Â
$request->setPackageWeight($oldWeight);
|
284 |
Â
$request->setPackageQty($oldQty);
|
285 |
Â
|
Â
|
|
286 |
Â
if (!empty($rate) && $rate['price'] >= 0) {
|
287 |
-
$method = Mage::getModel('shipping/rate_result_method');
|
288 |
-
|
289 |
-
$method->setCarrier('postnl');
|
290 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
291 |
-
|
292 |
-
$method->setMethod('tablerate');
|
293 |
-
$method->setMethodTitle($this->getConfigData('name'));
|
294 |
-
|
295 |
Â
if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
|
296 |
Â
$shippingPrice = 0;
|
297 |
Â
} else {
|
298 |
Â
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
|
299 |
Â
}
|
300 |
Â
|
301 |
-
$
|
302 |
-
$method->setCost($rate['cost']);
|
303 |
Â
|
304 |
-
$
|
Â
|
|
305 |
Â
} elseif (empty($rate) && $request->getFreeShipping() === true) {
|
306 |
Â
/**
|
307 |
Â
* was applied promotion rule for whole cart
|
@@ -314,34 +377,90 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
314 |
Â
$rate = $this->getRate($request);
|
315 |
Â
if (!empty($rate) && $rate['price'] >= 0) {
|
316 |
Â
$method = Mage::getModel('shipping/rate_result_method');
|
317 |
-
|
318 |
-
$method->setCarrier('postnl');
|
319 |
-
$method->setCarrierTitle($this->getConfigData('title'));
|
320 |
-
|
321 |
-
$method->setMethod('tablerate');
|
322 |
-
$method->setMethodTitle($this->getConfigData('name'));
|
323 |
-
|
324 |
-
$method->setPrice(0);
|
325 |
-
$method->setCost(0);
|
326 |
-
|
327 |
-
$result->append($method);
|
328 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
329 |
Â
} else {
|
330 |
Â
$error = Mage::getModel('shipping/rate_result_error');
|
331 |
Â
$error->setCarrier('tablerate');
|
332 |
Â
$error->setCarrierTitle($this->getConfigData('title'));
|
333 |
Â
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
334 |
Â
$result->append($error);
|
Â
|
|
Â
|
|
335 |
Â
}
|
336 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
337 |
Â
return $result;
|
338 |
Â
}
|
339 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
340 |
Â
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
341 |
Â
{
|
342 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
343 |
Â
}
|
344 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
345 |
Â
public function getCode($type, $code='')
|
346 |
Â
{
|
347 |
Â
$codes = array(
|
@@ -394,8 +513,6 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
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)
|
401 |
Â
{
|
@@ -423,8 +540,6 @@ class TIG_PostNL_Model_Carrier_Postnl
|
|
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 |
Â
{
|
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 |
Â
* PostNL shipping method model
|
40 |
Â
*
|
41 |
+
* @method boolean hasQuote()
|
42 |
+
* @method TIG_PostNL_Model_Carrier_Postnl setQuote(Mage_Sales_Model_Quote $value)
|
43 |
+
* @method boolean hasPostnlOrder()
|
44 |
+
* @method TIG_PostNL_Model_Carrier_Postnl setPostnlOrder(TIG_PostNL_Model_Core_Order $value)
|
45 |
+
* @method boolean hasHelper()
|
46 |
+
* @method TIG_PostNL_Model_Carrier_Postnl setHelper(TIG_PostNL_Helper_Carrier $value)
|
47 |
Â
*/
|
48 |
+
class TIG_PostNL_Model_Carrier_Postnl extends Mage_Shipping_Model_Carrier_Abstract
|
Â
|
|
49 |
Â
implements Mage_Shipping_Model_Carrier_Interface
|
50 |
Â
{
|
51 |
+
/**
|
52 |
+
* Rate type (tablerate or flatrate).
|
53 |
+
*/
|
54 |
Â
const XML_PATH_RATE_TYPE = 'carriers/postnl/rate_type';
|
55 |
Â
|
56 |
+
/**
|
57 |
+
* Whether to use Magento's tabelrates or PostNL's.
|
58 |
+
*/
|
59 |
+
const XPATH_RATE_SOURCE = 'carriers/postnl/rate_source';
|
60 |
+
|
61 |
Â
/**
|
62 |
Â
* PostNL carrier code
|
63 |
Â
*
|
71 |
Â
* @var boolean
|
72 |
Â
*/
|
73 |
Â
protected $_isFixed = true;
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @var string
|
77 |
+
*/
|
78 |
Â
protected $_default_condition_name = 'package_weight';
|
79 |
Â
|
80 |
+
/**
|
81 |
+
* @var array
|
82 |
+
*/
|
83 |
Â
protected $_conditionNames = array();
|
84 |
Â
|
85 |
+
/**
|
86 |
+
* Class constructor.
|
87 |
+
*/
|
88 |
Â
public function __construct()
|
89 |
Â
{
|
90 |
Â
parent::__construct();
|
91 |
+
foreach (array_keys($this->getCode('condition_name')) as $k) {
|
92 |
Â
$this->_conditionNames[] = $k;
|
93 |
Â
}
|
94 |
Â
}
|
95 |
Â
|
96 |
+
/**
|
97 |
+
* @return Mage_Sales_Model_Quote
|
98 |
+
*/
|
99 |
+
public function getQuote()
|
100 |
+
{
|
101 |
+
if ($this->hasQuote()) {
|
102 |
+
return $this->getData('quote');
|
103 |
+
}
|
104 |
+
|
105 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
106 |
+
$this->setQuote($quote);
|
107 |
+
|
108 |
+
return $quote;
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @return TIG_PostNL_Model_Core_Order
|
113 |
+
*/
|
114 |
+
public function getPostnlOrder()
|
115 |
+
{
|
116 |
+
if ($this->hasPostnlOrder()) {
|
117 |
+
return $this->getData('postnl_order');
|
118 |
+
}
|
119 |
+
|
120 |
+
$quote = $this->getQuote();
|
121 |
+
$postnlOrder = Mage::getModel('postnl_core/order');
|
122 |
+
|
123 |
+
if ($quote->getId()) {
|
124 |
+
$postnlOrder->load($quote->getId(), 'quote_id');
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->setPostnlOrder($postnlOrder);
|
128 |
+
return $postnlOrder;
|
129 |
+
}
|
130 |
+
|
131 |
Â
/**
|
132 |
Â
* get PostNL Carrier helper
|
133 |
Â
*
|
135 |
Â
*/
|
136 |
Â
public function getHelper()
|
137 |
Â
{
|
138 |
+
if ($this->hasHelper()) {
|
139 |
Â
return $this->getData('helper');
|
140 |
Â
}
|
141 |
Â
|
158 |
Â
/**
|
159 |
Â
* Collect shipping rate
|
160 |
Â
*
|
161 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
162 |
Â
*
|
163 |
+
* @throws TIG_PostNL_Exception
|
164 |
Â
* @return Mage_Shipping_Model_Rate_Result|void
|
165 |
Â
*/
|
166 |
Â
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
197 |
Â
}
|
198 |
Â
}
|
199 |
Â
|
Â
|
|
200 |
Â
$rateType = Mage::getStoreConfig(self::XML_PATH_RATE_TYPE, Mage::app()->getStore()->getId());
|
201 |
Â
|
202 |
Â
if ($rateType == 'flat') {
|
203 |
Â
$result = $this->_getFlatRate($request);
|
Â
|
|
204 |
Â
}
|
205 |
Â
|
206 |
Â
if ($rateType == 'table') {
|
207 |
Â
$result = $this->_getTableRate($request);
|
Â
|
|
208 |
Â
}
|
209 |
Â
|
210 |
+
if (!isset($result)) {
|
211 |
+
throw new TIG_PostNL_Exception(
|
212 |
+
$helper->__('Invalid rate type requested: %s', $rateType),
|
213 |
+
'POSTNL-0036'
|
214 |
+
);
|
215 |
+
}
|
216 |
+
|
217 |
+
return $result;
|
218 |
Â
}
|
219 |
Â
|
220 |
+
/**
|
221 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
222 |
+
*
|
223 |
+
* @return Mage_Shipping_Model_Rate_Result
|
224 |
+
*/
|
225 |
Â
protected function _getFlatRate($request)
|
226 |
Â
{
|
227 |
Â
$freeBoxes = 0;
|
249 |
Â
if ($this->getConfigData('type') == 'O') { // per order
|
250 |
Â
$shippingPrice = $this->getConfigData('price');
|
251 |
Â
} elseif ($this->getConfigData('type') == 'I') { // per item
|
252 |
+
$shippingPrice = ($request->getPackageQty() * $this->getConfigData('price'))
|
253 |
+
- ($this->getFreeBoxes() * $this->getConfigData('price'));
|
254 |
Â
} else {
|
255 |
Â
$shippingPrice = false;
|
256 |
Â
}
|
270 |
Â
$shippingPrice = '0.00';
|
271 |
Â
}
|
272 |
Â
|
273 |
+
$shippingPrice += $this->getPostnlFee();
|
274 |
Â
|
275 |
Â
$method->setPrice($shippingPrice);
|
276 |
Â
$method->setCost($shippingPrice);
|
281 |
Â
return $result;
|
282 |
Â
}
|
283 |
Â
|
284 |
+
/**
|
285 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
286 |
+
*
|
287 |
+
* @return Mage_Shipping_Model_Rate_Result
|
288 |
+
*/
|
289 |
+
protected function _getTableRate(Mage_Shipping_Model_Rate_Request $request)
|
290 |
Â
{
|
291 |
Â
// exclude Virtual products price from Package value if pre-configured
|
292 |
Â
if (!$this->getConfigFlag('include_virtual_price') && $request->getAllItems()) {
|
308 |
Â
|
309 |
Â
// Free shipping by qty
|
310 |
Â
$freeQty = 0;
|
311 |
+
$freePackageValue = false;
|
312 |
Â
if ($request->getAllItems()) {
|
313 |
Â
$freePackageValue = 0;
|
314 |
Â
foreach ($request->getAllItems() as $item) {
|
336 |
Â
if ($freePackageValue) {
|
337 |
Â
$request->setPackageValue($request->getPackageValue() - $freePackageValue);
|
338 |
Â
}
|
339 |
+
|
340 |
Â
$conditionName = $this->getConfigData('condition_name');
|
341 |
Â
$request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
|
342 |
Â
|
353 |
Â
$request->setPackageWeight($oldWeight);
|
354 |
Â
$request->setPackageQty($oldQty);
|
355 |
Â
|
356 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
357 |
Â
if (!empty($rate) && $rate['price'] >= 0) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
358 |
Â
if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
|
359 |
Â
$shippingPrice = 0;
|
360 |
Â
} else {
|
361 |
Â
$shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']);
|
362 |
Â
}
|
363 |
Â
|
364 |
+
$shippingPrice += $this->getPostnlFee();
|
Â
|
|
365 |
Â
|
366 |
+
$price = $shippingPrice;
|
367 |
+
$cost = $rate['cost'];
|
368 |
Â
} elseif (empty($rate) && $request->getFreeShipping() === true) {
|
369 |
Â
/**
|
370 |
Â
* was applied promotion rule for whole cart
|
377 |
Â
$rate = $this->getRate($request);
|
378 |
Â
if (!empty($rate) && $rate['price'] >= 0) {
|
379 |
Â
$method = Mage::getModel('shipping/rate_result_method');
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
380 |
Â
}
|
381 |
+
|
382 |
+
$price = 0;
|
383 |
+
$cost = 0;
|
384 |
Â
} else {
|
385 |
Â
$error = Mage::getModel('shipping/rate_result_error');
|
386 |
Â
$error->setCarrier('tablerate');
|
387 |
Â
$error->setCarrierTitle($this->getConfigData('title'));
|
388 |
Â
$error->setErrorMessage($this->getConfigData('specificerrmsg'));
|
389 |
Â
$result->append($error);
|
390 |
+
|
391 |
+
return $result;
|
392 |
Â
}
|
393 |
Â
|
394 |
+
$method->setCarrier('postnl');
|
395 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
396 |
+
|
397 |
+
$method->setMethod('tablerate');
|
398 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
399 |
+
|
400 |
+
$method->setPrice($price);
|
401 |
+
$method->setCost($cost);
|
402 |
+
|
403 |
+
$result->append($method);
|
404 |
+
|
405 |
Â
return $result;
|
406 |
Â
}
|
407 |
Â
|
408 |
+
/**
|
409 |
+
* @return float|int
|
410 |
+
*/
|
411 |
+
public function getPostnlFee()
|
412 |
+
{
|
413 |
+
$fee = 0;
|
414 |
+
$type = null;
|
415 |
+
$includingTax = false;
|
416 |
+
|
417 |
+
$postnlOrder = $this->getPostnlOrder();
|
418 |
+
if ($postnlOrder->getId() && $postnlOrder->getIsActive()) {
|
419 |
+
$type = $postnlOrder->getType();
|
420 |
+
} else {
|
421 |
+
return $fee;
|
422 |
+
}
|
423 |
+
|
424 |
+
if (Mage::getSingleton('tax/config')->shippingPriceIncludesTax()) {
|
425 |
+
$includingTax = true;
|
426 |
+
}
|
427 |
+
|
428 |
+
if ($type == 'PGE') {
|
429 |
+
$fee = Mage::helper('postnl/deliveryOptions')->getExpressFee(false, $includingTax);
|
430 |
+
} else if ($type == 'Avond' ) {
|
431 |
+
$fee = Mage::helper('postnl/deliveryOptions')->getEveningFee(false, $includingTax);
|
432 |
+
}
|
433 |
+
|
434 |
+
return $fee;
|
435 |
+
}
|
436 |
+
|
437 |
+
/**
|
438 |
+
* @param Mage_Shipping_Model_Rate_Request $request
|
439 |
+
*
|
440 |
+
* @return array|bool
|
441 |
+
*/
|
442 |
Â
public function getRate(Mage_Shipping_Model_Rate_Request $request)
|
443 |
Â
{
|
444 |
+
$websiteId = $request->getWebsiteId();
|
445 |
+
$website = Mage::getModel('core/website')->load($websiteId);
|
446 |
+
|
447 |
+
$rateSource = $website->getConfig(self::XPATH_RATE_SOURCE);
|
448 |
+
if ($rateSource == 'shipping_tablerate') {
|
449 |
+
$rate = Mage::getResourceModel('shipping/carrier_tablerate')->getRate($request);
|
450 |
+
} else {
|
451 |
+
$rate = Mage::getResourceModel('postnl_carrier/tablerate')->getRate($request);
|
452 |
+
}
|
453 |
+
|
454 |
+
return $rate;
|
455 |
Â
}
|
456 |
Â
|
457 |
+
/**
|
458 |
+
* @param $type
|
459 |
+
* @param string $code
|
460 |
+
*
|
461 |
+
* @return mixed
|
462 |
+
* @throws Mage_Core_Exception
|
463 |
+
*/
|
464 |
Â
public function getCode($type, $code='')
|
465 |
Â
{
|
466 |
Â
$codes = array(
|
513 |
Â
* @param string $tracking
|
514 |
Â
*
|
515 |
Â
* @return Mage_Shipping_Model_Tracking_Result_Status
|
Â
|
|
Â
|
|
516 |
Â
*/
|
517 |
Â
public function getTrackingInfo($tracking)
|
518 |
Â
{
|
540 |
Â
* @param string $number
|
541 |
Â
*
|
542 |
Â
* @return Mage_Sales_Model_Order_Shipment_Track
|
Â
|
|
Â
|
|
543 |
Â
*/
|
544 |
Â
protected function _getTrackByNumber($number)
|
545 |
Â
{
|
@@ -0,0 +1,152 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
class TIG_PostNL_Model_Carrier_Resource_Tablerate extends Mage_Shipping_Model_Resource_Carrier_Tablerate
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Define main table and id field name.
|
43 |
+
*
|
44 |
+
* @return void
|
45 |
+
*/
|
46 |
+
protected function _construct()
|
47 |
+
{
|
48 |
+
$this->_init('postnl_carrier/tablerate', 'pk');
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Upload table rate file and import data from it
|
53 |
+
*
|
54 |
+
* @param Varien_Object $object
|
55 |
+
*
|
56 |
+
* @throws Mage_Core_Exception
|
57 |
+
*
|
58 |
+
* @return Mage_Shipping_Model_Resource_Carrier_Tablerate
|
59 |
+
*/
|
60 |
+
public function uploadAndImport(Varien_Object $object)
|
61 |
+
{
|
62 |
+
if (empty($_FILES['groups']['tmp_name']['postnl']['fields']['import']['value'])) {
|
63 |
+
return $this;
|
64 |
+
}
|
65 |
+
|
66 |
+
$csvFile = $_FILES['groups']['tmp_name']['postnl']['fields']['import']['value'];
|
67 |
+
$website = Mage::app()->getWebsite($object->getScopeId());
|
68 |
+
|
69 |
+
$this->_importWebsiteId = (int)$website->getId();
|
70 |
+
$this->_importUniqueHash = array();
|
71 |
+
$this->_importErrors = array();
|
72 |
+
$this->_importedRows = 0;
|
73 |
+
|
74 |
+
$io = new Varien_Io_File();
|
75 |
+
$info = pathinfo($csvFile);
|
76 |
+
$io->open(array('path' => $info['dirname']));
|
77 |
+
$io->streamOpen($info['basename'], 'r');
|
78 |
+
|
79 |
+
// check and skip headers
|
80 |
+
$headers = $io->streamReadCsv();
|
81 |
+
if ($headers === false || count($headers) < 5) {
|
82 |
+
$io->streamClose();
|
83 |
+
Mage::throwException(Mage::helper('shipping')->__('Invalid Table Rates File Format'));
|
84 |
+
}
|
85 |
+
|
86 |
+
if ($object->getData('groups/postnl/fields/condition_name/inherit') == '1') {
|
87 |
+
$conditionName = (string)Mage::getConfig()->getNode('default/carriers/postnl/condition_name');
|
88 |
+
} else {
|
89 |
+
$conditionName = $object->getData('groups/postnl/fields/condition_name/value');
|
90 |
+
}
|
91 |
+
$this->_importConditionName = $conditionName;
|
92 |
+
|
93 |
+
$adapter = $this->_getWriteAdapter();
|
94 |
+
$adapter->beginTransaction();
|
95 |
+
|
96 |
+
try {
|
97 |
+
$rowNumber = 1;
|
98 |
+
$importData = array();
|
99 |
+
|
100 |
+
$this->_loadDirectoryCountries();
|
101 |
+
$this->_loadDirectoryRegions();
|
102 |
+
|
103 |
+
// delete old data by website and condition name
|
104 |
+
$condition = array(
|
105 |
+
'website_id = ?' => $this->_importWebsiteId,
|
106 |
+
'condition_name = ?' => $this->_importConditionName
|
107 |
+
);
|
108 |
+
$adapter->delete($this->getMainTable(), $condition);
|
109 |
+
|
110 |
+
while (false !== ($csvLine = $io->streamReadCsv())) {
|
111 |
+
$rowNumber ++;
|
112 |
+
|
113 |
+
if (empty($csvLine)) {
|
114 |
+
continue;
|
115 |
+
}
|
116 |
+
|
117 |
+
$row = $this->_getImportRow($csvLine, $rowNumber);
|
118 |
+
if ($row !== false) {
|
119 |
+
$importData[] = $row;
|
120 |
+
}
|
121 |
+
|
122 |
+
if (count($importData) == 5000) {
|
123 |
+
$this->_saveImportData($importData);
|
124 |
+
$importData = array();
|
125 |
+
}
|
126 |
+
}
|
127 |
+
$this->_saveImportData($importData);
|
128 |
+
$io->streamClose();
|
129 |
+
} catch (Mage_Core_Exception $e) {
|
130 |
+
$adapter->rollback();
|
131 |
+
$io->streamClose();
|
132 |
+
Mage::throwException($e->getMessage());
|
133 |
+
} catch (Exception $e) {
|
134 |
+
$adapter->rollback();
|
135 |
+
$io->streamClose();
|
136 |
+
Mage::logException($e);
|
137 |
+
Mage::throwException(Mage::helper('shipping')->__('An error occurred while import table rates.'));
|
138 |
+
}
|
139 |
+
|
140 |
+
$adapter->commit();
|
141 |
+
|
142 |
+
if ($this->_importErrors) {
|
143 |
+
$error = Mage::helper('shipping')->__(
|
144 |
+
'File has not been imported. See the following list of errors: %s',
|
145 |
+
implode(" \n", $this->_importErrors)
|
146 |
+
);
|
147 |
+
Mage::throwException($error);
|
148 |
+
}
|
149 |
+
|
150 |
+
return $this;
|
151 |
+
}
|
152 |
+
}
|
@@ -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 |
+
class TIG_PostNL_Model_Carrier_Resource_Tablerate_Collection
|
40 |
+
extends Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
|
41 |
+
{
|
42 |
+
/**
|
43 |
+
* Define resource model and item
|
44 |
+
*
|
45 |
+
*/
|
46 |
+
protected function _construct()
|
47 |
+
{
|
48 |
+
$this->_init('postnl_carrier/tablerate');
|
49 |
+
$this->_shipTable = $this->getMainTable();
|
50 |
+
$this->_countryTable = $this->getTable('directory/country');
|
51 |
+
$this->_regionTable = $this->getTable('directory/country_region');
|
52 |
+
}
|
53 |
+
}
|
@@ -0,0 +1,50 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
class TIG_PostNL_Model_Carrier_System_Config_Backend_Tablerate extends Mage_Core_Model_Config_Data
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Upload a new csv file.
|
43 |
+
*
|
44 |
+
* @return void
|
45 |
+
*/
|
46 |
+
public function _afterSave()
|
47 |
+
{
|
48 |
+
Mage::getResourceModel('postnl_carrier/tablerate')->uploadAndImport($this);
|
49 |
+
}
|
50 |
+
}
|
@@ -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.
|
@@ -33,14 +33,14 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Carrier_System_Config_Source_RateType
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for rate type options
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -56,7 +56,7 @@ class TIG_PostNL_Model_Carrier_System_Config_Source_RateType
|
|
56 |
Â
'label' => $helper->__('Table'),
|
57 |
Â
),
|
58 |
Â
);
|
59 |
-
|
60 |
Â
return $options;
|
61 |
Â
}
|
62 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Model_Carrier_System_Config_Source_RateType
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for rate type options
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
56 |
Â
'label' => $helper->__('Table'),
|
57 |
Â
),
|
58 |
Â
);
|
59 |
+
|
60 |
Â
return $options;
|
61 |
Â
}
|
62 |
Â
}
|
@@ -0,0 +1,62 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
class TIG_PostNL_Model_Carrier_System_Config_Source_TablerateSource
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Returns an option array for rate source options.
|
43 |
+
*
|
44 |
+
* @return array
|
45 |
+
*/
|
46 |
+
public function toOptionArray()
|
47 |
+
{
|
48 |
+
$helper = Mage::helper('postnl');
|
49 |
+
$options = array(
|
50 |
+
array(
|
51 |
+
'value' => 'shipping_tablerate',
|
52 |
+
'label' => $helper->__("Use Magento's Table Rates"),
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'value' => 'postnl_tablerate',
|
56 |
+
'label' => $helper->__('Use seperate table rates for PostNL'),
|
57 |
+
),
|
58 |
+
);
|
59 |
+
|
60 |
+
return $options;
|
61 |
+
}
|
62 |
+
}
|
@@ -0,0 +1,54 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
* This is a dummy class for the tablerate export/import functionality.
|
40 |
+
*/
|
41 |
+
class TIG_PostNL_Model_Carrier_Tablerate extends Mage_Core_Model_Abstract
|
42 |
+
{
|
43 |
+
/**
|
44 |
+
* Prefix of model events names
|
45 |
+
*
|
46 |
+
* @var string
|
47 |
+
*/
|
48 |
+
protected $_eventPrefix = 'postnl_carrier_tablerate';
|
49 |
+
|
50 |
+
public function _construct()
|
51 |
+
{
|
52 |
+
$this->_init('postnl_carrier/tablerate');
|
53 |
+
}
|
54 |
+
}
|
@@ -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.
|
@@ -33,8 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
40 |
Â
{
|
@@ -42,7 +44,7 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
42 |
Â
* Webshop ID config option path
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_WEBSHOP_ID = 'postnl/cif/webshop_id';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* XML paths for various options
|
48 |
Â
*/
|
@@ -56,65 +58,71 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
56 |
Â
const XML_PATH_SERVICE_URL = 'postnl/checkout/service_url';
|
57 |
Â
const XML_PATH_USE_MOBILE = 'postnl/checkout/use_mobile';
|
58 |
Â
const XML_PATH_USE_DOB = 'postnl/checkout/use_dob';
|
59 |
-
|
60 |
Â
/**
|
61 |
Â
* XML path to available payment methods.
|
62 |
-
* N.B. missing last part
|
63 |
Â
*/
|
64 |
Â
const XML_PATH_CHECKOUT_PAYMENT_METHODS = 'postnl/checkout_payment_methods';
|
65 |
-
|
66 |
Â
/**
|
67 |
Â
* XML paths for shipment reference info
|
68 |
Â
*/
|
69 |
Â
const XML_PATH_SHIPMENT_REFERENCE_TYPE = 'postnl/cif_labels_and_confirming/shipment_reference_type';
|
70 |
Â
const XML_PATH_CUSTOM_SHIPMENT_REFERENCE = 'postnl/cif_labels_and_confirming/custom_shipment_reference';
|
71 |
-
|
72 |
Â
/**
|
73 |
Â
* Check if the module is set to test mode
|
74 |
-
*
|
75 |
Â
* @see TIG_PostNL_Helper_Checkout::isTestMode()
|
76 |
-
*
|
Â
|
|
Â
|
|
77 |
Â
* @return boolean
|
78 |
Â
*/
|
79 |
Â
public function isTestMode($storeId = false)
|
80 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
81 |
Â
$testMode = Mage::helper('postnl/checkout')->isTestMode($storeId);
|
82 |
-
|
83 |
Â
return $testMode;
|
84 |
Â
}
|
85 |
-
|
86 |
Â
/**
|
87 |
Â
* Gets the current store Id
|
88 |
-
*
|
89 |
Â
* @return integer
|
90 |
Â
*/
|
91 |
Â
public function getStoreId()
|
92 |
Â
{
|
93 |
-
if ($this->
|
94 |
Â
return $this->getData('store_id');
|
95 |
Â
}
|
96 |
-
|
97 |
Â
$storeId = Mage::app()->getStore()->getId();
|
98 |
-
|
99 |
Â
$this->setStoreId($storeId);
|
100 |
Â
return $storeId;
|
101 |
Â
}
|
102 |
-
|
103 |
Â
/**
|
104 |
Â
* Checks if the PostNL service is available
|
105 |
-
*
|
106 |
Â
* @return string
|
107 |
-
*
|
108 |
Â
* @throws TIG_PostNL_Exception
|
109 |
Â
*/
|
110 |
Â
public function ping()
|
111 |
-
{
|
112 |
Â
$response = $this->call(
|
113 |
-
'checkout',
|
114 |
Â
'PingStatus'
|
115 |
Â
);
|
116 |
-
|
117 |
-
if (!is_object($response)
|
118 |
Â
|| !isset($response->Status)
|
119 |
Â
) {
|
120 |
Â
throw new TIG_PostNL_Exception(
|
@@ -122,17 +130,17 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
122 |
Â
'POSTNL-0038'
|
123 |
Â
);
|
124 |
Â
}
|
125 |
-
|
126 |
Â
return $response->Status;
|
127 |
Â
}
|
128 |
Â
|
129 |
Â
/**
|
130 |
Â
* Prepares a new PostNL checkout order
|
131 |
-
*
|
132 |
Â
* @param null|Mage_Sales_Model_Quote $quote
|
133 |
-
*
|
134 |
Â
* @return string
|
135 |
-
*
|
136 |
Â
* @throws TIG_PostNL_Exception
|
137 |
Â
*/
|
138 |
Â
public function prepareOrder($quote = null)
|
@@ -140,16 +148,16 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
140 |
Â
if (is_null($quote)) {
|
141 |
Â
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
142 |
Â
}
|
143 |
-
|
144 |
Â
if (!$quote) {
|
145 |
Â
throw new TIG_PostNL_Exception(
|
146 |
Â
Mage::helper('postnl')->__('No quote available to initiate PostNL Checkout.'),
|
147 |
Â
'POSTNL-0039'
|
148 |
Â
);
|
149 |
Â
}
|
150 |
-
|
151 |
Â
$this->setStoreId($quote->getStoreId());
|
152 |
-
|
153 |
Â
/**
|
154 |
Â
* Get all data required to form the SOAP request
|
155 |
Â
*/
|
@@ -162,50 +170,50 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
162 |
Â
$order = $this->_getOrder($quote);
|
163 |
Â
$restrictions = $this->_getRestrictions();
|
164 |
Â
$webshop = $this->_getWebshop();
|
165 |
-
|
166 |
Â
$soapParams = array(
|
167 |
Â
'Order' => $order,
|
168 |
Â
'Webshop' => $webshop,
|
169 |
Â
);
|
170 |
-
|
171 |
Â
if (!empty($paymentMethods)) {
|
172 |
Â
$soapParams['AangebodenBetaalMethoden'] = $paymentMethods;
|
173 |
Â
}
|
174 |
-
|
175 |
Â
if (!empty($communictionOptions)) {
|
176 |
Â
$soapParams['AangebodenCommunicatieOpties'] = $communictionOptions;
|
177 |
Â
}
|
178 |
-
|
179 |
Â
if (!empty($restrictions)) {
|
180 |
Â
$soapParams['Restrictions'] = $restrictions;
|
181 |
Â
}
|
182 |
-
|
183 |
Â
if ($customer) {
|
184 |
Â
$soapParams['Consument'] = $customer;
|
185 |
Â
}
|
186 |
-
|
187 |
Â
if (!empty($optional)) {
|
188 |
Â
$soapParams['Optional'] = $optional;
|
189 |
Â
}
|
190 |
-
|
191 |
Â
if ($contact) {
|
192 |
Â
$soapParams['Contact'] = $contact;
|
193 |
Â
}
|
194 |
-
|
195 |
Â
if ($service) {
|
196 |
Â
$soapParams['Service'] = $service;
|
197 |
Â
}
|
198 |
-
|
199 |
Â
/**
|
200 |
Â
* Send the SOAP request
|
201 |
Â
*/
|
202 |
Â
$response = $this->call(
|
203 |
-
'checkout',
|
204 |
Â
'PrepareOrder',
|
205 |
Â
$soapParams
|
206 |
Â
);
|
207 |
-
|
208 |
-
if (!is_object($response)
|
209 |
Â
|| !isset($response->Checkout)
|
210 |
Â
|| !is_object($response->Checkout)
|
211 |
Â
|| !isset($response->Checkout->OrderToken)
|
@@ -215,15 +223,17 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
215 |
Â
'POSTNL-0040'
|
216 |
Â
);
|
217 |
Â
}
|
218 |
-
|
219 |
Â
return $response;
|
220 |
Â
}
|
221 |
Â
|
222 |
Â
/**
|
223 |
Â
* Retrieves the data the customer entered for this quote
|
224 |
-
*
|
225 |
Â
* @param Mage_Sales_Model_Quote $quote
|
226 |
-
*
|
Â
|
|
Â
|
|
227 |
Â
* @return StdClass
|
228 |
Â
*/
|
229 |
Â
public function readOrder($quote = null)
|
@@ -231,48 +241,50 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
231 |
Â
if (is_null($quote)) {
|
232 |
Â
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
233 |
Â
}
|
234 |
-
|
235 |
Â
if (!$quote) {
|
236 |
Â
throw new TIG_PostNL_Exception(
|
237 |
Â
Mage::helper('postnl')->__('No quote available to initiate PostNL Checkout.'),
|
238 |
Â
'POSTNL-0039'
|
239 |
Â
);
|
240 |
Â
}
|
241 |
-
|
242 |
Â
$this->setStoreId($quote->getStoreId());
|
243 |
-
|
244 |
Â
$checkout = $this->_getCheckout($quote);
|
245 |
Â
$webshop = $this->_getWebshop();
|
246 |
-
|
247 |
Â
$soapParams = array(
|
248 |
Â
'Checkout' => $checkout,
|
249 |
Â
'Webshop' => $webshop,
|
250 |
Â
);
|
251 |
-
|
252 |
Â
/**
|
253 |
Â
* Send the SOAP request
|
254 |
Â
*/
|
255 |
Â
$response = $this->call(
|
256 |
-
'checkout',
|
257 |
Â
'ReadOrder',
|
258 |
Â
$soapParams
|
259 |
Â
);
|
260 |
-
|
261 |
Â
if (!is_object($response)) {
|
262 |
Â
throw new TIG_PostNL_Exception(
|
263 |
Â
Mage::helper('postnl')->__('Invalid ReadOrder response: %s', "\n" . var_export($response, true)),
|
264 |
Â
'POSTNL-0041'
|
265 |
Â
);
|
266 |
Â
}
|
267 |
-
|
268 |
Â
return $response;
|
269 |
Â
}
|
270 |
-
|
271 |
Â
/**
|
272 |
Â
* Confirms the PostNL order.
|
273 |
-
*
|
274 |
-
* @param
|
275 |
-
*
|
Â
|
|
Â
|
|
276 |
Â
* @return StdClass
|
277 |
Â
*/
|
278 |
Â
public function confirmOrder($postnlOrder)
|
@@ -280,136 +292,138 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
280 |
Â
$checkout = $this->_getCheckout($postnlOrder);
|
281 |
Â
$order = $this->_getConfirmOrder($postnlOrder);
|
282 |
Â
$webshop = $this->_getWebshop();
|
283 |
-
|
284 |
Â
$soapParams = array(
|
285 |
Â
'Checkout' => $checkout,
|
286 |
Â
'Order' => $order,
|
287 |
Â
'Webshop' => $webshop,
|
288 |
Â
);
|
289 |
-
|
290 |
Â
/**
|
291 |
Â
* Send the SOAP request
|
292 |
Â
*/
|
293 |
Â
$response = $this->call(
|
294 |
-
'checkout',
|
295 |
Â
'ConfirmOrder',
|
296 |
Â
$soapParams
|
297 |
Â
);
|
298 |
-
|
299 |
Â
if (!is_object($response)) {
|
300 |
Â
throw new TIG_PostNL_Exception(
|
301 |
Â
Mage::helper('postnl')->__('Invalid ConfirmOrder response: %s', "\n" . var_export($response, true)),
|
302 |
Â
'POSTNL-0042'
|
303 |
Â
);
|
304 |
Â
}
|
305 |
-
|
306 |
Â
return $response;
|
307 |
Â
}
|
308 |
-
|
309 |
Â
/**
|
310 |
Â
* Updates an order with CIF once a shipment has been confirmed in order to link the shipment to the PostNL CHeckout order
|
311 |
-
*
|
312 |
-
* @param
|
313 |
Â
* @param boolean $cancel
|
314 |
-
*
|
315 |
Â
* @return StdClass
|
316 |
-
*
|
317 |
Â
* @throws TIG_PostNL_Exception
|
318 |
Â
*/
|
319 |
Â
public function updateOrder($postnlOrder, $cancel = false)
|
320 |
Â
{
|
Â
|
|
Â
|
|
321 |
Â
$order = $this->_getUpdateOrder($postnlOrder, $cancel);
|
322 |
Â
$webshop = $this->_getWebshop();
|
323 |
-
|
324 |
Â
$soapParams = array(
|
325 |
Â
'Order' => $order,
|
326 |
Â
'Webshop' => $webshop,
|
327 |
Â
);
|
328 |
-
|
329 |
Â
/**
|
330 |
Â
* Send the SOAP request
|
331 |
Â
*/
|
332 |
Â
$response = $this->call(
|
333 |
-
'checkout',
|
334 |
Â
'UpdateOrder',
|
335 |
Â
$soapParams
|
336 |
Â
);
|
337 |
-
|
338 |
Â
if (!is_object($response)) {
|
339 |
Â
throw new TIG_PostNL_Exception(
|
340 |
Â
Mage::helper('postnl')->__('Invalid UpdateOrder response: %s', var_export($response, true)),
|
341 |
Â
'POSTNL-0097'
|
342 |
Â
);
|
343 |
Â
}
|
344 |
-
|
345 |
Â
return $response;
|
346 |
Â
}
|
347 |
-
|
348 |
Â
/**
|
349 |
Â
* Gets a list of allowed payment methods
|
350 |
-
*
|
351 |
Â
* @return array
|
352 |
Â
*/
|
353 |
Â
protected function _getPaymentMethods()
|
354 |
Â
{
|
355 |
Â
$storeId = $this->getStoreId();
|
356 |
-
|
357 |
Â
/**
|
358 |
Â
* Get all payment method configuration options as well as an array of all payment method supported by PostNL
|
359 |
Â
*/
|
360 |
Â
$paymentMethods = Mage::getStoreConfig(self::XML_PATH_CHECKOUT_PAYMENT_METHODS, $storeId);
|
361 |
Â
$postnlPaymentMethods = Mage::helper('postnl/checkout')->getCheckoutPaymentMethods();
|
362 |
-
|
363 |
Â
$allowedMethods = array();
|
364 |
Â
foreach ($paymentMethods as $method => $value) {
|
365 |
Â
/**
|
366 |
-
* The $postnlPaymentMethods array uses the configuration option names as keys. So if $method exists as a key in
|
367 |
Â
* $postnlPaymentMethods it's a valid payment method. We then check if it's enabled by checking $value.
|
368 |
Â
*/
|
369 |
Â
if (!array_key_exists($method, $postnlPaymentMethods) || !$value) {
|
370 |
Â
continue;
|
371 |
Â
}
|
372 |
-
|
373 |
Â
$allowedMethods[] = array(
|
374 |
Â
'Code' => $postnlPaymentMethods[$method],
|
375 |
Â
'Prijs' => '0.00', //additional fees are not supported
|
376 |
Â
);
|
377 |
Â
}
|
378 |
-
|
379 |
Â
return $allowedMethods;
|
380 |
Â
}
|
381 |
-
|
382 |
Â
/**
|
383 |
Â
* Gets a list of allowed communication options
|
384 |
-
*
|
385 |
Â
* @return array
|
386 |
Â
*/
|
387 |
Â
protected function _getCommunicationOptions()
|
388 |
Â
{
|
389 |
Â
$storeId = $this->getStoreId();
|
390 |
-
|
391 |
Â
$communicationOptions = array();
|
392 |
-
|
393 |
Â
$newsletterSubscription = Mage::getStoreConfigFlag(self::XML_PATH_NEWSLETTER_SUBSCRIPTION, $storeId);
|
394 |
Â
if ($newsletterSubscription) {
|
395 |
Â
$communicationOptions[] = array(
|
396 |
Â
'Code' => 'NEWS',
|
397 |
Â
);
|
398 |
Â
}
|
399 |
-
|
400 |
Â
$remark = Mage::getStoreConfigFlag(self::XML_PATH_REMARK, $storeId);
|
401 |
Â
if ($remark) {
|
402 |
Â
$communicationOptions[] = array(
|
403 |
Â
'Code' => 'REMARK',
|
404 |
Â
);
|
405 |
Â
}
|
406 |
-
|
407 |
Â
return $communicationOptions;
|
408 |
Â
}
|
409 |
-
|
410 |
Â
/**
|
411 |
Â
* Gets the customer ID if the customer is logged in
|
412 |
-
*
|
413 |
Â
* @return boolean | array
|
414 |
Â
*/
|
415 |
Â
protected function _getCustomer()
|
@@ -418,83 +432,96 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
418 |
Â
if (!$session->isLoggedIn()) {
|
419 |
Â
return false;
|
420 |
Â
}
|
421 |
-
|
422 |
Â
$customerId = $session->getCustomerId();
|
423 |
Â
$customer = array(
|
424 |
Â
'ExtRef' => $customerId,
|
425 |
Â
);
|
426 |
-
|
427 |
Â
return $customer;
|
428 |
Â
}
|
429 |
-
|
430 |
Â
/**
|
431 |
Â
* Gets two optional fields. Both default to false.
|
432 |
-
*
|
433 |
Â
* @return array
|
434 |
Â
*/
|
435 |
Â
protected function _getOptional()
|
436 |
Â
{
|
437 |
Â
$storeId = $this->getStoreId();
|
438 |
-
|
439 |
-
$optional =
|
440 |
Â
array(
|
441 |
Â
'MobileNumber' => 'False',
|
442 |
Â
'BirthDate' => 'False',
|
443 |
Â
);
|
444 |
-
|
445 |
Â
$useMobile = Mage::getStoreConfigFlag(self::XML_PATH_USE_MOBILE, $storeId);
|
446 |
Â
if ($useMobile) {
|
447 |
Â
$optional['MobileNumber'] = 'True';
|
448 |
Â
}
|
449 |
-
|
450 |
Â
$useDob = Mage::getStoreConfigFlag(self::XML_PATH_USE_DOB, $storeId);
|
451 |
Â
if ($useDob) {
|
452 |
Â
$optional['BirthDate'] = 'True';
|
453 |
Â
}
|
454 |
-
|
455 |
Â
return $optional;
|
456 |
Â
}
|
457 |
-
|
458 |
Â
/**
|
459 |
Â
* Gets an optional URL of a page where customers can find contact info for this webshop
|
460 |
-
*
|
461 |
Â
* @return boolean | array
|
462 |
Â
*/
|
463 |
Â
protected function _getContact()
|
464 |
Â
{
|
465 |
Â
$storeId = $this->getStoreId();
|
466 |
-
|
467 |
Â
$contactUrl = Mage::getStoreConfig(self::XML_PATH_CONTACT_URL, $storeId);
|
468 |
Â
if (!$contactUrl) {
|
469 |
Â
return false;
|
470 |
Â
}
|
471 |
-
|
472 |
Â
$contact = array(
|
473 |
Â
'Url' => $contactUrl,
|
474 |
Â
);
|
475 |
-
|
476 |
Â
return $contact;
|
477 |
Â
}
|
478 |
-
|
479 |
Â
/**
|
480 |
Â
* Builds the Order soap object based on the current quote.
|
481 |
-
*
|
482 |
Â
* @param Mage_Sales_Model_Quote $quote
|
483 |
-
*
|
484 |
Â
* @return array
|
485 |
-
*
|
486 |
-
* @todo figure out why base_shipping_incl_tax is sometimes empty when shipping_incl_tax is not
|
487 |
Â
*/
|
488 |
Â
protected function _getOrder(Mage_Sales_Model_Quote $quote)
|
489 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
490 |
Â
$shippingAddress = $quote->getShippingAddress();
|
491 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
492 |
Â
$extRef = $quote->getId();
|
493 |
Â
$orderDate = date('d-m-Y H:i:s', Mage::getModel('core/date')->timestamp());
|
494 |
-
$subtotal = round($
|
495 |
-
$shippingDate = $orderDate;
|
496 |
-
$shippingCosts = round($
|
497 |
-
|
498 |
Â
$order = array(
|
499 |
Â
'ExtRef' => $extRef,
|
500 |
Â
'OrderDatum' => $orderDate,
|
@@ -502,76 +529,76 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
502 |
Â
'VerzendDatum' => $shippingDate,
|
503 |
Â
'VerzendKosten' => number_format($shippingCosts, 2, '.', ''),
|
504 |
Â
);
|
505 |
-
|
506 |
Â
return $order;
|
507 |
Â
}
|
508 |
-
|
509 |
Â
/**
|
510 |
Â
* Builds the confirmOrder Order soap object based on the current postnl order.
|
511 |
-
*
|
512 |
-
* @param
|
513 |
-
*
|
514 |
Â
* @return array
|
515 |
Â
*/
|
516 |
Â
protected function _getConfirmOrder($postnlOrder)
|
517 |
Â
{
|
518 |
Â
$order = $postnlOrder->getOrder();
|
519 |
-
|
520 |
Â
$paymentTotal = round($order->getBaseGrandTotal());
|
521 |
Â
$extRef = $order->getIncrementId();
|
522 |
Â
$paymentMethodName = $order->getPayment()->getMethodInstance()->getTitle();
|
523 |
-
|
524 |
Â
$confirmOrder = array(
|
525 |
Â
'PaymentTotal' => number_format($paymentTotal, 2, '.', ''),
|
526 |
Â
'ExtRef' => $extRef,
|
527 |
Â
'PaymentMethodName' => $paymentMethodName,
|
528 |
Â
);
|
529 |
-
|
530 |
Â
return $confirmOrder;
|
531 |
Â
}
|
532 |
-
|
533 |
Â
/**
|
534 |
Â
* Builds the updateOrder Order soap object based on the current postnl order.
|
535 |
-
*
|
536 |
-
* @param
|
537 |
Â
* @param boolean $cancel
|
538 |
-
*
|
539 |
Â
* @return array
|
540 |
Â
*/
|
541 |
Â
protected function _getUpdateOrder($postnlOrder, $cancel = false)
|
542 |
Â
{
|
543 |
Â
$order = $postnlOrder->getOrder();
|
544 |
-
|
545 |
Â
$extRef = $order->getIncrementId();
|
546 |
Â
$shipment = $this->_getShipments($postnlOrder);
|
547 |
-
|
548 |
Â
$updateOrder = array(
|
549 |
Â
'ExtRef' => $extRef,
|
550 |
Â
);
|
551 |
-
|
552 |
Â
if (!empty($shipment)) {
|
553 |
Â
$updateOrder['Zending'] = $shipment;
|
554 |
Â
}
|
555 |
-
|
556 |
Â
if ($cancel) {
|
557 |
Â
$updateOrder['Geannuleerd'] = 'true';
|
558 |
Â
}
|
559 |
-
|
560 |
Â
return $updateOrder;
|
561 |
Â
}
|
562 |
-
|
563 |
Â
/**
|
564 |
Â
* Gets a list of shipments associated with a PostNL order
|
565 |
-
*
|
566 |
-
* @param
|
567 |
-
*
|
568 |
Â
* @return array
|
569 |
Â
*/
|
570 |
Â
protected function _getShipments($postnlOrder)
|
571 |
Â
{
|
572 |
Â
$order = $postnlOrder->getOrder();
|
573 |
Â
$shipments = $order->getShipmentsCollection();
|
574 |
-
|
575 |
Â
$shipmentData = array();
|
576 |
Â
foreach ($shipments as $shipment) {
|
577 |
Â
$shipmentData[] = array(
|
@@ -579,27 +606,26 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
579 |
Â
'Pakket' => $this->_getParcels($shipment),
|
580 |
Â
);
|
581 |
Â
}
|
582 |
-
|
583 |
Â
return $shipmentData;
|
584 |
Â
}
|
585 |
-
|
586 |
Â
/**
|
587 |
Â
* Get a shipment's reference. By default this will be the shipment's increment ID
|
588 |
-
*
|
589 |
-
* @param Mage_Sales_Model_Order_Shipment
|
590 |
-
*
|
591 |
Â
* @return string
|
592 |
-
*
|
593 |
Â
* @throws TIG_PostNL_Exception
|
594 |
-
*
|
595 |
-
* @todo shouldn't we save this with the shipment in case the value changes later?
|
596 |
Â
* @todo merge this with TIG_PostNL_Model_Core_Cif::_getReference()
|
597 |
Â
*/
|
598 |
Â
protected function _getReference($shipment)
|
599 |
Â
{
|
600 |
Â
$storeId = $this->getStoreId();
|
601 |
Â
$referenceType = Mage::getStoreConfig(self::XML_PATH_SHIPMENT_REFERENCE_TYPE, $storeId);
|
602 |
-
|
603 |
Â
/**
|
604 |
Â
* Parse the reference type
|
605 |
Â
*/
|
@@ -623,33 +649,36 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
623 |
Â
'POSTNL-0043'
|
624 |
Â
);
|
625 |
Â
}
|
626 |
-
|
627 |
Â
/**
|
628 |
Â
* For custom references we need to replace several optional variables
|
629 |
Â
*/
|
630 |
Â
if ($referenceType == 'custom') {
|
631 |
Â
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
632 |
Â
$reference = str_replace('{{var order_increment_id}}', $shipment->getOrder()->getIncrementId(), $reference);
|
633 |
-
|
634 |
Â
$store = Mage::getModel('core/store')->load($storeId);
|
635 |
Â
$reference = str_replace('{{var store_frontend_name}}', $store->getFrontendName(), $reference);
|
636 |
Â
}
|
637 |
-
|
638 |
Â
return $reference;
|
639 |
Â
}
|
640 |
-
|
641 |
Â
/**
|
642 |
Â
* Gets a list of parcels associated with a shipment
|
643 |
-
*
|
644 |
-
* @param Mage_Sales_Model_Order_Shipment
|
645 |
-
*
|
646 |
Â
* @return array
|
647 |
Â
*/
|
648 |
Â
protected function _getParcels($shipment)
|
649 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
650 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getid(), 'shipment_id');
|
651 |
Â
$parcelCount = $postnlShipment->getParcelCount();
|
652 |
-
|
653 |
Â
$parcelData = array();
|
654 |
Â
$postcode = $shipment->getShippingAddress()->getPostcode();
|
655 |
Â
for ($i = 0; $i < $parcelCount; $i++) {
|
@@ -661,23 +690,23 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
661 |
Â
|
662 |
Â
return $parcelData;
|
663 |
Â
}
|
664 |
-
|
665 |
Â
/**
|
666 |
Â
* Builds the Restrictions soap object based on cofig settings
|
667 |
-
*
|
668 |
Â
* @return array
|
669 |
Â
*/
|
670 |
Â
protected function _getRestrictions()
|
671 |
Â
{
|
672 |
Â
$storeId = $this->getStoreId();
|
673 |
-
|
674 |
Â
$restrictions = array();
|
675 |
-
|
676 |
Â
$retailLocation = Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_RETAIL_LOCATION, $storeId);
|
677 |
Â
$foreignAddress = Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_FOREIGN_ADDRESS, $storeId);
|
678 |
Â
$priceOverview = Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_PRICE_OVERVIEW, $storeId);
|
679 |
Â
$agreeConditions = Mage::getStoreConfigFlag(self::XML_PATH_AGREE_CONDITIONS, $storeId);
|
680 |
-
|
681 |
Â
/**
|
682 |
Â
* If the module cannot use PakjeGemak, retail locations are not allowed in PostNL Checkout
|
683 |
Â
*/
|
@@ -711,45 +740,45 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
711 |
Â
} else {
|
712 |
Â
$restrictions['NoAgreeConditions'] = 'false';
|
713 |
Â
}
|
714 |
-
|
715 |
Â
return $restrictions;
|
716 |
Â
}
|
717 |
-
|
718 |
Â
/**
|
719 |
Â
* Gets an URL linking to the webshop's service info
|
720 |
-
*
|
721 |
-
* @return boolean
|
722 |
Â
*/
|
723 |
Â
protected function _getService()
|
724 |
Â
{
|
725 |
Â
$storeId = $this->getStoreId();
|
726 |
-
|
727 |
Â
$serviceUrl = Mage::getStoreConfig(self::XML_PATH_SERVICE_URL, $storeId);
|
728 |
Â
if (!$serviceUrl) {
|
729 |
Â
return false;
|
730 |
Â
}
|
731 |
-
|
732 |
Â
$service = array(
|
733 |
Â
'Url' => $serviceUrl,
|
734 |
Â
);
|
735 |
-
|
736 |
Â
return $service;
|
737 |
Â
}
|
738 |
-
|
739 |
Â
/**
|
740 |
Â
* Gets the order token used to identify a PostNL order
|
741 |
-
*
|
742 |
-
* @param Mage_Sales_Model_Quote
|
743 |
-
*
|
744 |
Â
* @return array
|
745 |
-
*
|
746 |
Â
* @throws TIG_PostNL_Exception
|
747 |
Â
*/
|
748 |
Â
protected function _getCheckout($object)
|
749 |
Â
{
|
750 |
Â
if ($object instanceof Mage_Sales_Model_Quote) {
|
751 |
-
$postnlOrder = Mage::getModel('
|
752 |
-
} elseif ($object instanceof
|
753 |
Â
$postnlOrder = $object;
|
754 |
Â
} else {
|
755 |
Â
throw new TIG_PostNL_Exception(
|
@@ -757,7 +786,7 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
757 |
Â
'POSTNL-0044'
|
758 |
Â
);
|
759 |
Â
}
|
760 |
-
|
761 |
Â
$orderToken = $postnlOrder->getToken();
|
762 |
Â
if (!$orderToken) {
|
763 |
Â
throw new TIG_PostNL_Exception(
|
@@ -765,30 +794,30 @@ class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
765 |
Â
'POSTNL-0045'
|
766 |
Â
);
|
767 |
Â
}
|
768 |
-
|
769 |
Â
$checkout = array(
|
770 |
Â
'OrderToken' => $orderToken,
|
771 |
Â
);
|
772 |
-
|
773 |
Â
return $checkout;
|
774 |
Â
}
|
775 |
-
|
776 |
Â
/**
|
777 |
Â
* Gets the webshop ID for the current store
|
778 |
-
*
|
779 |
Â
* @return array
|
780 |
Â
*/
|
781 |
Â
protected function _getWebshop()
|
782 |
Â
{
|
783 |
Â
$storeId = $this->getStoreId();
|
784 |
-
|
785 |
Â
$webshopId = Mage::getStoreConfig(self::XML_PATH_WEBSHOP_ID, $storeId);
|
786 |
Â
$webshopId = Mage::helper('core')->decrypt($webshopId);
|
787 |
-
|
788 |
Â
$webshop = array(
|
789 |
Â
'IntRef' => $webshopId,
|
790 |
Â
);
|
791 |
-
|
792 |
Â
return $webshop;
|
793 |
Â
}
|
794 |
Â
}
|
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.
|
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 |
+
* @method TIG_PostNL_Model_Checkout_Cif setStoreId(int $value)
|
40 |
Â
*/
|
41 |
Â
class TIG_PostNL_Model_Checkout_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
42 |
Â
{
|
44 |
Â
* Webshop ID config option path
|
45 |
Â
*/
|
46 |
Â
const XML_PATH_WEBSHOP_ID = 'postnl/cif/webshop_id';
|
47 |
+
|
48 |
Â
/**
|
49 |
Â
* XML paths for various options
|
50 |
Â
*/
|
58 |
Â
const XML_PATH_SERVICE_URL = 'postnl/checkout/service_url';
|
59 |
Â
const XML_PATH_USE_MOBILE = 'postnl/checkout/use_mobile';
|
60 |
Â
const XML_PATH_USE_DOB = 'postnl/checkout/use_dob';
|
61 |
+
|
62 |
Â
/**
|
63 |
Â
* XML path to available payment methods.
|
64 |
+
* N.B. missing last part so it will return an array of settings.
|
65 |
Â
*/
|
66 |
Â
const XML_PATH_CHECKOUT_PAYMENT_METHODS = 'postnl/checkout_payment_methods';
|
67 |
+
|
68 |
Â
/**
|
69 |
Â
* XML paths for shipment reference info
|
70 |
Â
*/
|
71 |
Â
const XML_PATH_SHIPMENT_REFERENCE_TYPE = 'postnl/cif_labels_and_confirming/shipment_reference_type';
|
72 |
Â
const XML_PATH_CUSTOM_SHIPMENT_REFERENCE = 'postnl/cif_labels_and_confirming/custom_shipment_reference';
|
73 |
+
|
74 |
Â
/**
|
75 |
Â
* Check if the module is set to test mode
|
76 |
+
*
|
77 |
Â
* @see TIG_PostNL_Helper_Checkout::isTestMode()
|
78 |
+
*
|
79 |
+
* @param bool $storeId
|
80 |
+
*
|
81 |
Â
* @return boolean
|
82 |
Â
*/
|
83 |
Â
public function isTestMode($storeId = false)
|
84 |
Â
{
|
85 |
+
if ($storeId === false) {
|
86 |
+
$storeId = $this->getStoreId();
|
87 |
+
}
|
88 |
+
|
89 |
Â
$testMode = Mage::helper('postnl/checkout')->isTestMode($storeId);
|
90 |
+
|
91 |
Â
return $testMode;
|
92 |
Â
}
|
93 |
+
|
94 |
Â
/**
|
95 |
Â
* Gets the current store Id
|
96 |
+
*
|
97 |
Â
* @return integer
|
98 |
Â
*/
|
99 |
Â
public function getStoreId()
|
100 |
Â
{
|
101 |
+
if ($this->hasStoreId()) {
|
102 |
Â
return $this->getData('store_id');
|
103 |
Â
}
|
104 |
+
|
105 |
Â
$storeId = Mage::app()->getStore()->getId();
|
106 |
+
|
107 |
Â
$this->setStoreId($storeId);
|
108 |
Â
return $storeId;
|
109 |
Â
}
|
110 |
+
|
111 |
Â
/**
|
112 |
Â
* Checks if the PostNL service is available
|
113 |
+
*
|
114 |
Â
* @return string
|
115 |
+
*
|
116 |
Â
* @throws TIG_PostNL_Exception
|
117 |
Â
*/
|
118 |
Â
public function ping()
|
119 |
+
{
|
120 |
Â
$response = $this->call(
|
121 |
+
'checkout',
|
122 |
Â
'PingStatus'
|
123 |
Â
);
|
124 |
+
|
125 |
+
if (!is_object($response)
|
126 |
Â
|| !isset($response->Status)
|
127 |
Â
) {
|
128 |
Â
throw new TIG_PostNL_Exception(
|
130 |
Â
'POSTNL-0038'
|
131 |
Â
);
|
132 |
Â
}
|
133 |
+
|
134 |
Â
return $response->Status;
|
135 |
Â
}
|
136 |
Â
|
137 |
Â
/**
|
138 |
Â
* Prepares a new PostNL checkout order
|
139 |
+
*
|
140 |
Â
* @param null|Mage_Sales_Model_Quote $quote
|
141 |
+
*
|
142 |
Â
* @return string
|
143 |
+
*
|
144 |
Â
* @throws TIG_PostNL_Exception
|
145 |
Â
*/
|
146 |
Â
public function prepareOrder($quote = null)
|
148 |
Â
if (is_null($quote)) {
|
149 |
Â
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
150 |
Â
}
|
151 |
+
|
152 |
Â
if (!$quote) {
|
153 |
Â
throw new TIG_PostNL_Exception(
|
154 |
Â
Mage::helper('postnl')->__('No quote available to initiate PostNL Checkout.'),
|
155 |
Â
'POSTNL-0039'
|
156 |
Â
);
|
157 |
Â
}
|
158 |
+
|
159 |
Â
$this->setStoreId($quote->getStoreId());
|
160 |
+
|
161 |
Â
/**
|
162 |
Â
* Get all data required to form the SOAP request
|
163 |
Â
*/
|
170 |
Â
$order = $this->_getOrder($quote);
|
171 |
Â
$restrictions = $this->_getRestrictions();
|
172 |
Â
$webshop = $this->_getWebshop();
|
173 |
+
|
174 |
Â
$soapParams = array(
|
175 |
Â
'Order' => $order,
|
176 |
Â
'Webshop' => $webshop,
|
177 |
Â
);
|
178 |
+
|
179 |
Â
if (!empty($paymentMethods)) {
|
180 |
Â
$soapParams['AangebodenBetaalMethoden'] = $paymentMethods;
|
181 |
Â
}
|
182 |
+
|
183 |
Â
if (!empty($communictionOptions)) {
|
184 |
Â
$soapParams['AangebodenCommunicatieOpties'] = $communictionOptions;
|
185 |
Â
}
|
186 |
+
|
187 |
Â
if (!empty($restrictions)) {
|
188 |
Â
$soapParams['Restrictions'] = $restrictions;
|
189 |
Â
}
|
190 |
+
|
191 |
Â
if ($customer) {
|
192 |
Â
$soapParams['Consument'] = $customer;
|
193 |
Â
}
|
194 |
+
|
195 |
Â
if (!empty($optional)) {
|
196 |
Â
$soapParams['Optional'] = $optional;
|
197 |
Â
}
|
198 |
+
|
199 |
Â
if ($contact) {
|
200 |
Â
$soapParams['Contact'] = $contact;
|
201 |
Â
}
|
202 |
+
|
203 |
Â
if ($service) {
|
204 |
Â
$soapParams['Service'] = $service;
|
205 |
Â
}
|
206 |
+
|
207 |
Â
/**
|
208 |
Â
* Send the SOAP request
|
209 |
Â
*/
|
210 |
Â
$response = $this->call(
|
211 |
+
'checkout',
|
212 |
Â
'PrepareOrder',
|
213 |
Â
$soapParams
|
214 |
Â
);
|
215 |
+
|
216 |
+
if (!is_object($response)
|
217 |
Â
|| !isset($response->Checkout)
|
218 |
Â
|| !is_object($response->Checkout)
|
219 |
Â
|| !isset($response->Checkout->OrderToken)
|
223 |
Â
'POSTNL-0040'
|
224 |
Â
);
|
225 |
Â
}
|
226 |
+
|
227 |
Â
return $response;
|
228 |
Â
}
|
229 |
Â
|
230 |
Â
/**
|
231 |
Â
* Retrieves the data the customer entered for this quote
|
232 |
+
*
|
233 |
Â
* @param Mage_Sales_Model_Quote $quote
|
234 |
+
*
|
235 |
+
* @throws TIG_PostNL_Exception
|
236 |
+
*
|
237 |
Â
* @return StdClass
|
238 |
Â
*/
|
239 |
Â
public function readOrder($quote = null)
|
241 |
Â
if (is_null($quote)) {
|
242 |
Â
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
243 |
Â
}
|
244 |
+
|
245 |
Â
if (!$quote) {
|
246 |
Â
throw new TIG_PostNL_Exception(
|
247 |
Â
Mage::helper('postnl')->__('No quote available to initiate PostNL Checkout.'),
|
248 |
Â
'POSTNL-0039'
|
249 |
Â
);
|
250 |
Â
}
|
251 |
+
|
252 |
Â
$this->setStoreId($quote->getStoreId());
|
253 |
+
|
254 |
Â
$checkout = $this->_getCheckout($quote);
|
255 |
Â
$webshop = $this->_getWebshop();
|
256 |
+
|
257 |
Â
$soapParams = array(
|
258 |
Â
'Checkout' => $checkout,
|
259 |
Â
'Webshop' => $webshop,
|
260 |
Â
);
|
261 |
+
|
262 |
Â
/**
|
263 |
Â
* Send the SOAP request
|
264 |
Â
*/
|
265 |
Â
$response = $this->call(
|
266 |
+
'checkout',
|
267 |
Â
'ReadOrder',
|
268 |
Â
$soapParams
|
269 |
Â
);
|
270 |
+
|
271 |
Â
if (!is_object($response)) {
|
272 |
Â
throw new TIG_PostNL_Exception(
|
273 |
Â
Mage::helper('postnl')->__('Invalid ReadOrder response: %s', "\n" . var_export($response, true)),
|
274 |
Â
'POSTNL-0041'
|
275 |
Â
);
|
276 |
Â
}
|
277 |
+
|
278 |
Â
return $response;
|
279 |
Â
}
|
280 |
+
|
281 |
Â
/**
|
282 |
Â
* Confirms the PostNL order.
|
283 |
+
*
|
284 |
+
* @param TIG_PostNL_Model_Core_Order $postnlOrder
|
285 |
+
*
|
286 |
+
* @throws TIG_PostNL_Exception
|
287 |
+
*
|
288 |
Â
* @return StdClass
|
289 |
Â
*/
|
290 |
Â
public function confirmOrder($postnlOrder)
|
292 |
Â
$checkout = $this->_getCheckout($postnlOrder);
|
293 |
Â
$order = $this->_getConfirmOrder($postnlOrder);
|
294 |
Â
$webshop = $this->_getWebshop();
|
295 |
+
|
296 |
Â
$soapParams = array(
|
297 |
Â
'Checkout' => $checkout,
|
298 |
Â
'Order' => $order,
|
299 |
Â
'Webshop' => $webshop,
|
300 |
Â
);
|
301 |
+
|
302 |
Â
/**
|
303 |
Â
* Send the SOAP request
|
304 |
Â
*/
|
305 |
Â
$response = $this->call(
|
306 |
+
'checkout',
|
307 |
Â
'ConfirmOrder',
|
308 |
Â
$soapParams
|
309 |
Â
);
|
310 |
+
|
311 |
Â
if (!is_object($response)) {
|
312 |
Â
throw new TIG_PostNL_Exception(
|
313 |
Â
Mage::helper('postnl')->__('Invalid ConfirmOrder response: %s', "\n" . var_export($response, true)),
|
314 |
Â
'POSTNL-0042'
|
315 |
Â
);
|
316 |
Â
}
|
317 |
+
|
318 |
Â
return $response;
|
319 |
Â
}
|
320 |
+
|
321 |
Â
/**
|
322 |
Â
* Updates an order with CIF once a shipment has been confirmed in order to link the shipment to the PostNL CHeckout order
|
323 |
+
*
|
324 |
+
* @param TIG_PostNL_Model_Core_Order $postnlOrder
|
325 |
Â
* @param boolean $cancel
|
326 |
+
*
|
327 |
Â
* @return StdClass
|
328 |
+
*
|
329 |
Â
* @throws TIG_PostNL_Exception
|
330 |
Â
*/
|
331 |
Â
public function updateOrder($postnlOrder, $cancel = false)
|
332 |
Â
{
|
333 |
+
$this->setStoreId($postnlOrder->getOrder()->getStoreId());
|
334 |
+
|
335 |
Â
$order = $this->_getUpdateOrder($postnlOrder, $cancel);
|
336 |
Â
$webshop = $this->_getWebshop();
|
337 |
+
|
338 |
Â
$soapParams = array(
|
339 |
Â
'Order' => $order,
|
340 |
Â
'Webshop' => $webshop,
|
341 |
Â
);
|
342 |
+
|
343 |
Â
/**
|
344 |
Â
* Send the SOAP request
|
345 |
Â
*/
|
346 |
Â
$response = $this->call(
|
347 |
+
'checkout',
|
348 |
Â
'UpdateOrder',
|
349 |
Â
$soapParams
|
350 |
Â
);
|
351 |
+
|
352 |
Â
if (!is_object($response)) {
|
353 |
Â
throw new TIG_PostNL_Exception(
|
354 |
Â
Mage::helper('postnl')->__('Invalid UpdateOrder response: %s', var_export($response, true)),
|
355 |
Â
'POSTNL-0097'
|
356 |
Â
);
|
357 |
Â
}
|
358 |
+
|
359 |
Â
return $response;
|
360 |
Â
}
|
361 |
+
|
362 |
Â
/**
|
363 |
Â
* Gets a list of allowed payment methods
|
364 |
+
*
|
365 |
Â
* @return array
|
366 |
Â
*/
|
367 |
Â
protected function _getPaymentMethods()
|
368 |
Â
{
|
369 |
Â
$storeId = $this->getStoreId();
|
370 |
+
|
371 |
Â
/**
|
372 |
Â
* Get all payment method configuration options as well as an array of all payment method supported by PostNL
|
373 |
Â
*/
|
374 |
Â
$paymentMethods = Mage::getStoreConfig(self::XML_PATH_CHECKOUT_PAYMENT_METHODS, $storeId);
|
375 |
Â
$postnlPaymentMethods = Mage::helper('postnl/checkout')->getCheckoutPaymentMethods();
|
376 |
+
|
377 |
Â
$allowedMethods = array();
|
378 |
Â
foreach ($paymentMethods as $method => $value) {
|
379 |
Â
/**
|
380 |
+
* The $postnlPaymentMethods array uses the configuration option names as keys. So if $method exists as a key in
|
381 |
Â
* $postnlPaymentMethods it's a valid payment method. We then check if it's enabled by checking $value.
|
382 |
Â
*/
|
383 |
Â
if (!array_key_exists($method, $postnlPaymentMethods) || !$value) {
|
384 |
Â
continue;
|
385 |
Â
}
|
386 |
+
|
387 |
Â
$allowedMethods[] = array(
|
388 |
Â
'Code' => $postnlPaymentMethods[$method],
|
389 |
Â
'Prijs' => '0.00', //additional fees are not supported
|
390 |
Â
);
|
391 |
Â
}
|
392 |
+
|
393 |
Â
return $allowedMethods;
|
394 |
Â
}
|
395 |
+
|
396 |
Â
/**
|
397 |
Â
* Gets a list of allowed communication options
|
398 |
+
*
|
399 |
Â
* @return array
|
400 |
Â
*/
|
401 |
Â
protected function _getCommunicationOptions()
|
402 |
Â
{
|
403 |
Â
$storeId = $this->getStoreId();
|
404 |
+
|
405 |
Â
$communicationOptions = array();
|
406 |
+
|
407 |
Â
$newsletterSubscription = Mage::getStoreConfigFlag(self::XML_PATH_NEWSLETTER_SUBSCRIPTION, $storeId);
|
408 |
Â
if ($newsletterSubscription) {
|
409 |
Â
$communicationOptions[] = array(
|
410 |
Â
'Code' => 'NEWS',
|
411 |
Â
);
|
412 |
Â
}
|
413 |
+
|
414 |
Â
$remark = Mage::getStoreConfigFlag(self::XML_PATH_REMARK, $storeId);
|
415 |
Â
if ($remark) {
|
416 |
Â
$communicationOptions[] = array(
|
417 |
Â
'Code' => 'REMARK',
|
418 |
Â
);
|
419 |
Â
}
|
420 |
+
|
421 |
Â
return $communicationOptions;
|
422 |
Â
}
|
423 |
+
|
424 |
Â
/**
|
425 |
Â
* Gets the customer ID if the customer is logged in
|
426 |
+
*
|
427 |
Â
* @return boolean | array
|
428 |
Â
*/
|
429 |
Â
protected function _getCustomer()
|
432 |
Â
if (!$session->isLoggedIn()) {
|
433 |
Â
return false;
|
434 |
Â
}
|
435 |
+
|
436 |
Â
$customerId = $session->getCustomerId();
|
437 |
Â
$customer = array(
|
438 |
Â
'ExtRef' => $customerId,
|
439 |
Â
);
|
440 |
+
|
441 |
Â
return $customer;
|
442 |
Â
}
|
443 |
+
|
444 |
Â
/**
|
445 |
Â
* Gets two optional fields. Both default to false.
|
446 |
+
*
|
447 |
Â
* @return array
|
448 |
Â
*/
|
449 |
Â
protected function _getOptional()
|
450 |
Â
{
|
451 |
Â
$storeId = $this->getStoreId();
|
452 |
+
|
453 |
+
$optional =
|
454 |
Â
array(
|
455 |
Â
'MobileNumber' => 'False',
|
456 |
Â
'BirthDate' => 'False',
|
457 |
Â
);
|
458 |
+
|
459 |
Â
$useMobile = Mage::getStoreConfigFlag(self::XML_PATH_USE_MOBILE, $storeId);
|
460 |
Â
if ($useMobile) {
|
461 |
Â
$optional['MobileNumber'] = 'True';
|
462 |
Â
}
|
463 |
+
|
464 |
Â
$useDob = Mage::getStoreConfigFlag(self::XML_PATH_USE_DOB, $storeId);
|
465 |
Â
if ($useDob) {
|
466 |
Â
$optional['BirthDate'] = 'True';
|
467 |
Â
}
|
468 |
+
|
469 |
Â
return $optional;
|
470 |
Â
}
|
471 |
+
|
472 |
Â
/**
|
473 |
Â
* Gets an optional URL of a page where customers can find contact info for this webshop
|
474 |
+
*
|
475 |
Â
* @return boolean | array
|
476 |
Â
*/
|
477 |
Â
protected function _getContact()
|
478 |
Â
{
|
479 |
Â
$storeId = $this->getStoreId();
|
480 |
+
|
481 |
Â
$contactUrl = Mage::getStoreConfig(self::XML_PATH_CONTACT_URL, $storeId);
|
482 |
Â
if (!$contactUrl) {
|
483 |
Â
return false;
|
484 |
Â
}
|
485 |
+
|
486 |
Â
$contact = array(
|
487 |
Â
'Url' => $contactUrl,
|
488 |
Â
);
|
489 |
+
|
490 |
Â
return $contact;
|
491 |
Â
}
|
492 |
+
|
493 |
Â
/**
|
494 |
Â
* Builds the Order soap object based on the current quote.
|
495 |
+
*
|
496 |
Â
* @param Mage_Sales_Model_Quote $quote
|
497 |
+
*
|
498 |
Â
* @return array
|
Â
|
|
Â
|
|
499 |
Â
*/
|
500 |
Â
protected function _getOrder(Mage_Sales_Model_Quote $quote)
|
501 |
Â
{
|
502 |
+
/**
|
503 |
+
* @var Mage_Sales_Model_Quote_Address $shippingAddress
|
504 |
+
*/
|
505 |
Â
$shippingAddress = $quote->getShippingAddress();
|
506 |
+
$baseSubtotalIncltax = $shippingAddress->getBaseSubtotalTotalInclTax();
|
507 |
+
if ($baseSubtotalIncltax === null) {
|
508 |
+
$baseSubtotalIncltax = $shippingAddress->getBaseSubtotalWithDiscount()
|
509 |
+
+ $shippingAddress->getBaseTaxAmount()
|
510 |
+
- $shippingAddress->getBaseShippingTaxAmount();
|
511 |
+
}
|
512 |
+
|
513 |
+
$baseShippingAmount = $shippingAddress->getBaseShippingInclTax();
|
514 |
+
if ($baseShippingAmount === null) {
|
515 |
+
$baseShippingAmount = $shippingAddress->getBaseShippingAmount()
|
516 |
+
+ $shippingAddress->getBaseShippingTaxAmount();
|
517 |
+
}
|
518 |
+
|
519 |
Â
$extRef = $quote->getId();
|
520 |
Â
$orderDate = date('d-m-Y H:i:s', Mage::getModel('core/date')->timestamp());
|
521 |
+
$subtotal = round($baseSubtotalIncltax, 2);
|
522 |
+
$shippingDate = $orderDate;
|
523 |
+
$shippingCosts = round($baseShippingAmount, 2);
|
524 |
+
|
525 |
Â
$order = array(
|
526 |
Â
'ExtRef' => $extRef,
|
527 |
Â
'OrderDatum' => $orderDate,
|
529 |
Â
'VerzendDatum' => $shippingDate,
|
530 |
Â
'VerzendKosten' => number_format($shippingCosts, 2, '.', ''),
|
531 |
Â
);
|
532 |
+
|
533 |
Â
return $order;
|
534 |
Â
}
|
535 |
+
|
536 |
Â
/**
|
537 |
Â
* Builds the confirmOrder Order soap object based on the current postnl order.
|
538 |
+
*
|
539 |
+
* @param TIG_PostNL_Model_Core_Order $postnlOrder
|
540 |
+
*
|
541 |
Â
* @return array
|
542 |
Â
*/
|
543 |
Â
protected function _getConfirmOrder($postnlOrder)
|
544 |
Â
{
|
545 |
Â
$order = $postnlOrder->getOrder();
|
546 |
+
|
547 |
Â
$paymentTotal = round($order->getBaseGrandTotal());
|
548 |
Â
$extRef = $order->getIncrementId();
|
549 |
Â
$paymentMethodName = $order->getPayment()->getMethodInstance()->getTitle();
|
550 |
+
|
551 |
Â
$confirmOrder = array(
|
552 |
Â
'PaymentTotal' => number_format($paymentTotal, 2, '.', ''),
|
553 |
Â
'ExtRef' => $extRef,
|
554 |
Â
'PaymentMethodName' => $paymentMethodName,
|
555 |
Â
);
|
556 |
+
|
557 |
Â
return $confirmOrder;
|
558 |
Â
}
|
559 |
+
|
560 |
Â
/**
|
561 |
Â
* Builds the updateOrder Order soap object based on the current postnl order.
|
562 |
+
*
|
563 |
+
* @param TIG_PostNL_Model_Core_Order $postnlOrder
|
564 |
Â
* @param boolean $cancel
|
565 |
+
*
|
566 |
Â
* @return array
|
567 |
Â
*/
|
568 |
Â
protected function _getUpdateOrder($postnlOrder, $cancel = false)
|
569 |
Â
{
|
570 |
Â
$order = $postnlOrder->getOrder();
|
571 |
+
|
572 |
Â
$extRef = $order->getIncrementId();
|
573 |
Â
$shipment = $this->_getShipments($postnlOrder);
|
574 |
+
|
575 |
Â
$updateOrder = array(
|
576 |
Â
'ExtRef' => $extRef,
|
577 |
Â
);
|
578 |
+
|
579 |
Â
if (!empty($shipment)) {
|
580 |
Â
$updateOrder['Zending'] = $shipment;
|
581 |
Â
}
|
582 |
+
|
583 |
Â
if ($cancel) {
|
584 |
Â
$updateOrder['Geannuleerd'] = 'true';
|
585 |
Â
}
|
586 |
+
|
587 |
Â
return $updateOrder;
|
588 |
Â
}
|
589 |
+
|
590 |
Â
/**
|
591 |
Â
* Gets a list of shipments associated with a PostNL order
|
592 |
+
*
|
593 |
+
* @param TIG_PostNL_Model_Core_Order $postnlOrder
|
594 |
+
*
|
595 |
Â
* @return array
|
596 |
Â
*/
|
597 |
Â
protected function _getShipments($postnlOrder)
|
598 |
Â
{
|
599 |
Â
$order = $postnlOrder->getOrder();
|
600 |
Â
$shipments = $order->getShipmentsCollection();
|
601 |
+
|
602 |
Â
$shipmentData = array();
|
603 |
Â
foreach ($shipments as $shipment) {
|
604 |
Â
$shipmentData[] = array(
|
606 |
Â
'Pakket' => $this->_getParcels($shipment),
|
607 |
Â
);
|
608 |
Â
}
|
609 |
+
|
610 |
Â
return $shipmentData;
|
611 |
Â
}
|
612 |
+
|
613 |
Â
/**
|
614 |
Â
* Get a shipment's reference. By default this will be the shipment's increment ID
|
615 |
+
*
|
616 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
617 |
+
*
|
618 |
Â
* @return string
|
619 |
+
*
|
620 |
Â
* @throws TIG_PostNL_Exception
|
621 |
+
*
|
Â
|
|
622 |
Â
* @todo merge this with TIG_PostNL_Model_Core_Cif::_getReference()
|
623 |
Â
*/
|
624 |
Â
protected function _getReference($shipment)
|
625 |
Â
{
|
626 |
Â
$storeId = $this->getStoreId();
|
627 |
Â
$referenceType = Mage::getStoreConfig(self::XML_PATH_SHIPMENT_REFERENCE_TYPE, $storeId);
|
628 |
+
|
629 |
Â
/**
|
630 |
Â
* Parse the reference type
|
631 |
Â
*/
|
649 |
Â
'POSTNL-0043'
|
650 |
Â
);
|
651 |
Â
}
|
652 |
+
|
653 |
Â
/**
|
654 |
Â
* For custom references we need to replace several optional variables
|
655 |
Â
*/
|
656 |
Â
if ($referenceType == 'custom') {
|
657 |
Â
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
658 |
Â
$reference = str_replace('{{var order_increment_id}}', $shipment->getOrder()->getIncrementId(), $reference);
|
659 |
+
|
660 |
Â
$store = Mage::getModel('core/store')->load($storeId);
|
661 |
Â
$reference = str_replace('{{var store_frontend_name}}', $store->getFrontendName(), $reference);
|
662 |
Â
}
|
663 |
+
|
664 |
Â
return $reference;
|
665 |
Â
}
|
666 |
+
|
667 |
Â
/**
|
668 |
Â
* Gets a list of parcels associated with a shipment
|
669 |
+
*
|
670 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
671 |
+
*
|
672 |
Â
* @return array
|
673 |
Â
*/
|
674 |
Â
protected function _getParcels($shipment)
|
675 |
Â
{
|
676 |
+
/**
|
677 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
678 |
+
*/
|
679 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment')->load($shipment->getid(), 'shipment_id');
|
680 |
Â
$parcelCount = $postnlShipment->getParcelCount();
|
681 |
+
|
682 |
Â
$parcelData = array();
|
683 |
Â
$postcode = $shipment->getShippingAddress()->getPostcode();
|
684 |
Â
for ($i = 0; $i < $parcelCount; $i++) {
|
690 |
Â
|
691 |
Â
return $parcelData;
|
692 |
Â
}
|
693 |
+
|
694 |
Â
/**
|
695 |
Â
* Builds the Restrictions soap object based on cofig settings
|
696 |
+
*
|
697 |
Â
* @return array
|
698 |
Â
*/
|
699 |
Â
protected function _getRestrictions()
|
700 |
Â
{
|
701 |
Â
$storeId = $this->getStoreId();
|
702 |
+
|
703 |
Â
$restrictions = array();
|
704 |
+
|
705 |
Â
$retailLocation = Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_RETAIL_LOCATION, $storeId);
|
706 |
Â
$foreignAddress = Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_FOREIGN_ADDRESS, $storeId);
|
707 |
Â
$priceOverview = Mage::getStoreConfigFlag(self::XML_PATH_ALLOW_PRICE_OVERVIEW, $storeId);
|
708 |
Â
$agreeConditions = Mage::getStoreConfigFlag(self::XML_PATH_AGREE_CONDITIONS, $storeId);
|
709 |
+
|
710 |
Â
/**
|
711 |
Â
* If the module cannot use PakjeGemak, retail locations are not allowed in PostNL Checkout
|
712 |
Â
*/
|
740 |
Â
} else {
|
741 |
Â
$restrictions['NoAgreeConditions'] = 'false';
|
742 |
Â
}
|
743 |
+
|
744 |
Â
return $restrictions;
|
745 |
Â
}
|
746 |
+
|
747 |
Â
/**
|
748 |
Â
* Gets an URL linking to the webshop's service info
|
749 |
+
*
|
750 |
+
* @return boolean|array
|
751 |
Â
*/
|
752 |
Â
protected function _getService()
|
753 |
Â
{
|
754 |
Â
$storeId = $this->getStoreId();
|
755 |
+
|
756 |
Â
$serviceUrl = Mage::getStoreConfig(self::XML_PATH_SERVICE_URL, $storeId);
|
757 |
Â
if (!$serviceUrl) {
|
758 |
Â
return false;
|
759 |
Â
}
|
760 |
+
|
761 |
Â
$service = array(
|
762 |
Â
'Url' => $serviceUrl,
|
763 |
Â
);
|
764 |
+
|
765 |
Â
return $service;
|
766 |
Â
}
|
767 |
+
|
768 |
Â
/**
|
769 |
Â
* Gets the order token used to identify a PostNL order
|
770 |
+
*
|
771 |
+
* @param Mage_Sales_Model_Quote|TIG_PostNL_Model_Core_Order $object
|
772 |
+
*
|
773 |
Â
* @return array
|
774 |
+
*
|
775 |
Â
* @throws TIG_PostNL_Exception
|
776 |
Â
*/
|
777 |
Â
protected function _getCheckout($object)
|
778 |
Â
{
|
779 |
Â
if ($object instanceof Mage_Sales_Model_Quote) {
|
780 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($object->getId(), 'quote_id');
|
781 |
+
} elseif ($object instanceof TIG_PostNL_Model_Core_Order) {
|
782 |
Â
$postnlOrder = $object;
|
783 |
Â
} else {
|
784 |
Â
throw new TIG_PostNL_Exception(
|
786 |
Â
'POSTNL-0044'
|
787 |
Â
);
|
788 |
Â
}
|
789 |
+
|
790 |
Â
$orderToken = $postnlOrder->getToken();
|
791 |
Â
if (!$orderToken) {
|
792 |
Â
throw new TIG_PostNL_Exception(
|
794 |
Â
'POSTNL-0045'
|
795 |
Â
);
|
796 |
Â
}
|
797 |
+
|
798 |
Â
$checkout = array(
|
799 |
Â
'OrderToken' => $orderToken,
|
800 |
Â
);
|
801 |
+
|
802 |
Â
return $checkout;
|
803 |
Â
}
|
804 |
+
|
805 |
Â
/**
|
806 |
Â
* Gets the webshop ID for the current store
|
807 |
+
*
|
808 |
Â
* @return array
|
809 |
Â
*/
|
810 |
Â
protected function _getWebshop()
|
811 |
Â
{
|
812 |
Â
$storeId = $this->getStoreId();
|
813 |
+
|
814 |
Â
$webshopId = Mage::getStoreConfig(self::XML_PATH_WEBSHOP_ID, $storeId);
|
815 |
Â
$webshopId = Mage::helper('core')->decrypt($webshopId);
|
816 |
+
|
817 |
Â
$webshop = array(
|
818 |
Â
'IntRef' => $webshopId,
|
819 |
Â
);
|
820 |
+
|
821 |
Â
return $webshop;
|
822 |
Â
}
|
823 |
Â
}
|
@@ -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.
|
@@ -33,38 +33,42 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Checkout_Observer_Order
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
-
* Cancels a PostNL Checkout order
|
43 |
-
*
|
44 |
Â
* @param Varien_Event_Observer $observer
|
45 |
-
*
|
46 |
Â
* @return TIG_PostNL_Model_Checkout_Observer_Order
|
47 |
-
*
|
48 |
Â
* @event order_cancel_after
|
49 |
-
*
|
50 |
Â
* @observer postnl_cancel_checkout_order
|
51 |
Â
*/
|
52 |
Â
public function cancelOrder(Varien_Event_Observer $observer)
|
53 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
54 |
Â
$order = $observer->getOrder();
|
55 |
-
$postnlOrder = Mage::getModel('
|
56 |
-
|
57 |
-
if (!$postnlOrder->getId()) {
|
58 |
Â
return $this;
|
59 |
Â
}
|
60 |
-
|
61 |
Â
try {
|
62 |
Â
$postnlOrder->cancel()
|
63 |
Â
->save();
|
64 |
Â
} catch (Exception $e) {
|
65 |
Â
Mage::helper('postnl/checkout')->logException($e);
|
66 |
Â
}
|
67 |
-
|
68 |
Â
return $this;
|
69 |
Â
}
|
70 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Checkout_Observer_Order
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
+
* Cancels a PostNL Checkout order after it's Magento order has been cancelled.
|
43 |
+
*
|
44 |
Â
* @param Varien_Event_Observer $observer
|
45 |
+
*
|
46 |
Â
* @return TIG_PostNL_Model_Checkout_Observer_Order
|
47 |
+
*
|
48 |
Â
* @event order_cancel_after
|
49 |
+
*
|
50 |
Â
* @observer postnl_cancel_checkout_order
|
51 |
Â
*/
|
52 |
Â
public function cancelOrder(Varien_Event_Observer $observer)
|
53 |
Â
{
|
54 |
+
/**
|
55 |
+
* @var Mage_Sales_Model_Order $order
|
56 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
57 |
+
*/
|
58 |
Â
$order = $observer->getOrder();
|
59 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($order->getId(), 'order_id');
|
60 |
+
|
61 |
+
if (!$postnlOrder->getId() || !$postnlOrder->getToken()) {
|
62 |
Â
return $this;
|
63 |
Â
}
|
64 |
+
|
65 |
Â
try {
|
66 |
Â
$postnlOrder->cancel()
|
67 |
Â
->save();
|
68 |
Â
} catch (Exception $e) {
|
69 |
Â
Mage::helper('postnl/checkout')->logException($e);
|
70 |
Â
}
|
71 |
+
|
72 |
Â
return $this;
|
73 |
Â
}
|
74 |
Â
}
|
@@ -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.
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Checkout_Observer_Shipment
|
@@ -42,42 +42,45 @@ class TIG_PostNL_Model_Checkout_Observer_Shipment
|
|
42 |
Â
* Updates a PostNL Checkout order with CIF. This has to occur after a shipment is confirmed. If an order has multiple
|
43 |
Â
* shipments, this has to happen every time a shipment is confirmed. Each time the request will contain and additional
|
44 |
Â
* shipment each having 1 or more parcels.
|
45 |
-
*
|
46 |
Â
* @param Varien_Event_Observer $observer
|
47 |
-
*
|
48 |
Â
* @return TIG_PostNL_Model_Core_Observer_Barcode
|
49 |
-
*
|
50 |
Â
* @event postnl_shipment_confirm_after
|
51 |
-
*
|
52 |
Â
* @observer postnl_checkout_update_order
|
53 |
-
*
|
54 |
Â
* @throws TIG_PostNL_Exception
|
55 |
Â
*/
|
56 |
Â
public function updateOrder(Varien_Event_Observer $observer)
|
57 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
58 |
Â
$postnlShipment = $observer->getShipment();
|
59 |
-
|
60 |
Â
$orderId = $postnlShipment->getOrderId();
|
61 |
-
$postnlOrder = Mage::getModel('
|
62 |
Â
$postnlOrder->load($orderId, 'order_id');
|
63 |
-
if (!$postnlOrder->getId()) {
|
64 |
Â
return $this;
|
65 |
Â
}
|
66 |
-
|
67 |
Â
try {
|
68 |
Â
$cif = Mage::getModel('postnl_checkout/cif');
|
69 |
Â
$result = $cif->updateOrder($postnlOrder);
|
70 |
-
|
71 |
Â
if (!isset($result->Succes) || $result->Succes != 'true') {
|
72 |
Â
throw new TIG_PostNL_Exception(
|
73 |
Â
Mage::helper('postnl')->__('Invalid UpdateOrder response received!'),
|
74 |
Â
'POSTNL-0037'
|
75 |
Â
);
|
76 |
Â
}
|
77 |
-
} catch (
|
78 |
Â
$helper = Mage::helper('postnl');
|
79 |
Â
$helper->addSessionMessage(
|
80 |
-
'adminhtml/session',
|
81 |
Â
'POSTNL-0113',
|
82 |
Â
'notice',
|
83 |
Â
$helper->__('An error occurred while updating the PostNL Checkout order: %s', $e->getMessage())
|
@@ -86,14 +89,14 @@ class TIG_PostNL_Model_Checkout_Observer_Shipment
|
|
86 |
Â
} catch (Exception $e) {
|
87 |
Â
$helper = Mage::helper('postnl');
|
88 |
Â
$helper->addSessionMessage(
|
89 |
-
'adminhtml/session',
|
90 |
Â
'POSTNL-0113',
|
91 |
Â
'notice',
|
92 |
Â
$helper->__('An error occurred while updating the PostNL Checkout order.')
|
93 |
Â
);
|
94 |
Â
return $this;
|
95 |
Â
}
|
96 |
-
|
97 |
Â
return $this;
|
98 |
Â
}
|
99 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Model_Checkout_Observer_Shipment
|
42 |
Â
* Updates a PostNL Checkout order with CIF. This has to occur after a shipment is confirmed. If an order has multiple
|
43 |
Â
* shipments, this has to happen every time a shipment is confirmed. Each time the request will contain and additional
|
44 |
Â
* shipment each having 1 or more parcels.
|
45 |
+
*
|
46 |
Â
* @param Varien_Event_Observer $observer
|
47 |
+
*
|
48 |
Â
* @return TIG_PostNL_Model_Core_Observer_Barcode
|
49 |
+
*
|
50 |
Â
* @event postnl_shipment_confirm_after
|
51 |
+
*
|
52 |
Â
* @observer postnl_checkout_update_order
|
53 |
+
*
|
54 |
Â
* @throws TIG_PostNL_Exception
|
55 |
Â
*/
|
56 |
Â
public function updateOrder(Varien_Event_Observer $observer)
|
57 |
Â
{
|
58 |
+
/**
|
59 |
+
* @var TIG_PostNL_Model_Core_Shipment $postnlShipment
|
60 |
+
*/
|
61 |
Â
$postnlShipment = $observer->getShipment();
|
62 |
+
|
63 |
Â
$orderId = $postnlShipment->getOrderId();
|
64 |
+
$postnlOrder = Mage::getModel('postnl_core/order');
|
65 |
Â
$postnlOrder->load($orderId, 'order_id');
|
66 |
+
if (!$postnlOrder->getId() || !$postnlOrder->getToken()) {
|
67 |
Â
return $this;
|
68 |
Â
}
|
69 |
+
|
70 |
Â
try {
|
71 |
Â
$cif = Mage::getModel('postnl_checkout/cif');
|
72 |
Â
$result = $cif->updateOrder($postnlOrder);
|
73 |
+
|
74 |
Â
if (!isset($result->Succes) || $result->Succes != 'true') {
|
75 |
Â
throw new TIG_PostNL_Exception(
|
76 |
Â
Mage::helper('postnl')->__('Invalid UpdateOrder response received!'),
|
77 |
Â
'POSTNL-0037'
|
78 |
Â
);
|
79 |
Â
}
|
80 |
+
} catch (TIG_PostNL_Exception $e) {
|
81 |
Â
$helper = Mage::helper('postnl');
|
82 |
Â
$helper->addSessionMessage(
|
83 |
+
'adminhtml/session',
|
84 |
Â
'POSTNL-0113',
|
85 |
Â
'notice',
|
86 |
Â
$helper->__('An error occurred while updating the PostNL Checkout order: %s', $e->getMessage())
|
89 |
Â
} catch (Exception $e) {
|
90 |
Â
$helper = Mage::helper('postnl');
|
91 |
Â
$helper->addSessionMessage(
|
92 |
+
'adminhtml/session',
|
93 |
Â
'POSTNL-0113',
|
94 |
Â
'notice',
|
95 |
Â
$helper->__('An error occurred while updating the PostNL Checkout order.')
|
96 |
Â
);
|
97 |
Â
return $this;
|
98 |
Â
}
|
99 |
+
|
100 |
Â
return $this;
|
101 |
Â
}
|
102 |
Â
}
|
@@ -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.
|
@@ -33,128 +33,13 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
-
class TIG_PostNL_Model_Checkout_Order extends
|
40 |
Â
{
|
41 |
-
/**
|
42 |
-
* Prefix of model events names
|
43 |
-
*
|
44 |
-
* @var string
|
45 |
-
*/
|
46 |
-
protected $_eventPrefix = 'postnl_order';
|
47 |
-
|
48 |
-
public function _construct()
|
49 |
-
{
|
50 |
-
$this->_init('postnl_checkout/order');
|
51 |
-
}
|
52 |
-
|
53 |
-
/**
|
54 |
-
* Gets the order associated with this PostNL Checkout Order
|
55 |
-
*
|
56 |
-
* @return Mage_Sales_Model_Order | null
|
57 |
-
*/
|
58 |
-
public function getOrder()
|
59 |
-
{
|
60 |
-
if ($this->getData('order')) {
|
61 |
-
return $this->getData('order');
|
62 |
-
}
|
63 |
-
|
64 |
-
if (!$this->getOrderId()) {
|
65 |
-
return null;
|
66 |
-
}
|
67 |
-
|
68 |
-
$order = Mage::getModel('sales/order')->load($this->getOrderId());
|
69 |
-
|
70 |
-
$this->setOrder($order);
|
71 |
-
return $order;
|
72 |
-
}
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Gets the quote associated with this PostNL Checkout Order
|
76 |
-
*
|
77 |
-
* @return Mage_Sales_Model_Quote | null
|
78 |
-
*/
|
79 |
-
public function getQuote()
|
80 |
-
{
|
81 |
-
if ($this->getData('quote')) {
|
82 |
-
return $this->getData('quote');
|
83 |
-
}
|
84 |
-
|
85 |
-
if (!$this-getQuoteId()) {
|
86 |
-
return null;
|
87 |
-
}
|
88 |
-
|
89 |
-
$order = Mage::getModel('sales/quote')->load($this->getQuoteId());
|
90 |
-
|
91 |
-
$this->setQuote($order);
|
92 |
-
return $order;
|
93 |
-
}
|
94 |
-
|
95 |
-
/**
|
96 |
-
* Alias for magic getToken()
|
97 |
-
*
|
98 |
-
* @return string
|
99 |
-
*/
|
100 |
-
public function getOrderToken()
|
101 |
-
{
|
102 |
-
return $this->getToken();
|
103 |
-
}
|
104 |
-
|
105 |
-
/**
|
106 |
-
* Alias for magic getQuoteId()
|
107 |
-
*
|
108 |
-
* @return int
|
109 |
-
*/
|
110 |
-
public function getExtRef()
|
111 |
-
{
|
112 |
-
return $this->getQuoteId();
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Cancels the PostNL order
|
117 |
-
*
|
118 |
-
* @return TIG_PostNL_Model_Checkout_Order
|
119 |
-
*
|
120 |
-
* @throws TIG_PostNL_Exception
|
121 |
-
*/
|
122 |
-
public function cancel()
|
123 |
-
{
|
124 |
-
$helper = Mage::helper('postnl');
|
125 |
-
if (!$this->getOrderId()) {
|
126 |
-
throw new TIG_PostNL_Exception(
|
127 |
-
$helper->__('This PostNL Checkout order cannot be cancelled: it has no associated magento order.'),
|
128 |
-
'POSTNL-0046'
|
129 |
-
);
|
130 |
-
}
|
131 |
Â
|
132 |
-
|
133 |
-
throw new TIG_PostNL_Exception(
|
134 |
-
$helper->__('This PostNL Checkout order cannot be cancelled: it has already been canceled.'),
|
135 |
-
'POSTNL-0047'
|
136 |
-
);
|
137 |
-
}
|
138 |
-
|
139 |
-
$cif = Mage::getModel('postnl_checkout/cif');
|
140 |
-
$cif->updateOrder($this, true);
|
141 |
-
|
142 |
-
$this->setIsCanceled(true);
|
143 |
-
|
144 |
-
return $this;
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* Sets new PostNL Orders to active before saving
|
149 |
-
*
|
150 |
-
* @return Mage_Core_Model_Abstract::_beforeSave();
|
151 |
-
*/
|
152 |
-
protected function _beforeSave()
|
153 |
-
{
|
154 |
-
if ($this->isObjectNew()) {
|
155 |
-
$this->setIsActive(1);
|
156 |
-
}
|
157 |
-
|
158 |
-
return parent::_beforeSave();
|
159 |
-
}
|
160 |
-
}
|
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.
|
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 |
+
* @deprecated 1.2.0 This class has been moved to TIG_PostNL_Model_Core_Order. A dummy class has been left behind to
|
40 |
+
* provide backwards compatibility. This class may be removed in the future without further notice.
|
41 |
Â
*/
|
42 |
+
class TIG_PostNL_Model_Checkout_Order extends TIG_PostNL_Model_Core_Order
|
43 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
44 |
Â
|
45 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,868 +1,972 @@
|
|
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)
|
37 |
-
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
const
|
54 |
-
const
|
55 |
-
const
|
56 |
-
const
|
57 |
-
const
|
58 |
-
const
|
59 |
-
const
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
*
|
95 |
-
*
|
96 |
-
*
|
97 |
-
*
|
98 |
-
* @
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
$
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
$shippingAddress
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
$billingAddress
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
$pakjeGemakAddress
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
*
|
198 |
-
*
|
199 |
-
* @param
|
200 |
-
*
|
201 |
-
* @
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
$
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
/**
|
358 |
-
*
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
*
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
$
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
)
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
$
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
$
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
$
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
)
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
$
|
635 |
-
|
636 |
-
|
637 |
-
$
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
$
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
/**
|
690 |
-
*
|
691 |
-
*/
|
692 |
-
$
|
693 |
-
$
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
$
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
return $
|
713 |
-
}
|
714 |
-
|
715 |
-
/**
|
716 |
-
*
|
717 |
-
*
|
718 |
-
*
|
719 |
-
*
|
720 |
-
* @
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
$
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
*
|
745 |
-
*
|
746 |
-
* @param
|
747 |
-
*
|
748 |
-
*
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
$
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
$
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
$
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
$
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
return $
|
838 |
-
}
|
839 |
-
|
840 |
-
/**
|
841 |
-
*
|
842 |
-
*
|
843 |
-
*
|
844 |
-
*
|
845 |
-
*
|
846 |
-
*
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method TIG_PostNL_Model_Checkout_Service setQuote(Mage_Sales_Model_Quote $value)
|
40 |
+
* @method TIG_PostNL_Model_Checkout_Service setStoreId(int $value)
|
41 |
+
* @method int getStoreId()
|
42 |
+
*/
|
43 |
+
class TIG_PostNL_Model_Checkout_Service extends Varien_Object
|
44 |
+
{
|
45 |
+
/**
|
46 |
+
* XML path to public webshop ID setting
|
47 |
+
*/
|
48 |
+
const XML_PATH_WEBSHOP_ID = 'postnl/cif/webshop_id';
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Constants containing XML paths to cif address configuration options
|
52 |
+
*/
|
53 |
+
const XML_PATH_SPLIT_STREET = 'postnl/cif_address/split_street';
|
54 |
+
const XML_PATH_STREETNAME_FIELD = 'postnl/cif_address/streetname_field';
|
55 |
+
const XML_PATH_HOUSENUMBER_FIELD = 'postnl/cif_address/housenr_field';
|
56 |
+
const XML_PATH_SPLIT_HOUSENUMBER = 'postnl/cif_address/split_housenr';
|
57 |
+
const XML_PATH_HOUSENUMBER_EXTENSION_FIELD = 'postnl/cif_address/housenr_extension_field';
|
58 |
+
const XML_PATH_AREA_FIELD = 'postnl/cif_address/area_field';
|
59 |
+
const XML_PATH_BUILDING_NAME_FIELD = 'postnl/cif_address/building_name_field';
|
60 |
+
const XML_PATH_DEPARTMENT_FIELD = 'postnl/cif_address/department_field';
|
61 |
+
const XML_PATH_DOORCODE_FIELD = 'postnl/cif_address/doorcode_field';
|
62 |
+
const XML_PATH_FLOOR_FIELD = 'postnl/cif_address/floor_field';
|
63 |
+
const XML_PATH_REMARK_FIELD = 'postnl/cif_address/remark_field';
|
64 |
+
|
65 |
+
/**
|
66 |
+
* XML path to all PostNL Checkout payment settings
|
67 |
+
* N.B. missing last part os it will return an array of settings
|
68 |
+
*/
|
69 |
+
const XML_PATH_PAYMENT_METHODS = 'postnl/checkout_payment_methods';
|
70 |
+
|
71 |
+
/**
|
72 |
+
* Newly added 'pakje_gemak' address type
|
73 |
+
*/
|
74 |
+
const ADDRESS_TYPE_PAKJEGEMAK = 'pakje_gemak';
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Gets the currently used quote object
|
78 |
+
*
|
79 |
+
* @return Mage_Sales_Model_Quote
|
80 |
+
*/
|
81 |
+
public function getQuote()
|
82 |
+
{
|
83 |
+
if ($this->getData('quote')) {
|
84 |
+
return $this->getData('quote');
|
85 |
+
}
|
86 |
+
|
87 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
88 |
+
|
89 |
+
$this->setQuote($quote);
|
90 |
+
return $quote;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Updates a quote with the given PostNL order data. Each part of the data is used to replace the data normally
|
95 |
+
* acquired during checkout.
|
96 |
+
*
|
97 |
+
* @param StdClass $data
|
98 |
+
* @param Mage_Sales_Model_Quote | null $quote
|
99 |
+
*
|
100 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
101 |
+
*
|
102 |
+
* @throws TIG_PostNL_Exception
|
103 |
+
*/
|
104 |
+
public function updateQuoteAddresses($data, $quote = null)
|
105 |
+
{
|
106 |
+
/**
|
107 |
+
* Load the current quote if none was supplied
|
108 |
+
*/
|
109 |
+
if (is_null($quote)) {
|
110 |
+
$quote = $this->getQuote();
|
111 |
+
}
|
112 |
+
|
113 |
+
$this->setStoreId($quote->getStoreId());
|
114 |
+
|
115 |
+
$this->_verifyData($data, $quote);
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Get consumer data
|
119 |
+
*/
|
120 |
+
$consumer = $data->Consument;
|
121 |
+
$email = $consumer->Email;
|
122 |
+
$phone = $consumer->TelefoonNummer;
|
123 |
+
if (!$phone) {
|
124 |
+
$phone = '-';
|
125 |
+
} else {
|
126 |
+
$phone = preg_replace("/[^0-9]/", '', $phone);
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Remove all existing addresses, we're going to add new ones
|
131 |
+
*/
|
132 |
+
$this->_removeAllQuoteAddresses($quote);
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Parse the shippingaddresses
|
136 |
+
*/
|
137 |
+
$delivery = $data->Bezorging;
|
138 |
+
$shippingAddressData = $delivery->Geadresseerde;
|
139 |
+
|
140 |
+
$shippingAddress = Mage::getModel('sales/quote_address');
|
141 |
+
$shippingAddress->setAddressType($shippingAddress::TYPE_SHIPPING)
|
142 |
+
->setEmail($email)
|
143 |
+
->setTelephone($phone);
|
144 |
+
|
145 |
+
$shippingAddress = $this->_parseAddress($shippingAddress, $shippingAddressData);
|
146 |
+
|
147 |
+
$shippingMethod = Mage::helper('postnl/carrier')->getCurrentPostnlShippingMethod();
|
148 |
+
if (!$shippingAddress->getShippingMethod()) {
|
149 |
+
$shippingAddress->setCollectShippingRates(true)
|
150 |
+
->setShippingMethod($shippingMethod);
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Parse the billing address
|
155 |
+
*/
|
156 |
+
$billingAddressData = $data->Facturatie->Adres;
|
157 |
+
$billingAddress = Mage::getModel('sales/quote_address');
|
158 |
+
$billingAddress->setAddressType($billingAddress::TYPE_BILLING)
|
159 |
+
->setEmail($email)
|
160 |
+
->setTelephone($phone);
|
161 |
+
|
162 |
+
$billingAddress = $this->_parseAddress($billingAddress, $billingAddressData);
|
163 |
+
|
164 |
+
/**
|
165 |
+
* If a servicelocation was set, add that as a third address
|
166 |
+
*/
|
167 |
+
if (isset($delivery->ServicePunt)) {
|
168 |
+
$serviceLocationData = $delivery->ServicePunt;
|
169 |
+
$pakjeGemakAddress = Mage::getModel('sales/quote_address');
|
170 |
+
$pakjeGemakAddress->setAddressType(self::ADDRESS_TYPE_PAKJEGEMAK)
|
171 |
+
->setEmail($email)
|
172 |
+
->setTelephone($phone);
|
173 |
+
|
174 |
+
$pakjeGemakAddress = $this->_parseAddress($pakjeGemakAddress, $serviceLocationData);
|
175 |
+
|
176 |
+
$quote->addAddress($pakjeGemakAddress);
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Register that this is a PakjeGemak order
|
180 |
+
*/
|
181 |
+
Mage::register('quote_is_pakje_gemak', 1);
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Update the quote's addresses
|
186 |
+
*/
|
187 |
+
$quote->setCustomerEmail($email)
|
188 |
+
->setShippingAddress($shippingAddress)
|
189 |
+
->setBillingAddress($billingAddress)
|
190 |
+
->collectTotals()
|
191 |
+
->save();
|
192 |
+
|
193 |
+
return $this;
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Updates a quote with the given payment data (from PostNL or magento).
|
198 |
+
*
|
199 |
+
* @param mixed $data
|
200 |
+
* @param boolean $isOrderdetails Flag whether or not the supplied data was sent by PostNL and not by magento
|
201 |
+
* @param boolean $methodOnly Flag whether or not to only set the payment method. If false, all data will be set
|
202 |
+
* for the chosen payment method.
|
203 |
+
* @param Mage_Sales_Model_Quote|null $quote
|
204 |
+
*
|
205 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
206 |
+
*/
|
207 |
+
public function updateQuotePayment($data, $isOrderdetails = true, $methodOnly = false, $quote = null)
|
208 |
+
{
|
209 |
+
/**
|
210 |
+
* Load the current quote if none was supplied
|
211 |
+
*/
|
212 |
+
if (is_null($quote)) {
|
213 |
+
$quote = $this->getQuote();
|
214 |
+
}
|
215 |
+
|
216 |
+
$this->setStoreId($quote->getStoreId());
|
217 |
+
|
218 |
+
/**
|
219 |
+
* If the payment data is sent by PostNL we need to process it accordingly
|
220 |
+
*/
|
221 |
+
if ($isOrderdetails) {
|
222 |
+
$this->_verifyData($data, $quote);
|
223 |
+
$this->_processPostnlPaymentData($data, $methodOnly, $quote);
|
224 |
+
|
225 |
+
return $this;
|
226 |
+
}
|
227 |
+
|
228 |
+
/**
|
229 |
+
* Otherwise, we need to process the data as we would with a regular checkout procedure
|
230 |
+
*/
|
231 |
+
if ($quote->isVirtual()) {
|
232 |
+
$quote->getBillingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
233 |
+
} else {
|
234 |
+
$quote->getShippingAddress()->setPaymentMethod(isset($data['method']) ? $data['method'] : null);
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* shipping totals may be affected by payment method
|
239 |
+
*/
|
240 |
+
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
|
241 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
242 |
+
}
|
243 |
+
|
244 |
+
/**
|
245 |
+
* Extra checks used by Magento
|
246 |
+
*
|
247 |
+
* @var $paymentMethodAbstractClass Mage_Payment_Model_Method_Abstract
|
248 |
+
*
|
249 |
+
* @since Magento v1.13
|
250 |
+
*/
|
251 |
+
$paymentMethodAbstractClass = Mage::getConfig()->getModelClassName('payment/method_abstract');
|
252 |
+
if (defined($paymentMethodAbstractClass . '::CHECK_USE_CHECKOUT')
|
253 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_COUNTRY')
|
254 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_CURRENCY')
|
255 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_ORDER_TOTAL_MIN_MAX')
|
256 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_ZERO_TOTAL')
|
257 |
+
) {
|
258 |
+
$data['checks'] = $paymentMethodAbstractClass::CHECK_USE_CHECKOUT
|
259 |
+
| $paymentMethodAbstractClass::CHECK_USE_FOR_COUNTRY
|
260 |
+
| $paymentMethodAbstractClass::CHECK_USE_FOR_CURRENCY
|
261 |
+
| $paymentMethodAbstractClass::CHECK_ORDER_TOTAL_MIN_MAX
|
262 |
+
| $paymentMethodAbstractClass::CHECK_ZERO_TOTAL;
|
263 |
+
}
|
264 |
+
|
265 |
+
$paymentDataObject = new Varien_Object();
|
266 |
+
$paymentDataObject->setPaymentData($data);
|
267 |
+
|
268 |
+
Mage::dispatchEvent(
|
269 |
+
'postnl_checkout_set_payment_before',
|
270 |
+
array(
|
271 |
+
'payment' => $quote->getPayment(),
|
272 |
+
'quote' => $quote,
|
273 |
+
'payment_data_object' => $paymentDataObject,
|
274 |
+
)
|
275 |
+
);
|
276 |
+
|
277 |
+
$paymentData = $paymentDataObject->getPaymentData();
|
278 |
+
|
279 |
+
$quote->getPayment()->setMethod($data['method'])->importData($paymentData);
|
280 |
+
$quote->getPayment()->getMethodInstance()->assignData($paymentData);
|
281 |
+
|
282 |
+
Mage::dispatchEvent(
|
283 |
+
'postnl_checkout_set_payment_after',
|
284 |
+
array(
|
285 |
+
'payment' => $quote->getPayment(),
|
286 |
+
'quote' => $quote,
|
287 |
+
)
|
288 |
+
);
|
289 |
+
|
290 |
+
$quote->save();
|
291 |
+
|
292 |
+
return $this;
|
293 |
+
}
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Processes PostNL payment data
|
297 |
+
*
|
298 |
+
* @param StdClass $data
|
299 |
+
* @param boolean $methodOnly
|
300 |
+
* @param Mage_Sales_Model_Quote $quote
|
301 |
+
*
|
302 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
303 |
+
*
|
304 |
+
* @throws TIG_PostNL_Exception
|
305 |
+
*/
|
306 |
+
protected function _processPostnlPaymentData($data, $methodOnly, $quote)
|
307 |
+
{
|
308 |
+
/**
|
309 |
+
* Get the payment data PostNL supplied
|
310 |
+
*/
|
311 |
+
$postnlPaymentData = $data->BetaalMethode;
|
312 |
+
|
313 |
+
/**
|
314 |
+
* Check if the plugin supports the chosen payment method
|
315 |
+
*/
|
316 |
+
$postnlPaymentMethods = Mage::helper('postnl/checkout')->getCheckoutPaymentMethods();
|
317 |
+
$methodName = array_search($postnlPaymentData->Code, $postnlPaymentMethods);
|
318 |
+
|
319 |
+
/**
|
320 |
+
* Check if the payment method chosen is allowed
|
321 |
+
*/
|
322 |
+
if (!Mage::getStoreConfigFlag(self::XML_PATH_PAYMENT_METHODS . '/' . $methodName, $quote->getStoreId())) {
|
323 |
+
throw new TIG_PostNL_Exception(
|
324 |
+
Mage::helper('postnl')->__('Selected payment method %s is not available.', $methodName),
|
325 |
+
'POSTNL-0048'
|
326 |
+
);
|
327 |
+
}
|
328 |
+
|
329 |
+
if ($methodOnly === true) {
|
330 |
+
$this->_processPaymentMethod($methodName, $quote);
|
331 |
+
return $this;
|
332 |
+
}
|
333 |
+
|
334 |
+
$this->_processPaymentData($postnlPaymentData, $methodName, $quote);
|
335 |
+
return $this;
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Process a chosen payment method
|
340 |
+
*
|
341 |
+
* @param string $methodName
|
342 |
+
* @param Mage_Sales_Model_Quote $quote
|
343 |
+
*
|
344 |
+
* @return TIG_PostNL_Exception
|
345 |
+
*/
|
346 |
+
protected function _processPaymentMethod($methodName, $quote)
|
347 |
+
{
|
348 |
+
/**
|
349 |
+
* Get the Magento payment method code associated with this method
|
350 |
+
*/
|
351 |
+
$methodCode = Mage::getStoreConfig(
|
352 |
+
self::XML_PATH_PAYMENT_METHODS . '/' . $methodName . '_method',
|
353 |
+
$quote->getStoreId()
|
354 |
+
);
|
355 |
+
Mage::register('postnl_payment_data', array('method' => $methodCode));
|
356 |
+
|
357 |
+
/**
|
358 |
+
* Remove any current payment associtaed with the quote and get a new one
|
359 |
+
*/
|
360 |
+
$payment = $quote->removePayment()
|
361 |
+
->getPayment();
|
362 |
+
|
363 |
+
$payment->setMethod($methodCode);
|
364 |
+
$quote->save();
|
365 |
+
|
366 |
+
return $this;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Process a chosen payment method with extra payment data
|
371 |
+
*
|
372 |
+
* @param StdClass $postnlPaymentData
|
373 |
+
* @param string $methodName
|
374 |
+
* @param Mage_Sales_Model_Quote $quote
|
375 |
+
*
|
376 |
+
* @return TIG_PostNL_Exception
|
377 |
+
*/
|
378 |
+
protected function _processPaymentData($postnlPaymentData, $methodName, $quote)
|
379 |
+
{
|
380 |
+
/**
|
381 |
+
* Otherwise we need to form the payment data array containing all relevant payment data
|
382 |
+
*/
|
383 |
+
$paymentData = Mage::app()->getRequest()->getPost('payment', array());
|
384 |
+
|
385 |
+
$optionValue = $postnlPaymentData->Optie;
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Get the payment method code associated with the chosen payment method
|
389 |
+
*/
|
390 |
+
$methodCode = Mage::getStoreConfig(
|
391 |
+
self::XML_PATH_PAYMENT_METHODS . '/' . $methodName . '_method',
|
392 |
+
$quote->getStoreId()
|
393 |
+
);
|
394 |
+
|
395 |
+
/**
|
396 |
+
* Extra checks used by Magento
|
397 |
+
*
|
398 |
+
* @since Magento CE v1.7
|
399 |
+
* @since Magento EE v1.13
|
400 |
+
*
|
401 |
+
* @var $paymentMethodAbstractClass Mage_Payment_Model_Method_Abstract
|
402 |
+
*/
|
403 |
+
$paymentMethodAbstractClass = Mage::getConfig()->getModelClassName('payment/method_abstract');
|
404 |
+
if (defined($paymentMethodAbstractClass . '::CHECK_USE_CHECKOUT')
|
405 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_COUNTRY')
|
406 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_USE_FOR_CURRENCY')
|
407 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_ORDER_TOTAL_MIN_MAX')
|
408 |
+
&& defined($paymentMethodAbstractClass . '::CHECK_ZERO_TOTAL')
|
409 |
+
) {
|
410 |
+
$paymentData['checks'] = $paymentMethodAbstractClass::CHECK_USE_CHECKOUT
|
411 |
+
| $paymentMethodAbstractClass::CHECK_USE_FOR_COUNTRY
|
412 |
+
| $paymentMethodAbstractClass::CHECK_USE_FOR_CURRENCY
|
413 |
+
| $paymentMethodAbstractClass::CHECK_ORDER_TOTAL_MIN_MAX
|
414 |
+
| $paymentMethodAbstractClass::CHECK_ZERO_TOTAL;
|
415 |
+
}
|
416 |
+
|
417 |
+
if ($quote->isVirtual()) {
|
418 |
+
$quote->getBillingAddress()->setPaymentMethod($methodCode);
|
419 |
+
} else {
|
420 |
+
$quote->getShippingAddress()->setPaymentMethod($methodCode);
|
421 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
422 |
+
}
|
423 |
+
|
424 |
+
$paymentData['method'] = $methodCode;
|
425 |
+
|
426 |
+
/**
|
427 |
+
* If the chosen payment method has an optional field (like bank selection for iDEAL) we have to check
|
428 |
+
* system / config in order to map it to a form field the payment method would expect.
|
429 |
+
*/
|
430 |
+
if ($optionValue) {
|
431 |
+
$field = Mage::getStoreConfig(
|
432 |
+
self::XML_PATH_PAYMENT_METHODS . '/' . $methodName . '_option_field',
|
433 |
+
$quote->getStoreId()
|
434 |
+
);
|
435 |
+
|
436 |
+
/**
|
437 |
+
* If a field name is specified we add the option to the payment data as well as to the super global POST
|
438 |
+
* array.
|
439 |
+
*/
|
440 |
+
if ($field) {
|
441 |
+
$paymentData[$field] = $optionValue;
|
442 |
+
$_POST[$field] = $optionValue;
|
443 |
+
}
|
444 |
+
}
|
445 |
+
|
446 |
+
$paymentDataObject = new Varien_Object();
|
447 |
+
$paymentDataObject->setPaymentData($paymentData);
|
448 |
+
|
449 |
+
Mage::dispatchEvent(
|
450 |
+
'postnl_checkout_set_payment_before',
|
451 |
+
array(
|
452 |
+
'payment' => $quote->getPayment(),
|
453 |
+
'quote' => $quote,
|
454 |
+
'payment_data_object' => $paymentDataObject,
|
455 |
+
)
|
456 |
+
);
|
457 |
+
|
458 |
+
$paymentData = $paymentDataObject->getPaymentData();
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Import the payment data, save the payment, and then save the quote
|
462 |
+
*/
|
463 |
+
$quote->getPayment()->importData($paymentData);
|
464 |
+
|
465 |
+
Mage::dispatchEvent(
|
466 |
+
'postnl_checkout_set_payment_after',
|
467 |
+
array(
|
468 |
+
'payment' => $quote->getPayment(),
|
469 |
+
'quote' => $quote,
|
470 |
+
)
|
471 |
+
);
|
472 |
+
|
473 |
+
$quote->save();
|
474 |
+
|
475 |
+
return $this;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* Adds the customer to the quote if a customer is currently logged in. Also updates the customer's DOB if possible.
|
480 |
+
*
|
481 |
+
* @param StdClass $data
|
482 |
+
* @param Mage_Sales_Model_Quote | null $quote
|
483 |
+
*
|
484 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
485 |
+
*/
|
486 |
+
public function updateQuoteCustomer($data, $quote = null)
|
487 |
+
{
|
488 |
+
/**
|
489 |
+
* Load the current quote if none was supplied
|
490 |
+
*/
|
491 |
+
if (is_null($quote)) {
|
492 |
+
$quote = $this->getQuote();
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Load the current customer if the user is logged in
|
497 |
+
*/
|
498 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
499 |
+
$customerId = $customer->getId();
|
500 |
+
|
501 |
+
/**
|
502 |
+
* If there is no customer we don't have to do anything
|
503 |
+
*/
|
504 |
+
if(!$customerId) {
|
505 |
+
return $this;
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* Add the customer to the quote
|
510 |
+
*/
|
511 |
+
$quote->setCustomerId($customerId);
|
512 |
+
$quote->getShippingAddress()->setCustomerId($customerId);
|
513 |
+
$quote->getBillingAddress()->setCustomerId($customerId);
|
514 |
+
|
515 |
+
/**
|
516 |
+
* If the customer already has a DOB we're finished
|
517 |
+
*/
|
518 |
+
if ($customer->getDob()) {
|
519 |
+
return $this;
|
520 |
+
}
|
521 |
+
|
522 |
+
/**
|
523 |
+
* Check if PostNL returned a DOB for the customer
|
524 |
+
*/
|
525 |
+
if (isset($data->Consument)
|
526 |
+
&& is_object($data->Consument)
|
527 |
+
&& isset($data->Consument->GeboorteDatum)
|
528 |
+
&& !empty($data->Consument->GeboorteDatum)
|
529 |
+
) {
|
530 |
+
$dob = $data->Consument->GeboorteDatum;
|
531 |
+
}
|
532 |
+
|
533 |
+
if (!isset($dob)) {
|
534 |
+
return $this;
|
535 |
+
}
|
536 |
+
|
537 |
+
/**
|
538 |
+
* Update the customer with the DOB and save
|
539 |
+
*/
|
540 |
+
$customer->setDob(strtotime($dob))
|
541 |
+
->save();
|
542 |
+
|
543 |
+
return $this;
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
+
* Updates the PostNL order with the selected options
|
548 |
+
*
|
549 |
+
* @param $data
|
550 |
+
* @param null $quote
|
551 |
+
*
|
552 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
553 |
+
*/
|
554 |
+
public function updatePostnlOrder($data, $quote = null)
|
555 |
+
{
|
556 |
+
/**
|
557 |
+
* Load the current quote if none was supplied
|
558 |
+
*/
|
559 |
+
if (is_null($quote)) {
|
560 |
+
$quote = $this->getQuote();
|
561 |
+
}
|
562 |
+
|
563 |
+
$this->setStoreId($quote->getStoreId());
|
564 |
+
|
565 |
+
$this->_verifyData($data, $quote);
|
566 |
+
|
567 |
+
$postnlOrder = Mage::getModel('postnl_core/order');
|
568 |
+
$postnlOrder->load($quote->getId(), 'quote_id');
|
569 |
+
|
570 |
+
/**
|
571 |
+
* If a confirm date has been specified, save it with the PostNL Order object so we can reference it later
|
572 |
+
*/
|
573 |
+
if (isset($data->Voorkeuren)
|
574 |
+
&& is_object($data->Voorkeuren)
|
575 |
+
&& isset($data->Voorkeuren->Bezorging)
|
576 |
+
&& is_object($data->Voorkeuren->Bezorging)
|
577 |
+
&& isset($data->Voorkeuren->Bezorging->VerzendDatum)
|
578 |
+
&& isset($data->Voorkeuren->Bezorging->Datum)
|
579 |
+
) {
|
580 |
+
$delivery = $data->Voorkeuren->Bezorging;
|
581 |
+
$postnlOrder->setConfirmDate($delivery->VerzendDatum)
|
582 |
+
->setDeliveryDate($delivery->Datum);
|
583 |
+
}
|
584 |
+
|
585 |
+
/**
|
586 |
+
* If a specific product code is needed to ship this order, save it as well
|
587 |
+
*/
|
588 |
+
if (isset($data->Bezorging)
|
589 |
+
&& is_object($data->Bezorging)
|
590 |
+
&& isset($data->Bezorging->ProductCode)
|
591 |
+
) {
|
592 |
+
$postnlOrder->setProductCode($data->Bezorging->ProductCode);
|
593 |
+
}
|
594 |
+
|
595 |
+
/**
|
596 |
+
* Check if this is a PakjeGemak order. If so, save the PostNL Order as such
|
597 |
+
*/
|
598 |
+
if (Mage::registry('quote_is_pakje_gemak')) {
|
599 |
+
$postnlOrder->setIsPakjeGemak(1);
|
600 |
+
|
601 |
+
Mage::unRegister('quote_is_pakje_gemak');
|
602 |
+
}
|
603 |
+
|
604 |
+
$postnlOrder->save();
|
605 |
+
|
606 |
+
return $this;
|
607 |
+
}
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Converts a quote to it's order
|
611 |
+
*
|
612 |
+
* @param Mage_Sales_Model_Quote $quote
|
613 |
+
*
|
614 |
+
* @return Mage_Sales_Model_Order
|
615 |
+
*
|
616 |
+
* @throws TIG_PostNL_Exception
|
617 |
+
*/
|
618 |
+
public function saveOrder($quote = null)
|
619 |
+
{
|
620 |
+
/**
|
621 |
+
* Load the current quote if none was supplied
|
622 |
+
*/
|
623 |
+
if (is_null($quote)) {
|
624 |
+
$quote = $this->getQuote();
|
625 |
+
}
|
626 |
+
|
627 |
+
Mage::dispatchEvent('postnl_checkout_save_order_before',
|
628 |
+
array(
|
629 |
+
'quote' => $quote
|
630 |
+
)
|
631 |
+
);
|
632 |
+
|
633 |
+
$quoteService = Mage::getModel('sales/service_quote', $quote);
|
634 |
+
$quoteService->submitAll();
|
635 |
+
$order = $quoteService->getOrder();
|
636 |
+
|
637 |
+
if(empty($order)) {
|
638 |
+
throw new TIG_PostNL_Exception(
|
639 |
+
Mage::helper('postnl')->__('Unable to create an order for quote #%s', $quote->getId()),
|
640 |
+
'POSTNL-0049'
|
641 |
+
);
|
642 |
+
}
|
643 |
+
|
644 |
+
/**
|
645 |
+
* If a pakje_gemak address is present, add it to the order as well.
|
646 |
+
*
|
647 |
+
* @var Mage_Sales_Model_Quote_Address $address
|
648 |
+
*/
|
649 |
+
$quoteAddresses = $quote->getAllAddresses();
|
650 |
+
foreach ($quoteAddresses as $address) {
|
651 |
+
if ($address->getAddressType() != self::ADDRESS_TYPE_PAKJEGEMAK) {
|
652 |
+
continue;
|
653 |
+
}
|
654 |
+
|
655 |
+
$address->load($address->getId());
|
656 |
+
$orderAddress = Mage::getModel('sales/convert_quote')->addressToOrderAddress($address);
|
657 |
+
|
658 |
+
$order->addAddress($orderAddress);
|
659 |
+
|
660 |
+
$orderAddress->save();
|
661 |
+
break;
|
662 |
+
}
|
663 |
+
|
664 |
+
/**
|
665 |
+
* Save the customer's name
|
666 |
+
*/
|
667 |
+
$billingAddress = $quote->getBillingAddress();
|
668 |
+
$order->setCustomerFirstname($billingAddress->getFirstname())
|
669 |
+
->setCustomerLastname($billingAddress->getLastname())
|
670 |
+
->save();
|
671 |
+
|
672 |
+
Mage::dispatchEvent('checkout_type_onepage_save_order_after',
|
673 |
+
array(
|
674 |
+
'order' => $order,
|
675 |
+
'quote' => $quote
|
676 |
+
)
|
677 |
+
);
|
678 |
+
|
679 |
+
Mage::dispatchEvent('postnl_checkout_save_order_after',
|
680 |
+
array(
|
681 |
+
'order' => $order,
|
682 |
+
'quote' => $quote
|
683 |
+
)
|
684 |
+
);
|
685 |
+
|
686 |
+
$quote->setIsActive(false)
|
687 |
+
->save();
|
688 |
+
|
689 |
+
/**
|
690 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
691 |
+
*/
|
692 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($quote->getId(), 'quote_id');
|
693 |
+
$postnlOrder->setOrderId($order->getId())
|
694 |
+
->setIsActive(false)
|
695 |
+
->save();
|
696 |
+
|
697 |
+
$checkoutSession = Mage::getSingleton('checkout/session');
|
698 |
+
$checkoutSession->setLastSuccessQuoteId($order->getQuoteId())
|
699 |
+
->setLastRealOrderId($order->getRealOrderId())
|
700 |
+
->setLastQuoteId($order->getQuoteId())
|
701 |
+
->setLastOrderId($order->getId());
|
702 |
+
|
703 |
+
Mage::dispatchEvent(
|
704 |
+
'checkout_submit_all_after',
|
705 |
+
array(
|
706 |
+
'order' => $order,
|
707 |
+
'quote' => $quote,
|
708 |
+
'recurring_profiles' => null
|
709 |
+
)
|
710 |
+
);
|
711 |
+
|
712 |
+
return $order;
|
713 |
+
}
|
714 |
+
|
715 |
+
/**
|
716 |
+
* Confirms a PostNL order with PostNL.
|
717 |
+
*
|
718 |
+
* @param Mage_Sales_Model_Quote
|
719 |
+
*
|
720 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
721 |
+
*/
|
722 |
+
public function confirmPostnlOrder($quote = null)
|
723 |
+
{
|
724 |
+
/**
|
725 |
+
* Load the current quote if none was supplied
|
726 |
+
*/
|
727 |
+
if (is_null($quote)) {
|
728 |
+
$quote = $this->getQuote();
|
729 |
+
}
|
730 |
+
|
731 |
+
/**
|
732 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
733 |
+
*/
|
734 |
+
$postnlOrder = Mage::getModel('postnl_core/order')
|
735 |
+
->load($quote->getId(), 'quote_id');
|
736 |
+
|
737 |
+
$cif = Mage::getModel('postnl_checkout/cif');
|
738 |
+
$cif->confirmOrder($postnlOrder);
|
739 |
+
|
740 |
+
return $this;
|
741 |
+
}
|
742 |
+
|
743 |
+
/**
|
744 |
+
* Parses a PostNL Checkout address into a varien object that can be used by Magento.
|
745 |
+
*
|
746 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
747 |
+
* @param StdClass $addressData
|
748 |
+
*
|
749 |
+
* @return Mage_Sales_Model_Quote_Address
|
750 |
+
*/
|
751 |
+
protected function _parseAddress($address, $addressData)
|
752 |
+
{
|
753 |
+
$storeId = $this->getStoreId();
|
754 |
+
|
755 |
+
/**
|
756 |
+
* First parse the street data (streetname, house nr. house nr. ext.)
|
757 |
+
*/
|
758 |
+
$address = $this->_parseStreetData($address, $addressData);
|
759 |
+
|
760 |
+
/**
|
761 |
+
* Parse optional address fields
|
762 |
+
*/
|
763 |
+
$buildingNameField = Mage::getStoreConfig(self::XML_PATH_BUILDING_NAME_FIELD, $storeId);
|
764 |
+
$departmentField = Mage::getStoreConfig(self::XML_PATH_DEPARTMENT_FIELD, $storeId);
|
765 |
+
$doorcodeField = Mage::getStoreConfig(self::XML_PATH_DOORCODE_FIELD, $storeId);
|
766 |
+
$floorField = Mage::getStoreConfig(self::XML_PATH_FLOOR_FIELD, $storeId);
|
767 |
+
$areaField = Mage::getStoreConfig(self::XML_PATH_AREA_FIELD, $storeId);
|
768 |
+
|
769 |
+
if ($buildingNameField) {
|
770 |
+
$address->setData('street' . $buildingNameField, $addressData->Gebouw);
|
771 |
+
}
|
772 |
+
|
773 |
+
if ($departmentField) {
|
774 |
+
$address->setData('street' . $departmentField, $addressData->Afdeling);
|
775 |
+
}
|
776 |
+
|
777 |
+
if ($doorcodeField) {
|
778 |
+
$address->setData('street' . $doorcodeField, $addressData->Deurcode);
|
779 |
+
}
|
780 |
+
|
781 |
+
if ($floorField) {
|
782 |
+
$address->setData('street' . $floorField, $addressData->Verdieping);
|
783 |
+
}
|
784 |
+
|
785 |
+
if ($areaField) {
|
786 |
+
$address->setData('street' . $areaField, $addressData->Wijk);
|
787 |
+
}
|
788 |
+
|
789 |
+
/**
|
790 |
+
* Parse the remaining simple fields that require no additional logic
|
791 |
+
*/
|
792 |
+
$firstname = $addressData->Voornaam;
|
793 |
+
$lastname = $addressData->Achternaam;
|
794 |
+
$middlename = $addressData->Tussenvoegsel;
|
795 |
+
$country = $addressData->Land;
|
796 |
+
$city = $addressData->Plaats;
|
797 |
+
$postcode = $addressData->Postcode;
|
798 |
+
|
799 |
+
$address->setFirstname($firstname)
|
800 |
+
->setLastname($lastname)
|
801 |
+
->setMiddlename($middlename)
|
802 |
+
->setCountryId($country)
|
803 |
+
->setCity($city)
|
804 |
+
->setPostcode($postcode);
|
805 |
+
|
806 |
+
if (!$address->getCountryId()) {
|
807 |
+
$address->setCountryId('NL');
|
808 |
+
}
|
809 |
+
|
810 |
+
$address->setShouldIgnoreValidation(true);
|
811 |
+
|
812 |
+
return $address;
|
813 |
+
}
|
814 |
+
|
815 |
+
/**
|
816 |
+
* Add optional service location data to the shipping address. This ovverrides the previously set address data.
|
817 |
+
* nto a varien object that can be used by Magento
|
818 |
+
*
|
819 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
820 |
+
* @param $serviceLocationData
|
821 |
+
*
|
822 |
+
* @return Mage_Sales_Model_Quote_Address
|
823 |
+
*/
|
824 |
+
protected function _addServiceLocationData($address, $serviceLocationData)
|
825 |
+
{
|
826 |
+
/**
|
827 |
+
* First parse the street data (streetname, house nr. house nr. ext.)
|
828 |
+
*/
|
829 |
+
$address = $this->_parseStreetData($address, $serviceLocationData);
|
830 |
+
|
831 |
+
/**
|
832 |
+
* Remove any company data that may have been set, this could cause confusion when delivering the package to a
|
833 |
+
* service location with a different company name.
|
834 |
+
*/
|
835 |
+
$address->setCompany(false);
|
836 |
+
|
837 |
+
return $address;
|
838 |
+
}
|
839 |
+
|
840 |
+
/**
|
841 |
+
* Parses street data and returns an address object containing properly formatted street lines.
|
842 |
+
*
|
843 |
+
* @param Mage_Sales_Model_Quote_Address $address
|
844 |
+
* @param StdClass $addressData
|
845 |
+
*
|
846 |
+
* @return Mage_Sales_Model_Quote_Address
|
847 |
+
*/
|
848 |
+
protected function _parseStreetData($address, $addressData)
|
849 |
+
{
|
850 |
+
$storeId = $this->getStoreId();
|
851 |
+
$splitStreet = Mage::getStoreConfigFlag(self::XML_PATH_SPLIT_STREET, $storeId);
|
852 |
+
|
853 |
+
if (!$splitStreet) {
|
854 |
+
/**
|
855 |
+
* If the store uses single line addresses, merge the street fields
|
856 |
+
*/
|
857 |
+
$streetData = $addressData->Straat
|
858 |
+
. PHP_EOL
|
859 |
+
. $addressData->Huisnummer
|
860 |
+
. PHP_EOL
|
861 |
+
. $addressData->HuisnummerExt;
|
862 |
+
|
863 |
+
$address->setStreet($streetData);
|
864 |
+
return $address;
|
865 |
+
}
|
866 |
+
|
867 |
+
$streetData = array();
|
868 |
+
|
869 |
+
/**
|
870 |
+
* If the store uses multiple address lines, check which part of the address goes where
|
871 |
+
*/
|
872 |
+
$streetnameField = Mage::getStoreConfig(self::XML_PATH_STREETNAME_FIELD, $storeId);
|
873 |
+
$housenumberField = Mage::getStoreCOnfig(self::XML_PATH_HOUSENUMBER_FIELD, $storeId);
|
874 |
+
|
875 |
+
/**
|
876 |
+
* Set the streetname to the appropriate field
|
877 |
+
*/
|
878 |
+
$streetData[$streetnameField] = $addressData->Straat;
|
879 |
+
|
880 |
+
/**
|
881 |
+
* Check if the store splits housenumber and housenumber extensions as well. Place them in appriopriate fields
|
882 |
+
*/
|
883 |
+
$splitHousenumber = Mage::getStoreConfigFlag(self::XML_PATH_SPLIT_HOUSENUMBER, $storeId);
|
884 |
+
if (!$splitHousenumber) {
|
885 |
+
$housenumber = $addressData->Huisnummer . ' ' . $addressData->HuisnummerExt;
|
886 |
+
$streetData[$housenumberField] = $housenumber;
|
887 |
+
} else {
|
888 |
+
$housenumberExtensionField = Mage::getStoreConfig(self::XML_PATH_HOUSENUMBER_EXTENSION_FIELD, $storeId);
|
889 |
+
$streetData[$housenumberField] = $addressData->Huisnummer;
|
890 |
+
$streetData[$housenumberExtensionField] = $addressData->HuisnummerExt;
|
891 |
+
}
|
892 |
+
|
893 |
+
/**
|
894 |
+
* Sort the street data according to the field numbers and set it
|
895 |
+
*/
|
896 |
+
ksort($streetData);
|
897 |
+
$address->setStreet($streetData);
|
898 |
+
|
899 |
+
return $address;
|
900 |
+
}
|
901 |
+
|
902 |
+
/**
|
903 |
+
* Verifies the validity of the supplied data
|
904 |
+
*
|
905 |
+
* @param StdClass $data
|
906 |
+
* @param Mage_Sales_Model_Quote $quote
|
907 |
+
*
|
908 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
909 |
+
*
|
910 |
+
* @throws TIG_PostNL_Exception
|
911 |
+
*/
|
912 |
+
protected function _verifyData($data, $quote)
|
913 |
+
{
|
914 |
+
/**
|
915 |
+
* Check if the quote matches the one PostNL expected
|
916 |
+
*/
|
917 |
+
$quoteId = $data->Order->ExtRef;
|
918 |
+
if ($quote->getId() != $quoteId) {
|
919 |
+
throw new TIG_PostNL_Exception(
|
920 |
+
Mage::helper('postnl')->__('Invalid quote supplied.'),
|
921 |
+
'POSTNL-0050'
|
922 |
+
);
|
923 |
+
}
|
924 |
+
|
925 |
+
/**
|
926 |
+
* Verify the webshop ID to make sure this message was not meant for another shop
|
927 |
+
*/
|
928 |
+
$dataWebshopId = $data->Webshop->IntRef;
|
929 |
+
$webshopId = Mage::getStoreConfig(self::XML_PATH_WEBSHOP_ID, $this->getStoreId());
|
930 |
+
$webshopId = Mage::helper('core')->decrypt($webshopId);
|
931 |
+
|
932 |
+
if ($webshopId != $dataWebshopId) {
|
933 |
+
throw new TIG_PostNL_Exception(
|
934 |
+
Mage::helper('postnl')->__('Invalid data supplied.'),
|
935 |
+
'POSTNL-0051'
|
936 |
+
);
|
937 |
+
}
|
938 |
+
|
939 |
+
return $this;
|
940 |
+
}
|
941 |
+
|
942 |
+
/**
|
943 |
+
* Removes all addresses associated with a quote. The quote's regular method to remove all addresses
|
944 |
+
* (removeAllAddresses()) effectively resets the addresses rather than removing them (replaces each address by a
|
945 |
+
* default one of the same type). We specifically want to delete the optional PakjeGemak address as well.
|
946 |
+
*
|
947 |
+
* @param Mage_Sales_Model_Quote &$quote
|
948 |
+
*
|
949 |
+
* @return TIG_PostNL_Model_Checkout_Service
|
950 |
+
*/
|
951 |
+
protected function _removeAllQuoteAddresses(&$quote)
|
952 |
+
{
|
953 |
+
/**
|
954 |
+
* Truly delete the PakjeGemak address.
|
955 |
+
*
|
956 |
+
* @var Mage_Sales_Model_Quote_Address $address
|
957 |
+
*/
|
958 |
+
$addresses = $quote->getAllAddresses();
|
959 |
+
foreach ($addresses as $address) {
|
960 |
+
if ($address->getAddressType() == self::ADDRESS_TYPE_PAKJEGEMAK) {
|
961 |
+
$address->isDeleted(true);
|
962 |
+
}
|
963 |
+
}
|
964 |
+
|
965 |
+
/**
|
966 |
+
* Reset all remaining address types (by default only billing and shipping will remain)
|
967 |
+
*/
|
968 |
+
$quote->removeAllAddresses();
|
969 |
+
|
970 |
+
return $this;
|
971 |
+
}
|
972 |
+
}
|
@@ -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,28 +40,28 @@ class TIG_PostNL_Model_Checkout_System_Config_Source_ActivePaymentMethods
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Gets an array of active payment methods
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
47 |
Â
{
|
48 |
Â
$paymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();
|
49 |
-
|
50 |
Â
$storeId = Mage::app()->getStore()->getId();
|
51 |
-
|
52 |
Â
$options = array();
|
53 |
Â
foreach ($paymentMethods as $code => $model) {
|
54 |
Â
$title = Mage::getStoreConfig('payment/' . $code . '/title', $storeId);
|
55 |
Â
if (empty($title)) {
|
56 |
-
|
57 |
Â
}
|
58 |
-
|
59 |
Â
$options[$code] = array(
|
60 |
Â
'label' => $title,
|
61 |
Â
'value' => $code,
|
62 |
Â
);
|
63 |
Â
}
|
64 |
-
|
65 |
Â
return $options;
|
66 |
Â
}
|
67 |
Â
}
|
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 |
Â
* Gets an array of active payment methods
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
47 |
Â
{
|
48 |
Â
$paymentMethods = Mage::getSingleton('payment/config')->getActiveMethods();
|
49 |
+
|
50 |
Â
$storeId = Mage::app()->getStore()->getId();
|
51 |
+
|
52 |
Â
$options = array();
|
53 |
Â
foreach ($paymentMethods as $code => $model) {
|
54 |
Â
$title = Mage::getStoreConfig('payment/' . $code . '/title', $storeId);
|
55 |
Â
if (empty($title)) {
|
56 |
+
$title = $code;
|
57 |
Â
}
|
58 |
+
|
59 |
Â
$options[$code] = array(
|
60 |
Â
'label' => $title,
|
61 |
Â
'value' => $code,
|
62 |
Â
);
|
63 |
Â
}
|
64 |
+
|
65 |
Â
return $options;
|
66 |
Â
}
|
67 |
Â
}
|
@@ -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,34 +42,34 @@ class TIG_PostNL_Model_Checkout_System_Config_Source_CmsPage
|
|
42 |
Â
* @var array
|
43 |
Â
*/
|
44 |
Â
protected $_options;
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* Get the stored options array
|
48 |
-
*
|
49 |
Â
* @return array
|
50 |
Â
*/
|
51 |
Â
public function getOptions()
|
52 |
Â
{
|
53 |
Â
return $this->_options;
|
54 |
Â
}
|
55 |
-
|
56 |
Â
/**
|
57 |
Â
* Store the options array
|
58 |
-
*
|
59 |
Â
* @param array $options
|
60 |
-
*
|
61 |
Â
* @return TIG_PostNL_Model_Checkout_System_Config_Source_CmsPage
|
62 |
Â
*/
|
63 |
Â
public function setOptions($options)
|
64 |
Â
{
|
65 |
Â
$this->_options = $options;
|
66 |
-
|
67 |
Â
return $this;
|
68 |
Â
}
|
69 |
-
|
70 |
Â
/**
|
71 |
Â
* Checks if an option array has been stored
|
72 |
-
*
|
73 |
Â
* @return boolean
|
74 |
Â
*/
|
75 |
Â
public function hasOptions()
|
@@ -78,32 +78,35 @@ class TIG_PostNL_Model_Checkout_System_Config_Source_CmsPage
|
|
78 |
Â
if (empty($options)) {
|
79 |
Â
return false;
|
80 |
Â
}
|
81 |
-
|
82 |
Â
return true;
|
83 |
Â
}
|
84 |
-
|
85 |
Â
/**
|
86 |
Â
* Get an option array of all CMS pages available
|
87 |
-
*
|
88 |
Â
* @return array
|
89 |
Â
*/
|
90 |
Â
public function toOptionArray()
|
91 |
Â
{
|
92 |
Â
if ($this->hasOptions()) {
|
93 |
Â
return $this->getOptions();
|
94 |
-
|
95 |
Â
}
|
96 |
-
|
97 |
Â
$options = array(
|
98 |
Â
'' => Mage::helper('postnl')->__('-- none --'),
|
99 |
Â
);
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
Â
|
|
Â
|
|
Â
|
|
104 |
Â
$options = array_merge($options, $pageOptions);
|
105 |
Â
$this->setOptions($options);
|
106 |
-
|
107 |
Â
return $options;
|
108 |
Â
}
|
109 |
Â
}
|
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 |
Â
* @var array
|
43 |
Â
*/
|
44 |
Â
protected $_options;
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Get the stored options array
|
48 |
+
*
|
49 |
Â
* @return array
|
50 |
Â
*/
|
51 |
Â
public function getOptions()
|
52 |
Â
{
|
53 |
Â
return $this->_options;
|
54 |
Â
}
|
55 |
+
|
56 |
Â
/**
|
57 |
Â
* Store the options array
|
58 |
+
*
|
59 |
Â
* @param array $options
|
60 |
+
*
|
61 |
Â
* @return TIG_PostNL_Model_Checkout_System_Config_Source_CmsPage
|
62 |
Â
*/
|
63 |
Â
public function setOptions($options)
|
64 |
Â
{
|
65 |
Â
$this->_options = $options;
|
66 |
+
|
67 |
Â
return $this;
|
68 |
Â
}
|
69 |
+
|
70 |
Â
/**
|
71 |
Â
* Checks if an option array has been stored
|
72 |
+
*
|
73 |
Â
* @return boolean
|
74 |
Â
*/
|
75 |
Â
public function hasOptions()
|
78 |
Â
if (empty($options)) {
|
79 |
Â
return false;
|
80 |
Â
}
|
81 |
+
|
82 |
Â
return true;
|
83 |
Â
}
|
84 |
+
|
85 |
Â
/**
|
86 |
Â
* Get an option array of all CMS pages available
|
87 |
+
*
|
88 |
Â
* @return array
|
89 |
Â
*/
|
90 |
Â
public function toOptionArray()
|
91 |
Â
{
|
92 |
Â
if ($this->hasOptions()) {
|
93 |
Â
return $this->getOptions();
|
94 |
+
|
95 |
Â
}
|
96 |
+
|
97 |
Â
$options = array(
|
98 |
Â
'' => Mage::helper('postnl')->__('-- none --'),
|
99 |
Â
);
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @var Mage_Cms_Model_Resource_Page_Collection $pageCollection
|
103 |
+
*/
|
104 |
+
$pageCollection = Mage::getResourceModel('cms/page_collection')->load();
|
105 |
+
$pageOptions = $pageCollection->toOptionIdArray();
|
106 |
+
|
107 |
Â
$options = array_merge($options, $pageOptions);
|
108 |
Â
$this->setOptions($options);
|
109 |
+
|
110 |
Â
return $options;
|
111 |
Â
}
|
112 |
Â
}
|
@@ -33,14 +33,27 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
-
|
39 |
-
|
40 |
-
/**
|
41 |
Â
* Class containing all default methods used for CIF communication by this extension.
|
42 |
Â
*
|
43 |
-
* If you wish to add new methods you can etxend this class or create a new class that extends
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
44 |
Â
*/
|
45 |
Â
class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
46 |
Â
{
|
@@ -56,11 +69,6 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
56 |
Â
/**
|
57 |
Â
* Constants containing XML paths to cif address configuration options
|
58 |
Â
*/
|
59 |
-
const XML_PATH_SPLIT_STREET = 'postnl/cif_address/split_street';
|
60 |
-
const XML_PATH_STREETNAME_FIELD = 'postnl/cif_address/streetname_field';
|
61 |
-
const XML_PATH_HOUSENUMBER_FIELD = 'postnl/cif_address/housenr_field';
|
62 |
-
const XML_PATH_SPLIT_HOUSENUMBER = 'postnl/cif_address/split_housenr';
|
63 |
-
const XML_PATH_HOUSENUMBER_EXTENSION_FIELD = 'postnl/cif_address/housenr_extension_field';
|
64 |
Â
const XML_PATH_AREA_FIELD = 'postnl/cif_address/area_field';
|
65 |
Â
const XML_PATH_BUILDING_NAME_FIELD = 'postnl/cif_address/building_name_field';
|
66 |
Â
const XML_PATH_DEPARTMENT_FIELD = 'postnl/cif_address/department_field';
|
@@ -120,18 +128,6 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
120 |
Â
*/
|
121 |
Â
const XML_PATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
|
122 |
Â
|
123 |
-
/**
|
124 |
-
* Regular expression used to split streetname from housenumber. This regex works well for dutch
|
125 |
-
* addresses, but may fail for international addresses. We strongly recommend using split address
|
126 |
-
* lines instead.
|
127 |
-
*/
|
128 |
-
const SPLIT_STREET_REGEX = '#\A(.*?)\s+(\d+[a-zA-Z]{0,1}\s{0,1}[-]{1}\s{0,1}\d*[a-zA-Z]{0,1}|\d+[a-zA-Z-]{0,1}\d*[a-zA-Z]{0,1})#';
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Regular expression used to split housenumber and housenumber extension
|
132 |
-
*/
|
133 |
-
const SPLIT_HOUSENUMBER_REGEX = '#^([\d]+)(.*)#s';
|
134 |
-
|
135 |
Â
/**
|
136 |
Â
* array containing possible address types
|
137 |
Â
*
|
@@ -209,17 +205,6 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
209 |
Â
'Zebra|GK420d',
|
210 |
Â
);
|
211 |
Â
|
212 |
-
/**
|
213 |
-
* Array of countires which may send their full street data in a single line,
|
214 |
-
* rather than having to split them into streetname, housenr and extension parts
|
215 |
-
*
|
216 |
-
* @var array
|
217 |
-
*/
|
218 |
-
protected $_allowedFullStreetCountries = array(
|
219 |
-
'NL',
|
220 |
-
'BE'
|
221 |
-
);
|
222 |
-
|
223 |
Â
/**
|
224 |
Â
* These shipment types require an invoice in the customs declaration. Other possible shipment types are:
|
225 |
Â
* - Gift
|
@@ -233,6 +218,22 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
233 |
Â
'Returned Goods',
|
234 |
Â
);
|
235 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
236 |
Â
/**
|
237 |
Â
* Get possible address types
|
238 |
Â
*
|
@@ -254,23 +255,23 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
254 |
Â
}
|
255 |
Â
|
256 |
Â
/**
|
257 |
-
* Get
|
258 |
Â
*
|
259 |
Â
* @return array
|
260 |
Â
*/
|
261 |
-
public function
|
262 |
Â
{
|
263 |
-
return $this->
|
264 |
Â
}
|
265 |
Â
|
266 |
Â
/**
|
267 |
-
* Get
|
268 |
Â
*
|
269 |
Â
* @return array
|
270 |
Â
*/
|
271 |
-
public function
|
272 |
Â
{
|
273 |
-
return $this->
|
274 |
Â
}
|
275 |
Â
|
276 |
Â
/**
|
@@ -280,12 +281,12 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
280 |
Â
*/
|
281 |
Â
public function getStoreId()
|
282 |
Â
{
|
283 |
-
if ($this->
|
284 |
Â
return $this->getData('store_id');
|
285 |
Â
}
|
286 |
Â
|
287 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
288 |
-
$this->
|
289 |
Â
|
290 |
Â
return $storeId;
|
291 |
Â
}
|
@@ -341,9 +342,9 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
341 |
Â
}
|
342 |
Â
|
343 |
Â
/**
|
344 |
-
* Requests a new barcode from CIF as a ping request. This can be used to validate account settings or to check if
|
345 |
-
* service is up and running. This is not meant to be used to generate an actual barcode for a shipment.
|
346 |
-
* generateBarcode method for that.
|
347 |
Â
*
|
348 |
Â
* The generateBarcode CIF call was chosena s it is the simplest CIF function available.
|
349 |
Â
*
|
@@ -357,6 +358,9 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
357 |
Â
{
|
358 |
Â
$this->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID);
|
359 |
Â
|
Â
|
|
Â
|
|
Â
|
|
360 |
Â
$barcode = $this->_getBarcodeData('NL');
|
361 |
Â
|
362 |
Â
$message = $this->_getMessage('');
|
@@ -383,9 +387,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
383 |
Â
$response = $this->call(
|
384 |
Â
'Barcode',
|
385 |
Â
'GenerateBarcode',
|
386 |
-
$soapParams
|
387 |
-
$data['username'],
|
388 |
-
$data['password']
|
389 |
Â
);
|
390 |
Â
|
391 |
Â
if (!is_object($response)
|
@@ -403,16 +405,15 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
403 |
Â
/**
|
404 |
Â
* Retrieves the latest shipping status of a shipment from CIF
|
405 |
Â
*
|
406 |
-
* @param
|
Â
|
|
Â
|
|
407 |
Â
*
|
408 |
Â
* @return StdClass
|
409 |
Â
*
|
410 |
-
* @throws TIG_PostNL_Exception
|
411 |
Â
*/
|
412 |
-
public function getShipmentStatus($postnlShipment)
|
413 |
Â
{
|
414 |
-
$shipment = $postnlShipment->getShipment();
|
415 |
-
|
416 |
Â
$barcode = $postnlShipment->getMainBarcode();
|
417 |
Â
$message = $this->_getMessage($barcode);
|
418 |
Â
$customer = $this->_getCustomer();
|
@@ -449,7 +450,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
449 |
Â
$shipment = $shipment[0];
|
450 |
Â
}
|
451 |
Â
|
452 |
-
|
Â
|
|
Â
|
|
Â
|
|
453 |
Â
return $shipment;
|
454 |
Â
}
|
455 |
Â
}
|
@@ -458,7 +462,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
458 |
Â
* no shipment could be matched to the supplied barcode
|
459 |
Â
*/
|
460 |
Â
throw new TIG_PostNL_Exception(
|
461 |
-
Mage::helper('postnl')->__(
|
Â
|
|
Â
|
|
Â
|
|
462 |
Â
'POSTNL-0063'
|
463 |
Â
);
|
464 |
Â
}
|
@@ -466,16 +473,15 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
466 |
Â
/**
|
467 |
Â
* Retrieves the latest shipping status of a shipment from CIF including full status history
|
468 |
Â
*
|
469 |
-
* @param
|
Â
|
|
Â
|
|
470 |
Â
*
|
471 |
Â
* @return StdClass
|
472 |
Â
*
|
473 |
-
* @throws TIG_PostNL_Exception
|
474 |
Â
*/
|
475 |
-
public function getCompleteShipmentStatus($postnlShipment)
|
476 |
Â
{
|
477 |
-
$shipment = $postnlShipment->getShipment();
|
478 |
-
|
479 |
Â
$barcode = $postnlShipment->getMainBarcode();
|
480 |
Â
$message = $this->_getMessage($barcode);
|
481 |
Â
$customer = $this->_getCustomer();
|
@@ -488,12 +494,6 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
488 |
Â
),
|
489 |
Â
);
|
490 |
Â
|
491 |
-
$response = $this->call(
|
492 |
-
'ShippingStatus',
|
493 |
-
'CurrentStatus',
|
494 |
-
$soapParams
|
495 |
-
);
|
496 |
-
|
497 |
Â
$response = $this->call(
|
498 |
Â
'ShippingStatus',
|
499 |
Â
'CompleteStatus',
|
@@ -512,7 +512,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
512 |
Â
|
513 |
Â
foreach($response->Shipments as $shipment) {
|
514 |
Â
$shipment = $shipment[0];
|
515 |
-
|
Â
|
|
Â
|
|
Â
|
|
516 |
Â
return $shipment;
|
517 |
Â
}
|
518 |
Â
}
|
@@ -521,7 +524,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
521 |
Â
* no shipment could be matched to the supplied barcode
|
522 |
Â
*/
|
523 |
Â
throw new TIG_PostNL_Exception(
|
524 |
-
Mage::helper('postnl')->__(
|
Â
|
|
Â
|
|
Â
|
|
525 |
Â
'POSTNL-0063'
|
526 |
Â
);
|
527 |
Â
}
|
@@ -529,14 +535,17 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
529 |
Â
/**
|
530 |
Â
* Confirms the choen shipment without generating labels
|
531 |
Â
*
|
532 |
-
* @param
|
533 |
-
* @param string
|
534 |
-
*
|
535 |
-
* @
|
536 |
Â
*
|
537 |
Â
* @throws TIG_PostNL_Exception
|
Â
|
|
Â
|
|
538 |
Â
*/
|
539 |
-
public function confirmShipment($postnlShipment, $barcode, $mainBarcode = false,
|
Â
|
|
540 |
Â
{
|
541 |
Â
$shipment = $postnlShipment->getShipment();
|
542 |
Â
|
@@ -592,15 +601,24 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
592 |
Â
/**
|
593 |
Â
* Generates shipping labels for the chosen shipment
|
594 |
Â
*
|
595 |
-
* @param
|
Â
|
|
Â
|
|
Â
|
|
596 |
Â
* @param string $printerType The printertype used. Currently only 'GraphicFile|PDF' is fully supported
|
597 |
Â
*
|
Â
|
|
Â
|
|
598 |
Â
* @return array
|
599 |
Â
*
|
600 |
-
* @throws TIG_PostNL_Exception
|
601 |
Â
*/
|
602 |
-
public function generateLabels(
|
603 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
604 |
Â
$shipment = $postnlShipment->getShipment();
|
605 |
Â
|
606 |
Â
$availablePrinterTypes = $this->_printerTypes;
|
@@ -651,15 +669,26 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
651 |
Â
/**
|
652 |
Â
* Generates shipping labels for the chosen shipment without confirming it
|
653 |
Â
*
|
654 |
-
* @param
|
655 |
-
* @param
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
656 |
Â
*
|
657 |
-
* @return array
|
658 |
Â
*
|
659 |
Â
* @throws TIG_PostNL_Exception
|
Â
|
|
Â
|
|
Â
|
|
660 |
Â
*/
|
661 |
-
public function generateLabelsWithoutConfirm(
|
662 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
663 |
Â
$shipment = $postnlShipment->getShipment();
|
664 |
Â
|
665 |
Â
$availablePrinterTypes = $this->_printerTypes;
|
@@ -699,7 +728,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
699 |
Â
|| !is_object($response->Labels)
|
700 |
Â
) {
|
701 |
Â
throw new TIG_PostNL_Exception(
|
702 |
-
Mage::helper('postnl')->__(
|
Â
|
|
Â
|
|
Â
|
|
703 |
Â
'POSTNL-0058'
|
704 |
Â
);
|
705 |
Â
}
|
@@ -710,13 +742,17 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
710 |
Â
/**
|
711 |
Â
* Gets the Message parameter
|
712 |
Â
*
|
Â
|
|
713 |
Â
* @param array $extra An array of additional parameters to add
|
714 |
Â
*
|
715 |
Â
* @return array
|
716 |
Â
*/
|
717 |
Â
protected function _getMessage($barcode, $extra = array())
|
718 |
Â
{
|
719 |
-
$messageIdString = uniqid(
|
Â
|
|
Â
|
|
Â
|
|
720 |
Â
. $this->_getCustomerNumber()
|
721 |
Â
. $barcode
|
722 |
Â
. microtime();
|
@@ -736,7 +772,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
736 |
Â
/**
|
737 |
Â
* Gets the customer parameter
|
738 |
Â
*
|
739 |
-
* @param Mage_Sales_Model_Order_Shipment
|
740 |
Â
*
|
741 |
Â
* @return array
|
742 |
Â
*/
|
@@ -762,16 +798,15 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
762 |
Â
/**
|
763 |
Â
* Creates the CIF shipment object based on a PostNL shipment
|
764 |
Â
*
|
765 |
-
* @param
|
766 |
-
* @param
|
767 |
-
* @param bool
|
768 |
-
* @param bool
|
769 |
Â
*
|
770 |
Â
* @return array
|
771 |
-
*
|
772 |
-
* @todo modify to support OVM and PostNL checkout shipments
|
773 |
Â
*/
|
774 |
-
protected function _getShipment($postnlShipment,
|
Â
|
|
775 |
Â
{
|
776 |
Â
$shipment = $postnlShipment->getShipment();
|
777 |
Â
$order = $shipment->getOrder();
|
@@ -785,8 +820,11 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
785 |
Â
* needs to be calculated
|
786 |
Â
*/
|
787 |
Â
if ($shipmentNumber !== false) {
|
Â
|
|
Â
|
|
Â
|
|
788 |
Â
$parcelWeight = Mage::getStoreConfig(self::XML_PATH_WEIGHT_PER_PARCEL, $postnlShipment->getStoreId());
|
789 |
-
$parcelWeight = Mage::helper('postnl/cif')->standardizeWeight($parcelWeight, $shipment->getStoreId(), true);
|
790 |
Â
|
791 |
Â
/**
|
792 |
Â
* All parcels except for the last one weigh a configured amount. The last parcel weighs the remainder
|
@@ -805,6 +843,15 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
805 |
Â
$shipmentWeight = 1;
|
806 |
Â
}
|
807 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
808 |
Â
$shipmentData = array(
|
809 |
Â
'Barcode' => $barcode,
|
810 |
Â
'CollectionTimeStampEnd' => '',
|
@@ -812,14 +859,14 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
812 |
Â
'DownPartnerBarcode' => '',
|
813 |
Â
'DownPartnerID' => '',
|
814 |
Â
'ProductCodeDelivery' => $postnlShipment->getProductCode(),
|
815 |
-
'Reference' => $shipment->getReference(),
|
816 |
Â
'Contacts' => array(
|
817 |
-
'Contact' => $this->_getContact($shippingAddress, $order),
|
818 |
Â
),
|
819 |
Â
'Dimension' => array(
|
820 |
Â
'Weight' => round($shipmentWeight),
|
821 |
Â
),
|
822 |
Â
'Reference' => $this->_getReference($shipment),
|
Â
|
|
823 |
Â
);
|
824 |
Â
|
825 |
Â
/**
|
@@ -840,23 +887,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
840 |
Â
/**
|
841 |
Â
* Add address data
|
842 |
Â
*/
|
843 |
-
$
|
844 |
-
$pakjeGemakAddress = $postnlShipment->getPakjeGemakAddress();
|
845 |
-
|
846 |
-
$addresses = array(
|
847 |
-
'Address' => array(
|
848 |
-
$this->_getAddress('Receiver', $shippingAddress)
|
849 |
-
),
|
850 |
-
);
|
851 |
-
|
852 |
-
if (!$useSenderAddressAsReturn) {
|
853 |
-
$addresses['Address'][] = $this->_getAddress('Alternative');
|
854 |
-
}
|
855 |
-
|
856 |
-
if ($pakjeGemakAddress) {
|
857 |
-
$addresses['Address'][] =$this->_getAddress('Delivery', $pakjeGemakAddress);
|
858 |
-
}
|
859 |
-
|
860 |
Â
$shipmentData['Addresses'] = $addresses;
|
861 |
Â
|
862 |
Â
/**
|
@@ -876,15 +907,78 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
876 |
Â
$shipmentData['Customs'] = $this->_getCustoms($postnlShipment);
|
877 |
Â
}
|
878 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
879 |
Â
return $shipmentData;
|
880 |
Â
}
|
881 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
882 |
Â
/**
|
883 |
Â
* Gets an array containing required address data
|
884 |
Â
*
|
885 |
-
* @param
|
886 |
-
* @param
|
887 |
Â
*
|
Â
|
|
888 |
Â
* @return array
|
889 |
Â
*/
|
890 |
Â
protected function _getAddress($addressType, $shippingAddress= false)
|
@@ -924,7 +1018,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
924 |
Â
/**
|
925 |
Â
* Check if the return address is the same as the sender address. If so, no address is returned
|
926 |
Â
*/
|
927 |
-
$useSenderAddress = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
Â
|
|
928 |
Â
if ($useSenderAddress) {
|
929 |
Â
return false;
|
930 |
Â
}
|
@@ -960,9 +1057,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
960 |
Â
|
961 |
Â
/**
|
962 |
Â
* Forms an array of address data compatible with CIF
|
963 |
-
|
964 |
-
* @param Mage_Sales_Model_Order_Address $address
|
965 |
-
* @param array
|
Â
|
|
966 |
Â
*
|
967 |
Â
* @return array
|
968 |
Â
*/
|
@@ -1007,6 +1105,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1007 |
Â
*/
|
1008 |
Â
protected function _getBarcodeData($barcodeType)
|
1009 |
Â
{
|
Â
|
|
Â
|
|
1010 |
Â
switch ($barcodeType) {
|
1011 |
Â
case 'NL':
|
1012 |
Â
$type = '3S';
|
@@ -1057,13 +1157,11 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1057 |
Â
/**
|
1058 |
Â
* Generates the CIF amount object containing the shipment's insured amount (if any)
|
1059 |
Â
*
|
1060 |
-
* @param
|
1061 |
Â
*
|
1062 |
Â
* @return array
|
1063 |
-
*
|
1064 |
-
* @todo implement COD
|
1065 |
Â
*/
|
1066 |
-
protected function _getAmount($postnlShipment)
|
1067 |
Â
{
|
1068 |
Â
$amount = array();
|
1069 |
Â
if (!$postnlShipment->hasExtraCover() && !$postnlShipment->isCod()) {
|
@@ -1074,7 +1172,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1074 |
Â
$extraCover = number_format($postnlShipment->getExtraCoverAmount(), 2, '.', '');
|
1075 |
Â
$amount[] = array(
|
1076 |
Â
'AccountName' => '',
|
1077 |
-
'
|
Â
|
|
1078 |
Â
'AmountType' => '02', // 01 = COD, 02 = Insured
|
1079 |
Â
'Currency' => 'EUR',
|
1080 |
Â
'Reference' => '',
|
@@ -1084,7 +1183,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1084 |
Â
}
|
1085 |
Â
|
1086 |
Â
if ($postnlShipment->isCod()) {
|
1087 |
-
|
1088 |
Â
}
|
1089 |
Â
|
1090 |
Â
return $amount;
|
@@ -1094,27 +1193,51 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1094 |
Â
* Creates the CIF contact object
|
1095 |
Â
*
|
1096 |
Â
* @param Mage_Sales_Model_Order_Address $address
|
Â
|
|
1097 |
Â
* @param Mage_Sales_Model_Order $order
|
1098 |
Â
*
|
1099 |
Â
* @return array
|
1100 |
-
*
|
1101 |
-
* @todo check if SMSNr is required for pakjegemak
|
1102 |
Â
*/
|
1103 |
-
protected function _getContact($address,
|
Â
|
|
1104 |
Â
{
|
Â
|
|
Â
|
|
1105 |
Â
$contact = array(
|
1106 |
Â
'ContactType' => '01', // Receiver
|
1107 |
Â
'Email' => $order->getCustomerEmail(),
|
1108 |
-
'SMSNr' =>
|
1109 |
Â
'TelNr' => $address->getTelephone(),
|
1110 |
Â
);
|
1111 |
Â
|
1112 |
Â
return $contact;
|
1113 |
Â
}
|
1114 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1115 |
Â
/**
|
1116 |
Â
* Creates the CIF group object
|
1117 |
Â
*
|
Â
|
|
Â
|
|
Â
|
|
1118 |
Â
* @return array
|
1119 |
Â
*/
|
1120 |
Â
protected function _getGroup($groupCount = 1, $mainBarcode = false, $shipmentNumber = false)
|
@@ -1140,196 +1263,31 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1140 |
Â
}
|
1141 |
Â
|
1142 |
Â
/**
|
1143 |
-
* Retrieves streetname, housenumber and housenumber extension from the shipping address.
|
1144 |
-
*
|
1145 |
-
*
|
1146 |
-
* field
|
1147 |
-
* to be split using PREG.
|
1148 |
Â
*
|
1149 |
-
* PREG cannot be relied on as it is impossible to create a regex that can filter all
|
1150 |
-
*
|
1151 |
-
*
|
1152 |
-
*
|
1153 |
-
*
|
1154 |
-
* @param Mage_Sales_Model_Order_Address $address
|
1155 |
-
*
|
1156 |
-
* @return array
|
1157 |
-
*/
|
1158 |
-
protected function _getStreetData($address)
|
1159 |
-
{
|
1160 |
-
$storeId = $this->getStoreId();
|
1161 |
-
$splitStreet = Mage::getStoreConfigFlag(self::XML_PATH_SPLIT_STREET, $storeId);
|
1162 |
-
|
1163 |
-
/**
|
1164 |
-
* Website uses multi-line address mode
|
1165 |
-
*/
|
1166 |
-
if ($splitStreet) {
|
1167 |
-
$streetData = $this->_getMultiLineStreetData($address);
|
1168 |
-
|
1169 |
-
/**
|
1170 |
-
* If $streetData is false it means a required field was missing. In this
|
1171 |
-
* case the alternative methods are used to obtain the address data.
|
1172 |
-
*/
|
1173 |
-
if ($streetData !== false) {
|
1174 |
-
return $streetData;
|
1175 |
-
}
|
1176 |
-
}
|
1177 |
-
|
1178 |
-
/**
|
1179 |
-
* Website uses single-line address mode
|
1180 |
-
*/
|
1181 |
-
$allowedFullStreetCountries = $this->getAllowedFullStreetCountries();
|
1182 |
-
$fullStreet = $address->getStreetFull();
|
1183 |
-
|
1184 |
-
/**
|
1185 |
-
* Select countries don't have to split their street values into seperate part
|
1186 |
-
*/
|
1187 |
-
if (in_array($address->getCountry(), $allowedFullStreetCountries)) {
|
1188 |
-
$streetData = array(
|
1189 |
-
'streetname' => '',
|
1190 |
-
'housenumber' => '',
|
1191 |
-
'housenumberExtension' => '',
|
1192 |
-
'fullStreet' => $fullStreet,
|
1193 |
-
);
|
1194 |
-
return $streetData;
|
1195 |
-
}
|
1196 |
-
|
1197 |
-
/**
|
1198 |
-
* All other countries must split them using PREG
|
1199 |
-
*/
|
1200 |
-
$streetData = $this->_getSplitStreetData($fullStreet);
|
1201 |
-
|
1202 |
-
return $streetData;
|
1203 |
-
}
|
1204 |
-
|
1205 |
-
/**
|
1206 |
-
* Retrieves streetname, housenumber and housenumber extension from the shipping address in the multiple streetlines configuration.
|
1207 |
Â
*
|
1208 |
Â
* @param Mage_Sales_Model_Order_Address $address
|
Â
|
|
1209 |
Â
*
|
1210 |
Â
* @return array
|
1211 |
Â
*/
|
1212 |
-
protected function
|
1213 |
Â
{
|
Â
|
|
1214 |
Â
$storeId = $this->getStoreId();
|
1215 |
-
$streetnameField = (int) Mage::getStoreConfig(self::XML_PATH_STREETNAME_FIELD, $storeId);
|
1216 |
-
$housenumberField = (int) Mage::getStoreConfig(self::XML_PATH_HOUSENUMBER_FIELD, $storeId);
|
1217 |
-
|
1218 |
-
$streetname = $address->getStreet($streetnameField);
|
1219 |
-
$housenumber = $address->getStreet($housenumberField);
|
1220 |
-
|
1221 |
-
/**
|
1222 |
-
* If street or housenr fields are empty, use alternative options to obtain the address data
|
1223 |
-
*/
|
1224 |
-
if (is_null($streetname) || is_null($housenumber)) {
|
1225 |
-
return false;
|
1226 |
-
}
|
1227 |
-
|
1228 |
-
/**
|
1229 |
-
* Split the housenumber into a number and an extension
|
1230 |
-
*/
|
1231 |
-
$splitHouseNumber = Mage::getStoreConfigFlag(self::XML_PATH_SPLIT_HOUSENUMBER, $storeId);
|
1232 |
-
if ($splitHouseNumber) {
|
1233 |
-
$housenumberExtensionField = (int) Mage::getStoreConfig(self::XML_PATH_HOUSENUMBER_EXTENSION_FIELD, $storeId);
|
1234 |
-
$housenumberExtension = $address->getStreet($housenumberExtensionField);
|
1235 |
-
} else {
|
1236 |
-
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1237 |
-
$housenumber = $housenumberParts['number'];
|
1238 |
-
$housenumberExtension = $housenumberParts['extension'];
|
1239 |
-
}
|
1240 |
-
|
1241 |
-
$streetData = array(
|
1242 |
-
'streetname' => $streetname,
|
1243 |
-
'housenumber' => $housenumber,
|
1244 |
-
'housenumberExtension' => $housenumberExtension,
|
1245 |
-
'fullStreet' => '',
|
1246 |
-
);
|
1247 |
-
|
1248 |
-
return $streetData;
|
1249 |
-
}
|
1250 |
Â
|
1251 |
-
|
1252 |
-
* Splits street data into seperate parts for streetname, housenumber and extension.
|
1253 |
-
*
|
1254 |
-
* @param string $fullStreet The full streetname including all parts
|
1255 |
-
*
|
1256 |
-
* @return array
|
1257 |
-
*
|
1258 |
-
* @throws TIG_PostNL_Exception
|
1259 |
-
*/
|
1260 |
-
protected function _getSplitStreetData($fullStreet)
|
1261 |
-
{
|
1262 |
-
$result = preg_match(self::SPLIT_STREET_REGEX, $fullStreet, $matches);
|
1263 |
-
if (!$result || !is_array($matches)) {
|
1264 |
-
throw new TIG_PostNL_Exception(
|
1265 |
-
Mage::helper('postnl')->__('Invalid full street supplied: %s', $fullStreet),
|
1266 |
-
'POSTNL-0060'
|
1267 |
-
);
|
1268 |
-
}
|
1269 |
-
|
1270 |
-
$streetname = '';
|
1271 |
-
$housenumber = '';
|
1272 |
-
if (isset($matches[1])) {
|
1273 |
-
$streetname = $matches[1];
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
if (isset($matches[2])) {
|
1277 |
-
$housenumber = $matches[2];
|
1278 |
-
}
|
1279 |
-
|
1280 |
-
$housenumberParts = $this->_splitHousenumber($housenumber);
|
1281 |
-
$housenumber = $housenumberParts['number'];
|
1282 |
-
$housenumberExtension = $housenumberParts['extension'];
|
1283 |
-
|
1284 |
-
$streetData = array(
|
1285 |
-
'streetname' => $streetname,
|
1286 |
-
'housenumber' => $housenumber,
|
1287 |
-
'housenumberExtension' => $housenumberExtension,
|
1288 |
-
'fullStreet' => '',
|
1289 |
-
);
|
1290 |
Â
|
1291 |
Â
return $streetData;
|
1292 |
Â
}
|
1293 |
Â
|
1294 |
-
/**
|
1295 |
-
* Splits a supplier housenumber into a number and an extension
|
1296 |
-
*
|
1297 |
-
* @param string $housenumber
|
1298 |
-
*
|
1299 |
-
* @return array
|
1300 |
-
*
|
1301 |
-
* @throws TIG_PostNL_Exception
|
1302 |
-
*/
|
1303 |
-
protected function _splitHousenumber($housenumber)
|
1304 |
-
{
|
1305 |
-
$housenumber = trim($housenumber);
|
1306 |
-
|
1307 |
-
$result = preg_match(self::SPLIT_HOUSENUMBER_REGEX, $housenumber, $matches);
|
1308 |
-
if (!$result || !is_array($matches)) {
|
1309 |
-
throw new TIG_PostNL_Exception(
|
1310 |
-
Mage::helper('postnl')->__('Invalid housnumber supplied: %s', $housenumber),
|
1311 |
-
'POSTNL-0059'
|
1312 |
-
);
|
1313 |
-
}
|
1314 |
-
|
1315 |
-
$extension = '';
|
1316 |
-
$number = '';
|
1317 |
-
if (isset($matches[1])) {
|
1318 |
-
$number = $matches[1];
|
1319 |
-
}
|
1320 |
-
|
1321 |
-
if (isset($matches[2])) {
|
1322 |
-
$extension = trim($matches[2]);
|
1323 |
-
}
|
1324 |
-
|
1325 |
-
$housenumberParts = array(
|
1326 |
-
'number' => $number,
|
1327 |
-
'extension' => $extension,
|
1328 |
-
);
|
1329 |
-
|
1330 |
-
return $housenumberParts;
|
1331 |
-
}
|
1332 |
-
|
1333 |
Â
/**
|
1334 |
Â
* create Customs CIF object
|
1335 |
Â
*
|
@@ -1340,10 +1298,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1340 |
Â
protected function _getCustoms($postnlShipment)
|
1341 |
Â
{
|
1342 |
Â
$shipment = $postnlShipment->getShipment();
|
1343 |
-
$shipmentType = $postnlShipment->
|
1344 |
Â
|
1345 |
Â
$customs = array(
|
1346 |
-
'ShipmentType' => $shipmentType,
|
1347 |
Â
'HandleAsNonDeliverable' => 'false',
|
1348 |
Â
'Invoice' => 'false',
|
1349 |
Â
'Certificate' => 'false',
|
@@ -1352,7 +1310,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1352 |
Â
);
|
1353 |
Â
|
1354 |
Â
/**
|
1355 |
-
* Check if the shipment should be treated as abandoned when it can't be delivered or if it should be returned
|
Â
|
|
1356 |
Â
*/
|
1357 |
Â
if ($postnlShipment->getTreatAsAbandoned()) {
|
1358 |
Â
$customs['HandleAsNonDeliverable'] = 'true';
|
@@ -1397,6 +1356,9 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1397 |
Â
$content = array();
|
1398 |
Â
$items = $this->_sortCustomsItems($shipment->getAllItems());
|
1399 |
Â
|
Â
|
|
Â
|
|
Â
|
|
1400 |
Â
foreach ($items as $item) {
|
1401 |
Â
/**
|
1402 |
Â
* A maximum of 5 rows are allowed
|
@@ -1465,13 +1427,20 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1465 |
Â
/**
|
1466 |
Â
* Get the attribute and direction used for sorting
|
1467 |
Â
*/
|
1468 |
-
$sortingAttribute = Mage::getStoreConfig(
|
1469 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1470 |
Â
|
1471 |
Â
/**
|
1472 |
Â
* Place the item's sorting value in a temporary array where the key is the item's ID
|
Â
|
|
Â
|
|
1473 |
Â
*/
|
1474 |
-
$sortingValue = array();
|
1475 |
Â
foreach ($items as $item) {
|
1476 |
Â
$product = $item->getOrderItem()->getProduct();
|
1477 |
Â
$sortingAttributeValue = $product->getDataUsingMethod($sortingAttribute);
|
@@ -1501,11 +1470,11 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1501 |
Â
/**
|
1502 |
Â
* Get a shipment item's HS tariff
|
1503 |
Â
*
|
1504 |
-
* @param
|
1505 |
Â
*
|
1506 |
Â
* @return string
|
1507 |
Â
*/
|
1508 |
-
protected function _getHSTariff($shipmentItem)
|
1509 |
Â
{
|
1510 |
Â
$storeId = $this->getStoreId();
|
1511 |
Â
|
@@ -1516,7 +1485,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1516 |
Â
return '000000';
|
1517 |
Â
}
|
1518 |
Â
|
1519 |
-
if ($this->
|
1520 |
Â
$hsTariffAttribute = $this->getHSTariffAttribute();
|
1521 |
Â
} else {
|
1522 |
Â
$hsTariffAttribute = Mage::getStoreConfig(self::XML_PATH_GLOBALPACK_HS_TARIFF_ATTRIBUTE, $storeId);
|
@@ -1537,17 +1506,22 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1537 |
Â
/**
|
1538 |
Â
* Get a shipment item's country of origin
|
1539 |
Â
*
|
1540 |
-
* @param
|
Â
|
|
Â
|
|
1541 |
Â
*
|
1542 |
Â
* @return string
|
1543 |
Â
*/
|
1544 |
Â
protected function _getCountryOfOrigin($shipmentItem)
|
1545 |
Â
{
|
1546 |
Â
$storeId = $this->getStoreId();
|
1547 |
-
if ($this->
|
1548 |
Â
$countryOfOriginAttribute = $this->getCountryOfOriginAttribute();
|
1549 |
Â
} else {
|
1550 |
-
$countryOfOriginAttribute = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
Â
|
|
1551 |
Â
$this->setCountryOfOriginAttribute($countryOfOriginAttribute);
|
1552 |
Â
}
|
1553 |
Â
|
@@ -1557,7 +1531,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1557 |
Â
|
1558 |
Â
if (empty($countryOfOrigin)) {
|
1559 |
Â
throw new TIG_PostNL_Exception(
|
1560 |
-
Mage::helper('postnl')->__(
|
Â
|
|
Â
|
|
Â
|
|
1561 |
Â
'POSTNL-0091'
|
1562 |
Â
);
|
1563 |
Â
}
|
@@ -1568,14 +1545,16 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1568 |
Â
/**
|
1569 |
Â
* Get a shipment item's customs value
|
1570 |
Â
*
|
1571 |
-
* @param
|
Â
|
|
Â
|
|
1572 |
Â
*
|
1573 |
Â
* @return string
|
1574 |
Â
*/
|
1575 |
Â
protected function _getCustomsValue($shipmentItem)
|
1576 |
Â
{
|
1577 |
Â
$storeId = $this->getStoreId();
|
1578 |
-
if ($this->
|
1579 |
Â
$customsValueAttribute = $this->getCustomsValueAttribute();
|
1580 |
Â
} else {
|
1581 |
Â
$customsValueAttribute = Mage::getStoreConfig(self::XML_PATH_GLOBALPACK_CUSTOMS_VALUE_ATTRIBUTE, $storeId);
|
@@ -1599,14 +1578,16 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1599 |
Â
/**
|
1600 |
Â
* Get a shipment item's customs description
|
1601 |
Â
*
|
1602 |
-
* @param
|
Â
|
|
Â
|
|
1603 |
Â
*
|
1604 |
Â
* @return string
|
1605 |
Â
*/
|
1606 |
Â
protected function _getCustomsDescription($shipmentItem)
|
1607 |
Â
{
|
1608 |
Â
$storeId = $this->getStoreId();
|
1609 |
-
if ($this->
|
1610 |
Â
$descriptionAttribute = $this->getCustomsDescriptionAttribute();
|
1611 |
Â
} else {
|
1612 |
Â
$descriptionAttribute = Mage::getStoreConfig(self::XML_PATH_GLOBALPACK_DESCRIPTION_ATTRIBUTE, $storeId);
|
@@ -1619,7 +1600,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1619 |
Â
|
1620 |
Â
if (empty($description)) {
|
1621 |
Â
throw new TIG_PostNL_Exception(
|
1622 |
-
Mage::helper('postnl')->__(
|
Â
|
|
Â
|
|
Â
|
|
1623 |
Â
'POSTNL-0093'
|
1624 |
Â
);
|
1625 |
Â
}
|
@@ -1717,7 +1701,10 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1717 |
Â
protected function _getCustomsCertificate()
|
1718 |
Â
{
|
1719 |
Â
$storeId = $this->getStoreId();
|
1720 |
-
$customsCertificate = (string) Mage::getStoreConfig(
|
Â
|
|
Â
|
|
Â
|
|
1721 |
Â
|
1722 |
Â
if (empty($customsCertificate)) {
|
1723 |
Â
return false;
|
@@ -1729,6 +1716,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1729 |
Â
/**
|
1730 |
Â
* Get the area field from an address if enabled
|
1731 |
Â
*
|
Â
|
|
Â
|
|
1732 |
Â
* @return string
|
1733 |
Â
*/
|
1734 |
Â
protected function _getArea($address)
|
@@ -1744,6 +1733,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1744 |
Â
/**
|
1745 |
Â
* Attempt to get the area through the magic getter instead
|
1746 |
Â
*/
|
Â
|
|
1747 |
Â
$area = $address->getArea();
|
1748 |
Â
|
1749 |
Â
return $area;
|
@@ -1752,6 +1742,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1752 |
Â
/**
|
1753 |
Â
* Get the area building name from an address if enabled
|
1754 |
Â
*
|
Â
|
|
Â
|
|
1755 |
Â
* @return string
|
1756 |
Â
*/
|
1757 |
Â
protected function _getBuildingName($address)
|
@@ -1767,6 +1759,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1767 |
Â
/**
|
1768 |
Â
* Attempt to get the building name through the magic getter instead
|
1769 |
Â
*/
|
Â
|
|
1770 |
Â
$buildingName = $address->getBuildingName();
|
1771 |
Â
|
1772 |
Â
return $buildingName;
|
@@ -1775,6 +1768,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1775 |
Â
/**
|
1776 |
Â
* Get the department field from an address if enabled
|
1777 |
Â
*
|
Â
|
|
Â
|
|
1778 |
Â
* @return string
|
1779 |
Â
*/
|
1780 |
Â
protected function _getDepartment($address)
|
@@ -1790,6 +1785,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1790 |
Â
/**
|
1791 |
Â
* Attempt to get department through the magic getter instead
|
1792 |
Â
*/
|
Â
|
|
1793 |
Â
$department = $address->getDepartment();
|
1794 |
Â
|
1795 |
Â
return $department;
|
@@ -1798,6 +1794,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1798 |
Â
/**
|
1799 |
Â
* Get the doorcode field from an address if enabled
|
1800 |
Â
*
|
Â
|
|
Â
|
|
1801 |
Â
* @return string
|
1802 |
Â
*/
|
1803 |
Â
protected function _getDoorcode($address)
|
@@ -1813,6 +1811,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1813 |
Â
/**
|
1814 |
Â
* Attempt to get the doorcode through the magic getter instead
|
1815 |
Â
*/
|
Â
|
|
1816 |
Â
$doorcode = $address->getDoorcode();
|
1817 |
Â
|
1818 |
Â
return $doorcode;
|
@@ -1821,6 +1820,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1821 |
Â
/**
|
1822 |
Â
* Get the floor field from an address if enabled
|
1823 |
Â
*
|
Â
|
|
Â
|
|
1824 |
Â
* @return string
|
1825 |
Â
*/
|
1826 |
Â
protected function _getFloor($address)
|
@@ -1836,6 +1837,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1836 |
Â
/**
|
1837 |
Â
* Attempt to get the floor through the magic getter instead
|
1838 |
Â
*/
|
Â
|
|
1839 |
Â
$floor = $address->getFloor();
|
1840 |
Â
|
1841 |
Â
return $floor;
|
@@ -1844,6 +1846,8 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1844 |
Â
/**
|
1845 |
Â
* Get the remark field from an address if enabled
|
1846 |
Â
*
|
Â
|
|
Â
|
|
1847 |
Â
* @return string
|
1848 |
Â
*/
|
1849 |
Â
protected function _getRemark($address)
|
@@ -1859,6 +1863,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1859 |
Â
/**
|
1860 |
Â
* Attempt to get the remark through the magic getter instead
|
1861 |
Â
*/
|
Â
|
|
1862 |
Â
$remark = $address->getRemark();
|
1863 |
Â
|
1864 |
Â
return $remark;
|
@@ -1867,7 +1872,7 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1867 |
Â
/**
|
1868 |
Â
* Get a shipment's reference. By default this will be the shipment's increment ID
|
1869 |
Â
*
|
1870 |
-
* @param Mage_Sales_Model_Order_Shipment
|
1871 |
Â
*
|
1872 |
Â
* @return string
|
1873 |
Â
*
|
@@ -1906,10 +1911,11 @@ class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
|
1906 |
Â
* For custom references we need to replace several optional variables
|
1907 |
Â
*/
|
1908 |
Â
if ($referenceType == 'custom') {
|
Â
|
|
Â
|
|
1909 |
Â
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
1910 |
Â
$reference = str_replace('{{var order_increment_id}}', $shipment->getOrder()->getIncrementId(), $reference);
|
1911 |
Â
|
1912 |
-
$store = Mage::getModel('core/store')->load($storeId);
|
1913 |
Â
$reference = str_replace('{{var store_frontend_name}}', $store->getFrontendName(), $reference);
|
1914 |
Â
}
|
1915 |
Â
|
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 |
Â
* Class containing all default methods used for CIF communication by this extension.
|
40 |
Â
*
|
41 |
+
* If you wish to add new methods you can etxend this class or create a new class that extends
|
42 |
+
* TIG_PostNL_Model_Core_Cif_Abstract.
|
43 |
+
*
|
44 |
+
* @method TIG_PostNL_Model_Core_Cif setStoreId(int $value)
|
45 |
+
* @method boolean hasHSTariffAttribute()
|
46 |
+
* @method string getHSTariffAttribute()
|
47 |
+
* @method TIG_PostNL_Model_Core_Cif setHSTariffAttribute(string $value)
|
48 |
+
* @method boolean hasCountryOfOriginAttribute()
|
49 |
+
* @method string getCountryOfOriginAttribute()
|
50 |
+
* @method TIG_PostNL_Model_Core_Cif setCountryOfOriginAttribute(string $value)
|
51 |
+
* @method boolean hasCustomsValueAttribute()
|
52 |
+
* @method string getCustomsValueAttribute()
|
53 |
+
* @method TIG_PostNL_Model_Core_Cif setCustomsValueAttribute(string $value)
|
54 |
+
* @method boolean hasCustomsDescriptionAttribute()
|
55 |
+
* @method string getCustomsDescriptionAttribute()
|
56 |
+
* @method TIG_PostNL_Model_Core_Cif setCustomsDescriptionAttribute(string $value)
|
57 |
Â
*/
|
58 |
Â
class TIG_PostNL_Model_Core_Cif extends TIG_PostNL_Model_Core_Cif_Abstract
|
59 |
Â
{
|
69 |
Â
/**
|
70 |
Â
* Constants containing XML paths to cif address configuration options
|
71 |
Â
*/
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
72 |
Â
const XML_PATH_AREA_FIELD = 'postnl/cif_address/area_field';
|
73 |
Â
const XML_PATH_BUILDING_NAME_FIELD = 'postnl/cif_address/building_name_field';
|
74 |
Â
const XML_PATH_DEPARTMENT_FIELD = 'postnl/cif_address/department_field';
|
128 |
Â
*/
|
129 |
Â
const XML_PATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
|
130 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
131 |
Â
/**
|
132 |
Â
* array containing possible address types
|
133 |
Â
*
|
205 |
Â
'Zebra|GK420d',
|
206 |
Â
);
|
207 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
208 |
Â
/**
|
209 |
Â
* These shipment types require an invoice in the customs declaration. Other possible shipment types are:
|
210 |
Â
* - Gift
|
218 |
Â
'Returned Goods',
|
219 |
Â
);
|
220 |
Â
|
221 |
+
/**
|
222 |
+
* These shipment types need specific product options.
|
223 |
+
*
|
224 |
+
* @var array
|
225 |
+
*/
|
226 |
+
protected $_availableProductOptions = array(
|
227 |
+
'PGE' => array(
|
228 |
+
'Characteristic' => '118',
|
229 |
+
'Option' => '002',
|
230 |
+
),
|
231 |
+
'Avond' => array(
|
232 |
+
'Characteristic' => '118',
|
233 |
+
'Option' => '006',
|
234 |
+
),
|
235 |
+
);
|
236 |
+
|
237 |
Â
/**
|
238 |
Â
* Get possible address types
|
239 |
Â
*
|
255 |
Â
}
|
256 |
Â
|
257 |
Â
/**
|
258 |
+
* Get shipment types that require an invoice number
|
259 |
Â
*
|
260 |
Â
* @return array
|
261 |
Â
*/
|
262 |
+
public function getInvoiceRequiredShipmentTypes()
|
263 |
Â
{
|
264 |
+
return $this->_invoiceRequiredShipmentTypes;
|
265 |
Â
}
|
266 |
Â
|
267 |
Â
/**
|
268 |
+
* Get an array of available product options per type.
|
269 |
Â
*
|
270 |
Â
* @return array
|
271 |
Â
*/
|
272 |
+
public function getAvailableProductOptions()
|
273 |
Â
{
|
274 |
+
return $this->_availableProductOptions;
|
275 |
Â
}
|
276 |
Â
|
277 |
Â
/**
|
281 |
Â
*/
|
282 |
Â
public function getStoreId()
|
283 |
Â
{
|
284 |
+
if ($this->hasData('store_id')) {
|
285 |
Â
return $this->getData('store_id');
|
286 |
Â
}
|
287 |
Â
|
288 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
289 |
+
$this->setData('store_id', $storeId);
|
290 |
Â
|
291 |
Â
return $storeId;
|
292 |
Â
}
|
342 |
Â
}
|
343 |
Â
|
344 |
Â
/**
|
345 |
+
* Requests a new barcode from CIF as a ping request. This can be used to validate account settings or to check if
|
346 |
+
* the CIF service is up and running. This is not meant to be used to generate an actual barcode for a shipment.
|
347 |
+
* Use the generateBarcode method for that.
|
348 |
Â
*
|
349 |
Â
* The generateBarcode CIF call was chosena s it is the simplest CIF function available.
|
350 |
Â
*
|
358 |
Â
{
|
359 |
Â
$this->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID);
|
360 |
Â
|
361 |
+
$this->setPassword($data['password']);
|
362 |
+
$this->setUsername($data['username']);
|
363 |
+
|
364 |
Â
$barcode = $this->_getBarcodeData('NL');
|
365 |
Â
|
366 |
Â
$message = $this->_getMessage('');
|
387 |
Â
$response = $this->call(
|
388 |
Â
'Barcode',
|
389 |
Â
'GenerateBarcode',
|
390 |
+
$soapParams
|
Â
|
|
Â
|
|
391 |
Â
);
|
392 |
Â
|
393 |
Â
if (!is_object($response)
|
405 |
Â
/**
|
406 |
Â
* Retrieves the latest shipping status of a shipment from CIF
|
407 |
Â
*
|
408 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
409 |
+
*
|
410 |
+
* @throws TIG_PostNL_Exception
|
411 |
Â
*
|
412 |
Â
* @return StdClass
|
413 |
Â
*
|
Â
|
|
414 |
Â
*/
|
415 |
+
public function getShipmentStatus(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
416 |
Â
{
|
Â
|
|
Â
|
|
417 |
Â
$barcode = $postnlShipment->getMainBarcode();
|
418 |
Â
$message = $this->_getMessage($barcode);
|
419 |
Â
$customer = $this->_getCustomer();
|
450 |
Â
$shipment = $shipment[0];
|
451 |
Â
}
|
452 |
Â
|
453 |
+
/**
|
454 |
+
* We need the original shipment, not a related shipment (such as a return shipment).
|
455 |
+
*/
|
456 |
+
if ($shipment->Barcode === $barcode) {
|
457 |
Â
return $shipment;
|
458 |
Â
}
|
459 |
Â
}
|
462 |
Â
* no shipment could be matched to the supplied barcode
|
463 |
Â
*/
|
464 |
Â
throw new TIG_PostNL_Exception(
|
465 |
+
Mage::helper('postnl')->__(
|
466 |
+
'Unable to match barcode to shippingStatus response: %s',
|
467 |
+
var_export($response, true)
|
468 |
+
),
|
469 |
Â
'POSTNL-0063'
|
470 |
Â
);
|
471 |
Â
}
|
473 |
Â
/**
|
474 |
Â
* Retrieves the latest shipping status of a shipment from CIF including full status history
|
475 |
Â
*
|
476 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
477 |
+
*
|
478 |
+
* @throws TIG_PostNL_Exception
|
479 |
Â
*
|
480 |
Â
* @return StdClass
|
481 |
Â
*
|
Â
|
|
482 |
Â
*/
|
483 |
+
public function getCompleteShipmentStatus(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
484 |
Â
{
|
Â
|
|
Â
|
|
485 |
Â
$barcode = $postnlShipment->getMainBarcode();
|
486 |
Â
$message = $this->_getMessage($barcode);
|
487 |
Â
$customer = $this->_getCustomer();
|
494 |
Â
),
|
495 |
Â
);
|
496 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
497 |
Â
$response = $this->call(
|
498 |
Â
'ShippingStatus',
|
499 |
Â
'CompleteStatus',
|
512 |
Â
|
513 |
Â
foreach($response->Shipments as $shipment) {
|
514 |
Â
$shipment = $shipment[0];
|
515 |
+
/**
|
516 |
+
* we need the original shipment, not a related shipment (such as a return shipment).
|
517 |
+
*/
|
518 |
+
if ($shipment->Barcode === $barcode) {
|
519 |
Â
return $shipment;
|
520 |
Â
}
|
521 |
Â
}
|
524 |
Â
* no shipment could be matched to the supplied barcode
|
525 |
Â
*/
|
526 |
Â
throw new TIG_PostNL_Exception(
|
527 |
+
Mage::helper('postnl')->__(
|
528 |
+
'Unable to match barcode to shippingStatus response: %s',
|
529 |
+
var_export($response, true)
|
530 |
+
),
|
531 |
Â
'POSTNL-0063'
|
532 |
Â
);
|
533 |
Â
}
|
535 |
Â
/**
|
536 |
Â
* Confirms the choen shipment without generating labels
|
537 |
Â
*
|
538 |
+
* @param TIG_PostNL_Model_Core_Shipment $postnlShipment
|
539 |
+
* @param string $barcode
|
540 |
+
* @param bool $mainBarcode
|
541 |
+
* @param bool $shipmentNumber
|
542 |
Â
*
|
543 |
Â
* @throws TIG_PostNL_Exception
|
544 |
+
*
|
545 |
+
* @return array
|
546 |
Â
*/
|
547 |
+
public function confirmShipment(TIG_PostNL_Model_Core_Shipment $postnlShipment, $barcode, $mainBarcode = false,
|
548 |
+
$shipmentNumber = false)
|
549 |
Â
{
|
550 |
Â
$shipment = $postnlShipment->getShipment();
|
551 |
Â
|
601 |
Â
/**
|
602 |
Â
* Generates shipping labels for the chosen shipment
|
603 |
Â
*
|
604 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
605 |
+
* @param $barcode
|
606 |
+
* @param bool $mainBarcode
|
607 |
+
* @param bool $shipmentNumber
|
608 |
Â
* @param string $printerType The printertype used. Currently only 'GraphicFile|PDF' is fully supported
|
609 |
Â
*
|
610 |
+
* @throws TIG_PostNL_Exception
|
611 |
+
*
|
612 |
Â
* @return array
|
613 |
Â
*
|
Â
|
|
614 |
Â
*/
|
615 |
+
public function generateLabels(
|
616 |
+
TIG_PostnL_Model_Core_Shipment $postnlShipment,
|
617 |
+
$barcode,
|
618 |
+
$mainBarcode = false,
|
619 |
+
$shipmentNumber = false,
|
620 |
+
$printerType = 'GraphicFile|PDF'
|
621 |
+
) {
|
622 |
Â
$shipment = $postnlShipment->getShipment();
|
623 |
Â
|
624 |
Â
$availablePrinterTypes = $this->_printerTypes;
|
669 |
Â
/**
|
670 |
Â
* Generates shipping labels for the chosen shipment without confirming it
|
671 |
Â
*
|
672 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
673 |
+
* @param string $barcode
|
674 |
+
* @param boolean|string $mainBarcode
|
675 |
+
* @param bool|int $shipmentNumber
|
676 |
+
* @param string $printerType The printertype used. Currently only
|
677 |
+
* 'GraphicFile|PDF' is fully supported.
|
678 |
Â
*
|
Â
|
|
679 |
Â
*
|
680 |
Â
* @throws TIG_PostNL_Exception
|
681 |
+
*
|
682 |
+
* @return array
|
683 |
+
*
|
684 |
Â
*/
|
685 |
+
public function generateLabelsWithoutConfirm(
|
686 |
+
TIG_PostnL_Model_Core_Shipment $postnlShipment,
|
687 |
+
$barcode,
|
688 |
+
$mainBarcode = false,
|
689 |
+
$shipmentNumber = false,
|
690 |
+
$printerType = 'GraphicFile|PDF'
|
691 |
+
) {
|
692 |
Â
$shipment = $postnlShipment->getShipment();
|
693 |
Â
|
694 |
Â
$availablePrinterTypes = $this->_printerTypes;
|
728 |
Â
|| !is_object($response->Labels)
|
729 |
Â
) {
|
730 |
Â
throw new TIG_PostNL_Exception(
|
731 |
+
Mage::helper('postnl')->__(
|
732 |
+
'Invalid generateLabelsWithoutConfirm response: %s',
|
733 |
+
var_export($response, true)
|
734 |
+
),
|
735 |
Â
'POSTNL-0058'
|
736 |
Â
);
|
737 |
Â
}
|
742 |
Â
/**
|
743 |
Â
* Gets the Message parameter
|
744 |
Â
*
|
745 |
+
* @param $barcode
|
746 |
Â
* @param array $extra An array of additional parameters to add
|
747 |
Â
*
|
748 |
Â
* @return array
|
749 |
Â
*/
|
750 |
Â
protected function _getMessage($barcode, $extra = array())
|
751 |
Â
{
|
752 |
+
$messageIdString = uniqid(
|
753 |
+
'postnl_'
|
754 |
+
. ip2long(Mage::helper('core/http')->getServerAddr())
|
755 |
+
)
|
756 |
Â
. $this->_getCustomerNumber()
|
757 |
Â
. $barcode
|
758 |
Â
. microtime();
|
772 |
Â
/**
|
773 |
Â
* Gets the customer parameter
|
774 |
Â
*
|
775 |
+
* @param Mage_Sales_Model_Order_Shipment|boolean $shipment
|
776 |
Â
*
|
777 |
Â
* @return array
|
778 |
Â
*/
|
798 |
Â
/**
|
799 |
Â
* Creates the CIF shipment object based on a PostNL shipment
|
800 |
Â
*
|
801 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
802 |
+
* @param $barcode
|
803 |
+
* @param bool $mainBarcode
|
804 |
+
* @param bool $shipmentNumber
|
805 |
Â
*
|
806 |
Â
* @return array
|
Â
|
|
Â
|
|
807 |
Â
*/
|
808 |
+
protected function _getShipment(TIG_PostnL_Model_Core_Shipment $postnlShipment,
|
809 |
+
$barcode, $mainBarcode = false, $shipmentNumber = false)
|
810 |
Â
{
|
811 |
Â
$shipment = $postnlShipment->getShipment();
|
812 |
Â
$order = $shipment->getOrder();
|
820 |
Â
* needs to be calculated
|
821 |
Â
*/
|
822 |
Â
if ($shipmentNumber !== false) {
|
823 |
+
/**
|
824 |
+
* Get the parcel weight and then convert it to grams.
|
825 |
+
*/
|
826 |
Â
$parcelWeight = Mage::getStoreConfig(self::XML_PATH_WEIGHT_PER_PARCEL, $postnlShipment->getStoreId());
|
827 |
+
$parcelWeight = Mage::helper('postnl/cif')->standardizeWeight($parcelWeight, $shipment->getStoreId(), true);
|
828 |
Â
|
829 |
Â
/**
|
830 |
Â
* All parcels except for the last one weigh a configured amount. The last parcel weighs the remainder
|
843 |
Â
$shipmentWeight = 1;
|
844 |
Â
}
|
845 |
Â
|
846 |
+
/**
|
847 |
+
* Get and format this shipment's delivery date if available.
|
848 |
+
*/
|
849 |
+
$deliveryDate = $postnlShipment->getDeliveryDate();
|
850 |
+
if ($deliveryDate) {
|
851 |
+
$deliveryTime = strtotime($deliveryDate);
|
852 |
+
$deliveryDate = date('d-m-Y H:i:s', $deliveryTime);
|
853 |
+
}
|
854 |
+
|
855 |
Â
$shipmentData = array(
|
856 |
Â
'Barcode' => $barcode,
|
857 |
Â
'CollectionTimeStampEnd' => '',
|
859 |
Â
'DownPartnerBarcode' => '',
|
860 |
Â
'DownPartnerID' => '',
|
861 |
Â
'ProductCodeDelivery' => $postnlShipment->getProductCode(),
|
Â
|
|
862 |
Â
'Contacts' => array(
|
863 |
+
'Contact' => $this->_getContact($shippingAddress, $postnlShipment, $order),
|
864 |
Â
),
|
865 |
Â
'Dimension' => array(
|
866 |
Â
'Weight' => round($shipmentWeight),
|
867 |
Â
),
|
868 |
Â
'Reference' => $this->_getReference($shipment),
|
869 |
+
'DeliveryDate' => $deliveryDate,
|
870 |
Â
);
|
871 |
Â
|
872 |
Â
/**
|
887 |
Â
/**
|
888 |
Â
* Add address data
|
889 |
Â
*/
|
890 |
+
$addresses = $this->_getShipmentAddresses($postnlShipment, $shippingAddress);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
891 |
Â
$shipmentData['Addresses'] = $addresses;
|
892 |
Â
|
893 |
Â
/**
|
907 |
Â
$shipmentData['Customs'] = $this->_getCustoms($postnlShipment);
|
908 |
Â
}
|
909 |
Â
|
910 |
+
$productOptions = $this->_getProductOptions($postnlShipment);
|
911 |
+
if ($productOptions) {
|
912 |
+
$shipmentData['ProductOptions'] = $productOptions;
|
913 |
+
}
|
914 |
+
|
915 |
Â
return $shipmentData;
|
916 |
Â
}
|
917 |
Â
|
918 |
+
/**
|
919 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
920 |
+
* @param Mage_Sales_Model_order_Address $shippingAddress
|
921 |
+
*
|
922 |
+
* @return array
|
923 |
+
*/
|
924 |
+
protected function _getShipmentAddresses(TIG_PostnL_Model_Core_Shipment $postnlShipment, $shippingAddress)
|
925 |
+
{
|
926 |
+
$useSenderAddressAsReturn = Mage::getStoreConfig(
|
927 |
+
self::XML_PATH_USE_SENDER_ADDRESS_AS_RETURN,
|
928 |
+
$this->getStoreId()
|
929 |
+
);
|
930 |
+
$pakjeGemakAddress = $postnlShipment->getPakjeGemakAddress();
|
931 |
+
|
932 |
+
$addresses = array(
|
933 |
+
'Address' => array(
|
934 |
+
$this->_getAddress('Receiver', $shippingAddress)
|
935 |
+
),
|
936 |
+
);
|
937 |
+
|
938 |
+
if (!$useSenderAddressAsReturn) {
|
939 |
+
$addresses['Address'][] = $this->_getAddress('Alternative');
|
940 |
+
}
|
941 |
+
|
942 |
+
if ($pakjeGemakAddress) {
|
943 |
+
$addresses['Address'][] =$this->_getAddress('Delivery', $pakjeGemakAddress);
|
944 |
+
}
|
945 |
+
|
946 |
+
return $addresses;
|
947 |
+
}
|
948 |
+
|
949 |
+
/**
|
950 |
+
* Gets product options based on a specified shipment.
|
951 |
+
*
|
952 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
953 |
+
*
|
954 |
+
* @return array|bool
|
955 |
+
*/
|
956 |
+
protected function _getProductOptions(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
957 |
+
{
|
958 |
+
$postnlOrder = $postnlShipment->getPostnlOrder();
|
959 |
+
if (!$postnlOrder) {
|
960 |
+
return false;
|
961 |
+
}
|
962 |
+
|
963 |
+
$type = $postnlOrder->getType();
|
964 |
+
$availableProductOptions = $this->getAvailableProductOptions();
|
965 |
+
if (!array_key_exists($type, $availableProductOptions)) {
|
966 |
+
return false;
|
967 |
+
}
|
968 |
+
|
969 |
+
$productOptions = array(
|
970 |
+
'ProductOption' => $availableProductOptions[$type]
|
971 |
+
);
|
972 |
+
return $productOptions;
|
973 |
+
}
|
974 |
+
|
975 |
Â
/**
|
976 |
Â
* Gets an array containing required address data
|
977 |
Â
*
|
978 |
+
* @param $addressType
|
979 |
+
* @param bool|string $shippingAddress
|
980 |
Â
*
|
981 |
+
* @throws TIG_PostNL_Exception
|
982 |
Â
* @return array
|
983 |
Â
*/
|
984 |
Â
protected function _getAddress($addressType, $shippingAddress= false)
|
1018 |
Â
/**
|
1019 |
Â
* Check if the return address is the same as the sender address. If so, no address is returned
|
1020 |
Â
*/
|
1021 |
+
$useSenderAddress = Mage::getStoreConfig(
|
1022 |
+
self::XML_PATH_USE_SENDER_ADDRESS_AS_RETURN,
|
1023 |
+
$this->getStoreId()
|
1024 |
+
);
|
1025 |
Â
if ($useSenderAddress) {
|
1026 |
Â
return false;
|
1027 |
Â
}
|
1057 |
Â
|
1058 |
Â
/**
|
1059 |
Â
* Forms an array of address data compatible with CIF
|
1060 |
+
|
1061 |
+
* @param Mage_Sales_Model_Order_Address|Varien_Object $address
|
1062 |
+
* @param array|boolean $streetData Optional parameter containing streetname,
|
1063 |
+
* housenr, housenr extension and fullStreet values.
|
1064 |
Â
*
|
1065 |
Â
* @return array
|
1066 |
Â
*/
|
1105 |
Â
*/
|
1106 |
Â
protected function _getBarcodeData($barcodeType)
|
1107 |
Â
{
|
1108 |
+
$barcodeType = strtoupper($barcodeType);
|
1109 |
+
|
1110 |
Â
switch ($barcodeType) {
|
1111 |
Â
case 'NL':
|
1112 |
Â
$type = '3S';
|
1157 |
Â
/**
|
1158 |
Â
* Generates the CIF amount object containing the shipment's insured amount (if any)
|
1159 |
Â
*
|
1160 |
+
* @param TIG_PostnL_Model_Core_Shipment $postnlShipment
|
1161 |
Â
*
|
1162 |
Â
* @return array
|
Â
|
|
Â
|
|
1163 |
Â
*/
|
1164 |
+
protected function _getAmount(TIG_PostnL_Model_Core_Shipment $postnlShipment)
|
1165 |
Â
{
|
1166 |
Â
$amount = array();
|
1167 |
Â
if (!$postnlShipment->hasExtraCover() && !$postnlShipment->isCod()) {
|
1172 |
Â
$extraCover = number_format($postnlShipment->getExtraCoverAmount(), 2, '.', '');
|
1173 |
Â
$amount[] = array(
|
1174 |
Â
'AccountName' => '',
|
1175 |
+
'BIC' => '',
|
1176 |
+
'IBAN' => '',
|
1177 |
Â
'AmountType' => '02', // 01 = COD, 02 = Insured
|
1178 |
Â
'Currency' => 'EUR',
|
1179 |
Â
'Reference' => '',
|
1183 |
Â
}
|
1184 |
Â
|
1185 |
Â
if ($postnlShipment->isCod()) {
|
1186 |
+
/** @todo implement COD here */
|
1187 |
Â
}
|
1188 |
Â
|
1189 |
Â
return $amount;
|
1193 |
Â
* Creates the CIF contact object
|
1194 |
Â
*
|
1195 |
Â
* @param Mage_Sales_Model_Order_Address $address
|
1196 |
+
* @param TIG_PostNL_Model_Core_Shipment $postnlShipment
|
1197 |
Â
* @param Mage_Sales_Model_Order $order
|
1198 |
Â
*
|
1199 |
Â
* @return array
|
Â
|
|
Â
|
|
1200 |
Â
*/
|
1201 |
+
protected function _getContact($address, TIG_PostNL_Model_Core_Shipment $postnlShipment,
|
1202 |
+
Mage_Sales_Model_Order $order)
|
1203 |
Â
{
|
1204 |
+
$smsNr = $this->_getMobilePhoneNumber($postnlShipment);
|
1205 |
+
|
1206 |
Â
$contact = array(
|
1207 |
Â
'ContactType' => '01', // Receiver
|
1208 |
Â
'Email' => $order->getCustomerEmail(),
|
1209 |
+
'SMSNr' => $smsNr,
|
1210 |
Â
'TelNr' => $address->getTelephone(),
|
1211 |
Â
);
|
1212 |
Â
|
1213 |
Â
return $contact;
|
1214 |
Â
}
|
1215 |
Â
|
1216 |
+
/**
|
1217 |
+
* Gets a mobile phone number for the current shipment.
|
1218 |
+
*
|
1219 |
+
* @param TIG_PostNL_Model_Core_Shipment $postnlShipment
|
1220 |
+
*
|
1221 |
+
* @return string
|
1222 |
+
*/
|
1223 |
+
protected function _getMobilePhoneNumber(TIG_PostNL_Model_Core_Shipment $postnlShipment)
|
1224 |
+
{
|
1225 |
+
$mobilePhoneNumber = '';
|
1226 |
+
|
1227 |
+
$postnlOrder = $postnlShipment->getPostnlOrder();
|
1228 |
+
if ($postnlOrder && $postnlOrder->getMobilePhoneNumber()) {
|
1229 |
+
$mobilePhoneNumber = $postnlOrder->getMobilePhoneNumber();
|
1230 |
+
}
|
1231 |
+
|
1232 |
+
return $mobilePhoneNumber;
|
1233 |
+
}
|
1234 |
+
|
1235 |
Â
/**
|
1236 |
Â
* Creates the CIF group object
|
1237 |
Â
*
|
1238 |
+
* @param int $groupCount
|
1239 |
+
* @param bool $mainBarcode
|
1240 |
+
* @param bool $shipmentNumber
|
1241 |
Â
* @return array
|
1242 |
Â
*/
|
1243 |
Â
protected function _getGroup($groupCount = 1, $mainBarcode = false, $shipmentNumber = false)
|
1263 |
Â
}
|
1264 |
Â
|
1265 |
Â
/**
|
1266 |
+
* Retrieves streetname, housenumber and housenumber extension from the shipping address. The shipping address may
|
1267 |
+
* be in multiple streetlines configuration or single line configuration. In the case of multi-line, each part of
|
1268 |
+
* the street data will be in a seperate field. In the single line configuration, each part will be in the same
|
1269 |
+
* field and will have to be split using PREG.
|
Â
|
|
1270 |
Â
*
|
1271 |
+
* PREG cannot be relied on as it is impossible to create a regex that can filter all possible street syntaxes.
|
1272 |
+
* Therefore we strongly recommend to use multiple street lines. This can be enabled in Magento community in
|
1273 |
+
* system > config > customer configuration. Or if you use Enterprise, in customers > attributes > manage customer
|
1274 |
+
* address attributes.
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1275 |
Â
*
|
1276 |
Â
* @param Mage_Sales_Model_Order_Address $address
|
1277 |
+
* @param boolean $allowFullStreet
|
1278 |
Â
*
|
1279 |
Â
* @return array
|
1280 |
Â
*/
|
1281 |
+
protected function _getStreetData($address, $allowFullStreet = true)
|
1282 |
Â
{
|
1283 |
+
$helper = Mage::helper('postnl/cif');
|
1284 |
Â
$storeId = $this->getStoreId();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1285 |
Â
|
1286 |
+
$streetData = $helper->getStreetData($storeId, $address, $allowFullStreet);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1287 |
Â
|
1288 |
Â
return $streetData;
|
1289 |
Â
}
|
1290 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1291 |
Â
/**
|
1292 |
Â
* create Customs CIF object
|
1293 |
Â
*
|
1298 |
Â
protected function _getCustoms($postnlShipment)
|
1299 |
Â
{
|
1300 |
Â
$shipment = $postnlShipment->getShipment();
|
1301 |
+
$shipmentType = $postnlShipment->getGlobalpackShipmentType();
|
1302 |
Â
|
1303 |
Â
$customs = array(
|
1304 |
+
'ShipmentType' => $shipmentType,
|
1305 |
Â
'HandleAsNonDeliverable' => 'false',
|
1306 |
Â
'Invoice' => 'false',
|
1307 |
Â
'Certificate' => 'false',
|
1310 |
Â
);
|
1311 |
Â
|
1312 |
Â
/**
|
1313 |
+
* Check if the shipment should be treated as abandoned when it can't be delivered or if it should be returned
|
1314 |
+
* to the sender.
|
1315 |
Â
*/
|
1316 |
Â
if ($postnlShipment->getTreatAsAbandoned()) {
|
1317 |
Â
$customs['HandleAsNonDeliverable'] = 'true';
|
1356 |
Â
$content = array();
|
1357 |
Â
$items = $this->_sortCustomsItems($shipment->getAllItems());
|
1358 |
Â
|
1359 |
+
/**
|
1360 |
+
* @var Mage_Sales_Model_Order_Shipment_Item $item
|
1361 |
+
*/
|
1362 |
Â
foreach ($items as $item) {
|
1363 |
Â
/**
|
1364 |
Â
* A maximum of 5 rows are allowed
|
1427 |
Â
/**
|
1428 |
Â
* Get the attribute and direction used for sorting
|
1429 |
Â
*/
|
1430 |
+
$sortingAttribute = Mage::getStoreConfig(
|
1431 |
+
self::XML_PATH_GLOBALPACK_PRODUCT_SORTING_ATTRIBUTE,
|
1432 |
+
$this->getStoreId()
|
1433 |
+
);
|
1434 |
+
$sortingDirection = Mage::getStoreConfig(
|
1435 |
+
self::XML_PATH_GLOBALPACK_PRODUCT_SORTING_DIRECTION,
|
1436 |
+
$this->getStoreId()
|
1437 |
+
);
|
1438 |
Â
|
1439 |
Â
/**
|
1440 |
Â
* Place the item's sorting value in a temporary array where the key is the item's ID
|
1441 |
+
*
|
1442 |
+
* @var Mage_Sales_Model_Order_Shipment_Item $item
|
1443 |
Â
*/
|
Â
|
|
1444 |
Â
foreach ($items as $item) {
|
1445 |
Â
$product = $item->getOrderItem()->getProduct();
|
1446 |
Â
$sortingAttributeValue = $product->getDataUsingMethod($sortingAttribute);
|
1470 |
Â
/**
|
1471 |
Â
* Get a shipment item's HS tariff
|
1472 |
Â
*
|
1473 |
+
* @param Mage_Sales_Model_Order_Shipment_Item $shipmentItem
|
1474 |
Â
*
|
1475 |
Â
* @return string
|
1476 |
Â
*/
|
1477 |
+
protected function _getHSTariff(Mage_Sales_Model_Order_Shipment_Item $shipmentItem)
|
1478 |
Â
{
|
1479 |
Â
$storeId = $this->getStoreId();
|
1480 |
Â
|
1485 |
Â
return '000000';
|
1486 |
Â
}
|
1487 |
Â
|
1488 |
+
if ($this->hasHSTariffAttribute()) {
|
1489 |
Â
$hsTariffAttribute = $this->getHSTariffAttribute();
|
1490 |
Â
} else {
|
1491 |
Â
$hsTariffAttribute = Mage::getStoreConfig(self::XML_PATH_GLOBALPACK_HS_TARIFF_ATTRIBUTE, $storeId);
|
1506 |
Â
/**
|
1507 |
Â
* Get a shipment item's country of origin
|
1508 |
Â
*
|
1509 |
+
* @param Mage_Sales_Model_Order_Shipment_Item $shipmentItem
|
1510 |
+
*
|
1511 |
+
* @throws TIG_PostNL_Exception
|
1512 |
Â
*
|
1513 |
Â
* @return string
|
1514 |
Â
*/
|
1515 |
Â
protected function _getCountryOfOrigin($shipmentItem)
|
1516 |
Â
{
|
1517 |
Â
$storeId = $this->getStoreId();
|
1518 |
+
if ($this->hasCountryOfOriginAttribute()) {
|
1519 |
Â
$countryOfOriginAttribute = $this->getCountryOfOriginAttribute();
|
1520 |
Â
} else {
|
1521 |
+
$countryOfOriginAttribute = Mage::getStoreConfig(
|
1522 |
+
self::XML_PATH_GLOBALPACK_COUNTRY_OF_ORIGIN_ATTRIBUTE,
|
1523 |
+
$storeId
|
1524 |
+
);
|
1525 |
Â
$this->setCountryOfOriginAttribute($countryOfOriginAttribute);
|
1526 |
Â
}
|
1527 |
Â
|
1531 |
Â
|
1532 |
Â
if (empty($countryOfOrigin)) {
|
1533 |
Â
throw new TIG_PostNL_Exception(
|
1534 |
+
Mage::helper('postnl')->__(
|
1535 |
+
'Missing country of origin value for product #%s.',
|
1536 |
+
$shipmentItem->getProductId()
|
1537 |
+
),
|
1538 |
Â
'POSTNL-0091'
|
1539 |
Â
);
|
1540 |
Â
}
|
1545 |
Â
/**
|
1546 |
Â
* Get a shipment item's customs value
|
1547 |
Â
*
|
1548 |
+
* @param Mage_Sales_Model_Order_Shipment_Item $shipmentItem
|
1549 |
+
*
|
1550 |
+
* @throws TIG_PostNL_Exception
|
1551 |
Â
*
|
1552 |
Â
* @return string
|
1553 |
Â
*/
|
1554 |
Â
protected function _getCustomsValue($shipmentItem)
|
1555 |
Â
{
|
1556 |
Â
$storeId = $this->getStoreId();
|
1557 |
+
if ($this->hasCustomsValueAttribute()) {
|
1558 |
Â
$customsValueAttribute = $this->getCustomsValueAttribute();
|
1559 |
Â
} else {
|
1560 |
Â
$customsValueAttribute = Mage::getStoreConfig(self::XML_PATH_GLOBALPACK_CUSTOMS_VALUE_ATTRIBUTE, $storeId);
|
1578 |
Â
/**
|
1579 |
Â
* Get a shipment item's customs description
|
1580 |
Â
*
|
1581 |
+
* @param Mage_Sales_Model_Order_Shipment_Item $shipmentItem
|
1582 |
+
*
|
1583 |
+
* @throws TIG_PostNL_Exception
|
1584 |
Â
*
|
1585 |
Â
* @return string
|
1586 |
Â
*/
|
1587 |
Â
protected function _getCustomsDescription($shipmentItem)
|
1588 |
Â
{
|
1589 |
Â
$storeId = $this->getStoreId();
|
1590 |
+
if ($this->hasCustomsDescriptionAttribute()) {
|
1591 |
Â
$descriptionAttribute = $this->getCustomsDescriptionAttribute();
|
1592 |
Â
} else {
|
1593 |
Â
$descriptionAttribute = Mage::getStoreConfig(self::XML_PATH_GLOBALPACK_DESCRIPTION_ATTRIBUTE, $storeId);
|
1600 |
Â
|
1601 |
Â
if (empty($description)) {
|
1602 |
Â
throw new TIG_PostNL_Exception(
|
1603 |
+
Mage::helper('postnl')->__(
|
1604 |
+
'Missing customs description for product #%s.',
|
1605 |
+
$shipmentItem->getProductId()
|
1606 |
+
),
|
1607 |
Â
'POSTNL-0093'
|
1608 |
Â
);
|
1609 |
Â
}
|
1701 |
Â
protected function _getCustomsCertificate()
|
1702 |
Â
{
|
1703 |
Â
$storeId = $this->getStoreId();
|
1704 |
+
$customsCertificate = (string) Mage::getStoreConfig(
|
1705 |
+
self::XML_PATH_GLOBALPACK_CUSTOMS_CERTIFICATE_NUMBER,
|
1706 |
+
$storeId
|
1707 |
+
);
|
1708 |
Â
|
1709 |
Â
if (empty($customsCertificate)) {
|
1710 |
Â
return false;
|
1716 |
Â
/**
|
1717 |
Â
* Get the area field from an address if enabled
|
1718 |
Â
*
|
1719 |
+
* @param Mage_Sales_Model_Order_Address $address
|
1720 |
+
*
|
1721 |
Â
* @return string
|
1722 |
Â
*/
|
1723 |
Â
protected function _getArea($address)
|
1733 |
Â
/**
|
1734 |
Â
* Attempt to get the area through the magic getter instead
|
1735 |
Â
*/
|
1736 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1737 |
Â
$area = $address->getArea();
|
1738 |
Â
|
1739 |
Â
return $area;
|
1742 |
Â
/**
|
1743 |
Â
* Get the area building name from an address if enabled
|
1744 |
Â
*
|
1745 |
+
* @param Mage_Sales_Model_Order_Address $address
|
1746 |
+
*
|
1747 |
Â
* @return string
|
1748 |
Â
*/
|
1749 |
Â
protected function _getBuildingName($address)
|
1759 |
Â
/**
|
1760 |
Â
* Attempt to get the building name through the magic getter instead
|
1761 |
Â
*/
|
1762 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1763 |
Â
$buildingName = $address->getBuildingName();
|
1764 |
Â
|
1765 |
Â
return $buildingName;
|
1768 |
Â
/**
|
1769 |
Â
* Get the department field from an address if enabled
|
1770 |
Â
*
|
1771 |
+
* @param Mage_Sales_Model_Order_Address $address
|
1772 |
+
*
|
1773 |
Â
* @return string
|
1774 |
Â
*/
|
1775 |
Â
protected function _getDepartment($address)
|
1785 |
Â
/**
|
1786 |
Â
* Attempt to get department through the magic getter instead
|
1787 |
Â
*/
|
1788 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1789 |
Â
$department = $address->getDepartment();
|
1790 |
Â
|
1791 |
Â
return $department;
|
1794 |
Â
/**
|
1795 |
Â
* Get the doorcode field from an address if enabled
|
1796 |
Â
*
|
1797 |
+
* @param Mage_Sales_Model_Order_Address $address
|
1798 |
+
*
|
1799 |
Â
* @return string
|
1800 |
Â
*/
|
1801 |
Â
protected function _getDoorcode($address)
|
1811 |
Â
/**
|
1812 |
Â
* Attempt to get the doorcode through the magic getter instead
|
1813 |
Â
*/
|
1814 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1815 |
Â
$doorcode = $address->getDoorcode();
|
1816 |
Â
|
1817 |
Â
return $doorcode;
|
1820 |
Â
/**
|
1821 |
Â
* Get the floor field from an address if enabled
|
1822 |
Â
*
|
1823 |
+
* @param Mage_Sales_Model_Order_Address $address
|
1824 |
+
*
|
1825 |
Â
* @return string
|
1826 |
Â
*/
|
1827 |
Â
protected function _getFloor($address)
|
1837 |
Â
/**
|
1838 |
Â
* Attempt to get the floor through the magic getter instead
|
1839 |
Â
*/
|
1840 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1841 |
Â
$floor = $address->getFloor();
|
1842 |
Â
|
1843 |
Â
return $floor;
|
1846 |
Â
/**
|
1847 |
Â
* Get the remark field from an address if enabled
|
1848 |
Â
*
|
1849 |
+
* @param Mage_Sales_Model_Order_Address $address
|
1850 |
+
*
|
1851 |
Â
* @return string
|
1852 |
Â
*/
|
1853 |
Â
protected function _getRemark($address)
|
1863 |
Â
/**
|
1864 |
Â
* Attempt to get the remark through the magic getter instead
|
1865 |
Â
*/
|
1866 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
1867 |
Â
$remark = $address->getRemark();
|
1868 |
Â
|
1869 |
Â
return $remark;
|
1872 |
Â
/**
|
1873 |
Â
* Get a shipment's reference. By default this will be the shipment's increment ID
|
1874 |
Â
*
|
1875 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
1876 |
Â
*
|
1877 |
Â
* @return string
|
1878 |
Â
*
|
1911 |
Â
* For custom references we need to replace several optional variables
|
1912 |
Â
*/
|
1913 |
Â
if ($referenceType == 'custom') {
|
1914 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
1915 |
+
|
1916 |
Â
$reference = str_replace('{{var shipment_increment_id}}', $shipment->getIncrementId(), $reference);
|
1917 |
Â
$reference = str_replace('{{var order_increment_id}}', $shipment->getOrder()->getIncrementId(), $reference);
|
1918 |
Â
|
Â
|
|
1919 |
Â
$reference = str_replace('{{var store_frontend_name}}', $store->getFrontendName(), $reference);
|
1920 |
Â
}
|
1921 |
Â
|
@@ -1,157 +1,241 @@
|
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
-
* ___________ __ __
|
4 |
-
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
-
* \/
|
9 |
-
* ___ __ __
|
10 |
-
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
-
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
-
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
-
* \/ \/
|
15 |
-
* ________
|
16 |
-
* / _____/_______ ____ __ __ ______
|
17 |
-
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
-
* \______ /|__| \____/ |____/ | __/
|
20 |
-
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
-
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
29 |
Â
*
|
30 |
Â
* DISCLAIMER
|
31 |
Â
*
|
32 |
-
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Base CIF model. Contains general code for communicating with the CIF API
|
42 |
-
*/
|
43 |
-
class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
44 |
Â
{
|
45 |
Â
/**
|
46 |
Â
* Base URL of wsdl files
|
47 |
Â
*/
|
48 |
Â
const WSDL_BASE_URL = 'https://service.postnl.com/CIF/';
|
49 |
-
|
50 |
Â
/**
|
51 |
Â
* Base URL of sandbox wsdl files
|
52 |
Â
*/
|
53 |
Â
const TEST_WSDL_BASE_URL = 'https://testservice.postnl.com/CIF_SB/';
|
54 |
-
|
55 |
Â
/**
|
56 |
-
*
|
57 |
Â
*/
|
58 |
-
const WSDL_BARCODE_NAME
|
59 |
-
const WSDL_CONFIRMING_NAME
|
60 |
-
const WSDL_LABELLING_NAME
|
61 |
-
const
|
62 |
-
const WSDL_CHECKOUT_NAME
|
63 |
-
|
Â
|
|
Â
|
|
Â
|
|
64 |
Â
/**
|
65 |
-
*
|
66 |
Â
*/
|
67 |
Â
const HEADER_SECURITY_NAMESPACE = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
|
68 |
-
|
69 |
Â
/**
|
70 |
Â
* CIF error namespace.
|
71 |
Â
*/
|
72 |
Â
const CIF_ERROR_NAMESPACE = 'http://schemas.datacontract.org/2004/07/Tpp.Cif.Services.Services.Exception';
|
73 |
-
|
74 |
Â
/**
|
75 |
Â
* XML paths for config options
|
76 |
Â
*/
|
77 |
-
const
|
78 |
-
const
|
79 |
-
const
|
80 |
-
const
|
81 |
-
const
|
82 |
-
const
|
83 |
-
const
|
84 |
-
const
|
85 |
-
const
|
86 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
87 |
Â
/**
|
88 |
Â
* Gets the username from system/config. Test mode determines if live or test username is used.
|
89 |
-
*
|
90 |
Â
* @param boolean|int $storeId
|
91 |
-
*
|
92 |
Â
* @return string
|
93 |
Â
*/
|
94 |
-
|
95 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
96 |
Â
if ($storeId === false) {
|
97 |
Â
$storeId = $this->getStoreId();
|
98 |
Â
}
|
99 |
-
|
100 |
-
if (!$storeId) {
|
101 |
-
$storeId = Mage::app()->getStore()->getId();
|
102 |
-
}
|
103 |
-
|
104 |
Â
if ($this->isTestMode()) {
|
105 |
-
$username = Mage::getStoreConfig(self::
|
106 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
107 |
Â
}
|
108 |
-
|
109 |
-
$username = Mage::getStoreConfig(self::XML_PATH_LIVE_USERNAME, $storeId);
|
110 |
Â
return trim($username);
|
111 |
Â
}
|
112 |
-
|
113 |
Â
/**
|
114 |
Â
* Gets the password from system/config. Test mode determines if live or test password is used.
|
115 |
Â
* Passwords will be decrypted using Magento's encryption key and then hashed using sha1
|
116 |
-
*
|
117 |
Â
* @param boolean|int $storeId
|
118 |
-
*
|
119 |
-
* @return string
|
120 |
Â
*/
|
121 |
-
|
122 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
123 |
Â
if ($storeId === false) {
|
124 |
Â
$storeId = $this->getStoreId();
|
125 |
Â
}
|
126 |
-
|
127 |
-
if (!$storeId) {
|
128 |
-
$storeId = Mage::app()->getStore()->getId();
|
129 |
-
}
|
130 |
-
|
131 |
Â
if ($this->isTestMode()) {
|
132 |
-
$
|
133 |
-
|
134 |
-
$
|
135 |
-
$password = sha1(Mage::helper('core')->decrypt($password));
|
136 |
-
|
137 |
-
return $password;
|
138 |
Â
}
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
Â
|
|
Â
|
|
Â
|
|
145 |
Â
return $password;
|
146 |
Â
}
|
147 |
-
|
148 |
Â
/**
|
149 |
Â
* Check if the module is set to test mode
|
150 |
-
*
|
151 |
Â
* @param boolean|int $storeId
|
152 |
-
*
|
153 |
Â
* @return boolean
|
154 |
-
*
|
155 |
Â
* @see TIG_PostNL_Helper_Data::isTestMode()
|
156 |
Â
*/
|
157 |
Â
public function isTestMode($storeId = false)
|
@@ -160,127 +244,148 @@ class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
160 |
Â
$testMode = $this->getTestMode();
|
161 |
Â
return $testMode;
|
162 |
Â
}
|
163 |
-
|
164 |
Â
if ($storeId === false) {
|
165 |
Â
$storeId = $this->getStoreId();
|
166 |
Â
}
|
167 |
-
|
168 |
-
if (
|
169 |
Â
$storeId = Mage::app()->getStore()->getId();
|
170 |
Â
}
|
171 |
-
|
172 |
-
$testMode =
|
173 |
-
|
174 |
Â
return $testMode;
|
175 |
Â
}
|
176 |
Â
|
177 |
Â
/**
|
178 |
-
*
|
179 |
-
*
|
180 |
-
* @param string $wsdlType
|
181 |
-
*
|
182 |
-
* @
|
183 |
-
* @param boolean|string $username
|
184 |
-
* @param boolean|string $password
|
185 |
-
*
|
186 |
-
* @return object
|
187 |
-
*
|
188 |
-
* @throws TIG_PostNL_Exception
|
189 |
Â
*/
|
190 |
-
public function
|
191 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
192 |
Â
try {
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
'POSTNL-0052'
|
199 |
-
);
|
200 |
-
}
|
201 |
-
|
202 |
-
$wsdlFile = $this->_getWsdl($wsdlType);
|
203 |
-
|
204 |
Â
/**
|
205 |
-
*
|
206 |
Â
*/
|
207 |
-
$soapOptions =
|
208 |
-
|
209 |
-
|
Â
|
|
Â
|
|
210 |
Â
);
|
211 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
212 |
Â
/**
|
213 |
-
*
|
214 |
-
* wsdl cache.
|
215 |
Â
*/
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Disable wsdl cache and try again
|
224 |
-
*/
|
225 |
-
$soapOptions['cache_wsdl'] = WSDL_CACHE_NONE;
|
226 |
-
|
227 |
-
$client = new Zend_Soap_Client(
|
228 |
-
$wsdlFile,
|
229 |
-
$soapOptions
|
230 |
Â
);
|
231 |
Â
}
|
232 |
-
|
233 |
Â
/**
|
234 |
Â
* Add SOAP header
|
235 |
Â
*/
|
236 |
-
$header = $this->_getSoapHeader(
|
237 |
Â
$client->addSoapInputHeader($header, true); //permanent header
|
238 |
-
|
239 |
Â
/**
|
240 |
Â
* Call the SOAP method
|
241 |
Â
*/
|
242 |
-
$response = $client
|
243 |
-
|
244 |
-
array(
|
245 |
-
$method => $soapParams,
|
246 |
-
)
|
247 |
-
);
|
248 |
-
|
249 |
Â
/**
|
250 |
-
*
|
251 |
Â
*/
|
252 |
Â
$this->_processWarnings($client);
|
253 |
-
|
254 |
-
|
255 |
Â
return $response;
|
256 |
Â
} catch(SoapFault $e) {
|
257 |
Â
/**
|
258 |
Â
* Only Soap exceptions are caught. Other exceptions must be caught by the caller
|
Â
|
|
Â
|
|
259 |
Â
*/
|
260 |
Â
$this->_handleCifException($e, $client);
|
261 |
Â
}
|
Â
|
|
Â
|
|
262 |
Â
}
|
263 |
Â
|
264 |
Â
/**
|
265 |
-
*
|
266 |
-
*
|
267 |
-
*
|
268 |
Â
* - barcode
|
269 |
Â
* - confirming
|
270 |
Â
* - labelling
|
271 |
Â
* - shippingstatus
|
272 |
Â
* - checkout
|
273 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
274 |
Â
* @param string $wsdlType
|
275 |
-
*
|
276 |
Â
* @return string
|
277 |
-
*
|
278 |
Â
* @throws TIG_PostNL_Exception
|
279 |
Â
*/
|
280 |
Â
protected function _getWsdl($wsdlType)
|
281 |
Â
{
|
282 |
Â
$adminStoreId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
283 |
-
|
284 |
Â
/**
|
285 |
Â
* Check which wsdl file we need for each wsdl type
|
286 |
Â
* Als get the wsdl version to get
|
@@ -288,38 +393,44 @@ class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
288 |
Â
$wsdlType = strtolower($wsdlType);
|
289 |
Â
switch ($wsdlType) {
|
290 |
Â
case 'barcode':
|
291 |
-
$wsdlversion = Mage::getStoreConfig(self::
|
292 |
Â
$wsdlFileName = self::WSDL_BARCODE_NAME;
|
293 |
Â
break;
|
294 |
Â
case 'confirming':
|
295 |
-
$wsdlversion = Mage::getStoreConfig(self::
|
296 |
Â
$wsdlFileName = self::WSDL_CONFIRMING_NAME;
|
297 |
Â
break;
|
298 |
Â
case 'labelling':
|
299 |
-
$wsdlversion = Mage::getStoreConfig(self::
|
300 |
Â
$wsdlFileName = self::WSDL_LABELLING_NAME;
|
301 |
Â
break;
|
302 |
Â
case 'shippingstatus':
|
303 |
-
$wsdlversion = Mage::getStoreConfig(self::
|
304 |
-
$wsdlFileName = self::
|
305 |
Â
break;
|
306 |
Â
case 'checkout':
|
307 |
-
$wsdlversion = Mage::getStoreConfig(self::
|
308 |
Â
$wsdlFileName = self::WSDL_CHECKOUT_NAME;
|
309 |
Â
break;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
310 |
Â
default:
|
311 |
Â
throw new TIG_PostNL_Exception(
|
312 |
Â
Mage::helper('postnl')->__('Chosen wsdl type is not supported: %s', $wsdlType),
|
313 |
Â
'POSTNL-0053'
|
314 |
Â
);
|
315 |
Â
}
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Wsdl version numbers are formatted using an underscore instead of a period. Since many people would use a period, we
|
319 |
-
* convert it to CIF specifications.
|
320 |
-
*/
|
321 |
-
$wsdlversion = str_replace('.', '_', $wsdlversion);
|
322 |
-
|
323 |
Â
/**
|
324 |
Â
* Check if we need the live or the sandbox wsdl
|
325 |
Â
*/
|
@@ -328,48 +439,46 @@ class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
328 |
Â
} else {
|
329 |
Â
$wsdlUrl = self::WSDL_BASE_URL;
|
330 |
Â
}
|
331 |
-
|
332 |
Â
/**
|
333 |
Â
* Format the final wsdl URL
|
334 |
Â
*/
|
335 |
Â
$wsdlUrl .= $wsdlFileName
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
Â
return $wsdlUrl;
|
341 |
Â
}
|
342 |
-
|
343 |
Â
/**
|
344 |
-
* Builds soap headers array for CIF authentication
|
345 |
-
*
|
346 |
-
* @
|
347 |
-
* @param boolean|string $password
|
348 |
-
*
|
349 |
-
* @return array
|
350 |
Â
*/
|
351 |
-
protected function _getSoapHeader(
|
352 |
Â
{
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
}
|
357 |
-
|
358 |
Â
$namespace = self::HEADER_SECURITY_NAMESPACE;
|
359 |
-
$node1 = new SoapVar($username, XSD_STRING,
|
360 |
-
$node2 = new SoapVar($password, XSD_STRING,
|
Â
|
|
361 |
Â
$token = new SoapVar(array($node1, $node2), SOAP_ENC_OBJECT, null, null, 'UsernameToken', $namespace);
|
362 |
-
|
363 |
-
$
|
364 |
-
|
Â
|
|
Â
|
|
365 |
Â
return $header;
|
366 |
Â
}
|
367 |
-
|
368 |
Â
/**
|
369 |
Â
* Check if warnings occurred while processing the CIF request. If so, parse and register them
|
370 |
-
*
|
371 |
-
* @param
|
372 |
-
*
|
373 |
Â
* @return TIG_PostNL_Model_Core_Cif_Abstract
|
374 |
Â
*/
|
375 |
Â
protected function _processWarnings($client)
|
@@ -377,18 +486,20 @@ class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
377 |
Â
$responseXML = $client->getLastResponse();
|
378 |
Â
$responseDOMDoc = new DOMDocument();
|
379 |
Â
$responseDOMDoc->loadXML($responseXML);
|
380 |
-
|
381 |
Â
/**
|
382 |
-
* Search the CIF response for warnings
|
383 |
Â
*/
|
384 |
Â
$warnings = $responseDOMDoc->getElementsByTagName('Warning');
|
385 |
-
|
386 |
Â
if (!$warnings || $warnings->length < 1) {
|
387 |
Â
return $this;
|
388 |
Â
}
|
389 |
-
|
390 |
Â
/**
|
391 |
-
*
|
Â
|
|
Â
|
|
392 |
Â
*/
|
393 |
Â
$n = 0;
|
394 |
Â
$responseWarnings = array();
|
@@ -401,40 +512,44 @@ class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
401 |
Â
}
|
402 |
Â
$n++;
|
403 |
Â
}
|
404 |
-
|
405 |
Â
/**
|
406 |
-
* Check if old warnings are still present in the registry. If so, merge these with the new warnings
|
407 |
Â
*/
|
408 |
Â
if (Mage::registry('postnl_cif_warnings') !== null) {
|
409 |
Â
$existingWarnings = (array) Mage::registry('postnl_cif_warnings');
|
410 |
Â
$responseWarnings = array_merge($responseWarnings, $existingWarnings);
|
411 |
-
|
412 |
Â
/**
|
413 |
Â
* Remove the old warnings from the registry
|
414 |
Â
*/
|
415 |
-
Mage::
|
416 |
Â
}
|
417 |
-
|
418 |
Â
/**
|
419 |
Â
* Register the warnings
|
420 |
Â
*/
|
421 |
Â
Mage::register('postnl_cif_warnings', $responseWarnings);
|
422 |
-
|
423 |
Â
return $this;
|
424 |
Â
}
|
425 |
-
|
426 |
Â
/**
|
427 |
-
* Handle a SoapFault
|
428 |
-
*
|
429 |
-
* @param SoapFault
|
430 |
-
* @param
|
431 |
-
*
|
432 |
Â
* @throws TIG_PostNL_Model_Core_Cif_Exception
|
433 |
Â
*/
|
434 |
-
protected function _handleCifException($e, $client = null)
|
435 |
Â
{
|
436 |
Â
$cifHelper = Mage::helper('postnl/cif');
|
437 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
438 |
Â
/**
|
439 |
Â
* Get the request and response XML data
|
440 |
Â
*/
|
@@ -442,49 +557,57 @@ class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
|
442 |
Â
$requestXML = $cifHelper->formatXml($client->getLastRequest());
|
443 |
Â
$responseXML = $cifHelper->formatXml($client->getLastResponse());
|
444 |
Â
}
|
445 |
-
|
446 |
-
|
Â
|
|
Â
|
|
Â
|
|
447 |
Â
/**
|
448 |
Â
* If we received a response, parse it for errors and create an appropriate exception
|
449 |
Â
*/
|
450 |
Â
$errorResponse = new DOMDocument();
|
451 |
Â
$errorResponse->loadXML($responseXML);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
452 |
Â
$errors = $errorResponse->getElementsByTagNameNS(self::CIF_ERROR_NAMESPACE, 'ErrorMsg');
|
453 |
Â
if ($errors) {
|
454 |
Â
$message = '';
|
455 |
Â
foreach($errors as $error) {
|
456 |
Â
$message .= $error->nodeValue . PHP_EOL;
|
457 |
Â
}
|
458 |
-
|
459 |
-
|
Â
|
|
Â
|
|
Â
|
|
460 |
Â
}
|
461 |
-
|
Â
|
|
Â
|
|
Â
|
|
462 |
Â
$errorNumbers = $errorResponse->getElementsByTagNameNS(self::CIF_ERROR_NAMESPACE, 'ErrorNumber');
|
463 |
-
if ($
|
464 |
Â
foreach ($errorNumbers as $errorNumber) {
|
465 |
Â
$exception->addErrorNumber($errorNumber->nodeValue);
|
466 |
Â
}
|
467 |
Â
}
|
468 |
-
} else {
|
469 |
-
/**
|
470 |
-
* Create a general exception
|
471 |
-
*/
|
472 |
-
$exception = new TIG_PostNL_Model_Core_Cif_Exception($e->getMessage(), null, $e);
|
473 |
Â
}
|
474 |
-
|
475 |
Â
/**
|
476 |
Â
* Add the response and request data to the exception (to be logged later)
|
477 |
Â
*/
|
478 |
-
if ($
|
479 |
Â
$exception->setRequestXml($requestXML)
|
480 |
Â
->setResponseXml($responseXML);
|
481 |
Â
}
|
482 |
-
|
483 |
Â
/**
|
484 |
Â
* Log the exception and throw it
|
485 |
-
*/
|
486 |
Â
$cifHelper->logCifException($exception);
|
487 |
-
|
488 |
Â
throw $exception;
|
489 |
Â
}
|
490 |
Â
}
|
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 |
+
* Base CIF model. Contains general code for communicating with the CIF API
|
40 |
+
*
|
41 |
+
* @method boolean getTestMode()
|
42 |
+
*
|
43 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract setHelper(Mage_Core_Helper_Abstract $value)
|
44 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract setSoapClient(Zend_Soap_Client $value)
|
45 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract setTestMode(boolean $value)
|
46 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract setPassword(string $value)
|
47 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract setUsername(string $value)
|
48 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract setStoreId(int $value)
|
49 |
+
*
|
50 |
+
* @method boolean hasSoapClient()
|
51 |
+
* @method boolean hasHelper()
|
52 |
+
* @method boolean hasStoreId()
|
53 |
+
* @method boolean hasTestMode()
|
54 |
+
* @method boolean hasPassword()
|
55 |
+
* @method boolean hasUsername()
|
56 |
+
*
|
57 |
+
* @method TIG_PostNL_Model_Core_Cif_Abstract unsTestMode()
|
58 |
Â
*/
|
59 |
+
abstract class TIG_PostNL_Model_Core_Cif_Abstract extends Varien_Object
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
60 |
Â
{
|
61 |
Â
/**
|
62 |
Â
* Base URL of wsdl files
|
63 |
Â
*/
|
64 |
Â
const WSDL_BASE_URL = 'https://service.postnl.com/CIF/';
|
65 |
+
|
66 |
Â
/**
|
67 |
Â
* Base URL of sandbox wsdl files
|
68 |
Â
*/
|
69 |
Â
const TEST_WSDL_BASE_URL = 'https://testservice.postnl.com/CIF_SB/';
|
70 |
+
|
71 |
Â
/**
|
72 |
+
* Available wsdl filenames.
|
73 |
Â
*/
|
74 |
+
const WSDL_BARCODE_NAME = 'BarcodeWebService';
|
75 |
+
const WSDL_CONFIRMING_NAME = 'ConfirmingWebService';
|
76 |
+
const WSDL_LABELLING_NAME = 'LabellingWebService';
|
77 |
+
const WSDL_SHIPPINGSTATUS_NAME = 'ShippingStatusWebService';
|
78 |
+
const WSDL_CHECKOUT_NAME = 'WebshopCheckoutWebService';
|
79 |
+
const WSDL_DELIVERYDATE_NAME = 'DeliveryDateWebService';
|
80 |
+
const WSDL_TIMEFRAME_NAME = 'TimeframeWebService';
|
81 |
+
const WSDL_LOCATION_NAME = 'LocationWebService';
|
82 |
+
|
83 |
Â
/**
|
84 |
+
* Header security namespace. Used for constructing the SOAP headers array.
|
85 |
Â
*/
|
86 |
Â
const HEADER_SECURITY_NAMESPACE = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
|
87 |
+
|
88 |
Â
/**
|
89 |
Â
* CIF error namespace.
|
90 |
Â
*/
|
91 |
Â
const CIF_ERROR_NAMESPACE = 'http://schemas.datacontract.org/2004/07/Tpp.Cif.Services.Services.Exception';
|
92 |
+
|
93 |
Â
/**
|
94 |
Â
* XML paths for config options
|
95 |
Â
*/
|
96 |
+
const XPATH_LIVE_USERNAME = 'postnl/cif/live_username';
|
97 |
+
const XPATH_LIVE_PASSWORD = 'postnl/cif/live_password';
|
98 |
+
const XPATH_TEST_USERNAME = 'postnl/cif/test_username';
|
99 |
+
const XPATH_TEST_PASSWORD = 'postnl/cif/test_password';
|
100 |
+
const XPATH_CIF_VERSION_BARCODE = 'postnl/advanced/cif_version_barcode';
|
101 |
+
const XPATH_CIF_VERSION_LABELLING = 'postnl/advanced/cif_version_labelling';
|
102 |
+
const XPATH_CIF_VERSION_CONFIRMING = 'postnl/advanced/cif_version_confirming';
|
103 |
+
const XPATH_CIF_VERSION_SHIPPINGSTATUS = 'postnl/advanced/cif_version_shippingstatus';
|
104 |
+
const XPATH_CIF_VERSION_CHECKOUT = 'postnl/advanced/cif_version_checkout';
|
105 |
+
const XPATH_CIF_VERSION_DELIVERYDATE = 'postnl/advanced/cif_version_deliverydate';
|
106 |
+
const XPATH_CIF_VERSION_TIMEFRAME = 'postnl/advanced/cif_version_timeframe';
|
107 |
+
const XPATH_CIF_VERSION_LOCATION = 'postnl/advanced/cif_version_location';
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Check if the required PHP extensions are installed.
|
111 |
+
*
|
112 |
+
* @throws TIG_PostNL_Exception
|
113 |
+
*/
|
114 |
+
protected function _construct()
|
115 |
+
{
|
116 |
+
if (!extension_loaded('soap')) {
|
117 |
+
throw new TIG_PostNL_Exception(
|
118 |
+
Mage::helper('postnl')->__('The SOAP extension is not installed. PostNL requires the SOAP extension to '
|
119 |
+
. 'communicate with PostNL.'
|
120 |
+
),
|
121 |
+
'POSTNL-0134'
|
122 |
+
);
|
123 |
+
}
|
124 |
+
|
125 |
+
if (!extension_loaded('openssl')) {
|
126 |
+
throw new TIG_PostNL_Exception(
|
127 |
+
Mage::helper('postnl')->__('The OpenSSL extension is not installed. The PostNL extension requires the '
|
128 |
+
. 'OpenSSL extension to secure the communications with the PostNL servers.'
|
129 |
+
),
|
130 |
+
'POSTNL-0135'
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
parent::_construct();
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* @return int
|
139 |
+
*/
|
140 |
+
public function getStoreId()
|
141 |
+
{
|
142 |
+
if ($this->hasStoreId()) {
|
143 |
+
return $this->_getData('store_id');
|
144 |
+
}
|
145 |
+
|
146 |
+
$storeId = Mage::app()->getStore()->getId();
|
147 |
+
|
148 |
+
$this->setStoreId($storeId);
|
149 |
+
return $storeId;
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @return TIG_PostNL_Helper_Cif
|
154 |
+
*/
|
155 |
+
public function getHelper()
|
156 |
+
{
|
157 |
+
if ($this->hasHelper()) {
|
158 |
+
return $this->getData('helper');
|
159 |
+
}
|
160 |
+
|
161 |
+
$helper = Mage::helper('postnl/cif');
|
162 |
+
|
163 |
+
$this->setHelper($helper);
|
164 |
+
return $helper;
|
165 |
+
}
|
166 |
+
|
167 |
Â
/**
|
168 |
Â
* Gets the username from system/config. Test mode determines if live or test username is used.
|
169 |
+
*
|
170 |
Â
* @param boolean|int $storeId
|
171 |
+
*
|
172 |
Â
* @return string
|
173 |
Â
*/
|
174 |
+
public function getUsername($storeId = false)
|
175 |
Â
{
|
176 |
+
if ($this->hasUsername()) {
|
177 |
+
return $this->_getData('username');
|
178 |
+
}
|
179 |
+
|
180 |
Â
if ($storeId === false) {
|
181 |
Â
$storeId = $this->getStoreId();
|
182 |
Â
}
|
183 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
184 |
Â
if ($this->isTestMode()) {
|
185 |
+
$username = Mage::getStoreConfig(self::XPATH_TEST_USERNAME, $storeId);
|
186 |
+
} else {
|
187 |
+
$username = Mage::getStoreConfig(self::XPATH_LIVE_USERNAME, $storeId);
|
188 |
+
}
|
189 |
+
|
190 |
+
if (!$username) {
|
191 |
+
return false;
|
192 |
Â
}
|
193 |
+
|
Â
|
|
194 |
Â
return trim($username);
|
195 |
Â
}
|
196 |
+
|
197 |
Â
/**
|
198 |
Â
* Gets the password from system/config. Test mode determines if live or test password is used.
|
199 |
Â
* Passwords will be decrypted using Magento's encryption key and then hashed using sha1
|
200 |
+
*
|
201 |
Â
* @param boolean|int $storeId
|
202 |
+
*
|
203 |
+
* @return string|boolean
|
204 |
Â
*/
|
205 |
+
public function getPassword($storeId = false)
|
206 |
Â
{
|
207 |
+
if ($this->hasPassword()) {
|
208 |
+
return $this->_getData('password');
|
209 |
+
}
|
210 |
+
|
211 |
Â
if ($storeId === false) {
|
212 |
Â
$storeId = $this->getStoreId();
|
213 |
Â
}
|
214 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
215 |
Â
if ($this->isTestMode()) {
|
216 |
+
$configPassword = Mage::getStoreConfig(self::XPATH_TEST_PASSWORD, $storeId);
|
217 |
+
} else {
|
218 |
+
$configPassword = Mage::getStoreConfig(self::XPATH_LIVE_PASSWORD, $storeId);
|
Â
|
|
Â
|
|
Â
|
|
219 |
Â
}
|
220 |
+
|
221 |
+
if (!$configPassword) {
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
$configPassword = trim($configPassword);
|
226 |
+
$decryptedPassword = Mage::helper('core')->decrypt($configPassword);
|
227 |
+
$password = sha1($decryptedPassword);
|
228 |
+
|
229 |
Â
return $password;
|
230 |
Â
}
|
231 |
+
|
232 |
Â
/**
|
233 |
Â
* Check if the module is set to test mode
|
234 |
+
*
|
235 |
Â
* @param boolean|int $storeId
|
236 |
+
*
|
237 |
Â
* @return boolean
|
238 |
+
*
|
239 |
Â
* @see TIG_PostNL_Helper_Data::isTestMode()
|
240 |
Â
*/
|
241 |
Â
public function isTestMode($storeId = false)
|
244 |
Â
$testMode = $this->getTestMode();
|
245 |
Â
return $testMode;
|
246 |
Â
}
|
247 |
+
|
248 |
Â
if ($storeId === false) {
|
249 |
Â
$storeId = $this->getStoreId();
|
250 |
Â
}
|
251 |
+
|
252 |
+
if (is_null($storeId)) {
|
253 |
Â
$storeId = Mage::app()->getStore()->getId();
|
254 |
Â
}
|
255 |
+
|
256 |
+
$testMode = $this->getHelper()->isTestMode($storeId);
|
257 |
+
|
258 |
Â
return $testMode;
|
259 |
Â
}
|
260 |
Â
|
261 |
Â
/**
|
262 |
+
* Gets a Zend_Soap_Client instance for the specified wsdl type.
|
263 |
+
*
|
264 |
+
* @param string|null $wsdlType
|
265 |
+
*
|
266 |
+
* @return Zend_Soap_Client
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
267 |
Â
*/
|
268 |
+
public function getSoapClient($wsdlType = null)
|
269 |
Â
{
|
270 |
+
if ($this->hasSoapClient()) {
|
271 |
+
return $this->_getData('soap_client');
|
272 |
+
}
|
273 |
+
|
274 |
+
$wsdlFile = $this->_getWsdl($wsdlType);
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Array of soap options used when connecting to CIF
|
278 |
+
*/
|
279 |
+
$soapOptions = array(
|
280 |
+
'soap_version' => SOAP_1_1,
|
281 |
+
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
|
282 |
+
);
|
283 |
+
|
284 |
+
/**
|
285 |
+
* try to create a new Zend_Soap_Client instance based on the supplied wsdl. if it fails, try again without using the
|
286 |
+
* wsdl cache.
|
287 |
+
*/
|
288 |
Â
try {
|
289 |
+
$client = new Zend_Soap_Client(
|
290 |
+
$wsdlFile,
|
291 |
+
$soapOptions
|
292 |
+
);
|
293 |
+
} catch (Exception $e) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
294 |
Â
/**
|
295 |
+
* Disable wsdl cache and try again
|
296 |
Â
*/
|
297 |
+
$soapOptions['cache_wsdl'] = WSDL_CACHE_NONE;
|
298 |
+
|
299 |
+
$client = new Zend_Soap_Client(
|
300 |
+
$wsdlFile,
|
301 |
+
$soapOptions
|
302 |
Â
);
|
303 |
+
}
|
304 |
+
|
305 |
+
$this->setSoapClient($client);
|
306 |
+
return $client;
|
307 |
+
}
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Calls a CIF method
|
311 |
+
*
|
312 |
+
* @param string $wsdlType Which wsdl to use
|
313 |
+
* @param callable $method The method that will be called
|
314 |
+
* @param array $soapParams An array of parameters to be sent
|
315 |
+
*
|
316 |
+
* @return object|boolean
|
317 |
+
*
|
318 |
+
* @throws TIG_PostNL_Exception
|
319 |
+
*/
|
320 |
+
public function call($wsdlType, $method, $soapParams = array())
|
321 |
+
{
|
322 |
+
$client = null;
|
323 |
+
try {
|
324 |
Â
/**
|
325 |
+
* @var Zend_Soap_Client $client
|
Â
|
|
326 |
Â
*/
|
327 |
+
$client = $this->getSoapClient($wsdlType);
|
328 |
+
|
329 |
+
if (!is_callable(array($client, $method))) {
|
330 |
+
throw new TIG_PostNL_Exception(
|
331 |
+
Mage::helper('postnl')->__('The specified method "%s" is not callable.', $method),
|
332 |
+
'POSTNL-0136'
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
333 |
Â
);
|
334 |
Â
}
|
335 |
+
|
336 |
Â
/**
|
337 |
Â
* Add SOAP header
|
338 |
Â
*/
|
339 |
+
$header = $this->_getSoapHeader();
|
340 |
Â
$client->addSoapInputHeader($header, true); //permanent header
|
341 |
+
|
342 |
Â
/**
|
343 |
Â
* Call the SOAP method
|
344 |
Â
*/
|
345 |
+
$response = $client->$method($soapParams);
|
346 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
347 |
Â
/**
|
348 |
+
* Process any warnings that may have occurred
|
349 |
Â
*/
|
350 |
Â
$this->_processWarnings($client);
|
351 |
+
|
352 |
+
$this->getHelper()->logCifCall($client);
|
353 |
Â
return $response;
|
354 |
Â
} catch(SoapFault $e) {
|
355 |
Â
/**
|
356 |
Â
* Only Soap exceptions are caught. Other exceptions must be caught by the caller
|
357 |
+
*
|
358 |
+
* @throws TIG_PostNL_Exception
|
359 |
Â
*/
|
360 |
Â
$this->_handleCifException($e, $client);
|
361 |
Â
}
|
362 |
+
|
363 |
+
return false;
|
364 |
Â
}
|
365 |
Â
|
366 |
Â
/**
|
367 |
+
* Returns the URL of the chosen wsdl file based on a wsdl type.
|
368 |
+
*
|
369 |
+
* Available types are:
|
370 |
Â
* - barcode
|
371 |
Â
* - confirming
|
372 |
Â
* - labelling
|
373 |
Â
* - shippingstatus
|
374 |
Â
* - checkout
|
375 |
+
* - deliverydate
|
376 |
+
* - timeframe
|
377 |
+
* - location
|
378 |
+
*
|
379 |
Â
* @param string $wsdlType
|
380 |
+
*
|
381 |
Â
* @return string
|
382 |
+
*
|
383 |
Â
* @throws TIG_PostNL_Exception
|
384 |
Â
*/
|
385 |
Â
protected function _getWsdl($wsdlType)
|
386 |
Â
{
|
387 |
Â
$adminStoreId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
388 |
+
|
389 |
Â
/**
|
390 |
Â
* Check which wsdl file we need for each wsdl type
|
391 |
Â
* Als get the wsdl version to get
|
393 |
Â
$wsdlType = strtolower($wsdlType);
|
394 |
Â
switch ($wsdlType) {
|
395 |
Â
case 'barcode':
|
396 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_BARCODE, $adminStoreId);
|
397 |
Â
$wsdlFileName = self::WSDL_BARCODE_NAME;
|
398 |
Â
break;
|
399 |
Â
case 'confirming':
|
400 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_CONFIRMING, $adminStoreId);
|
401 |
Â
$wsdlFileName = self::WSDL_CONFIRMING_NAME;
|
402 |
Â
break;
|
403 |
Â
case 'labelling':
|
404 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_LABELLING, $adminStoreId);
|
405 |
Â
$wsdlFileName = self::WSDL_LABELLING_NAME;
|
406 |
Â
break;
|
407 |
Â
case 'shippingstatus':
|
408 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_SHIPPINGSTATUS, $adminStoreId);
|
409 |
+
$wsdlFileName = self::WSDL_SHIPPINGSTATUS_NAME;
|
410 |
Â
break;
|
411 |
Â
case 'checkout':
|
412 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_CHECKOUT, $adminStoreId);
|
413 |
Â
$wsdlFileName = self::WSDL_CHECKOUT_NAME;
|
414 |
Â
break;
|
415 |
+
case 'deliverydate':
|
416 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_DELIVERYDATE, $adminStoreId);
|
417 |
+
$wsdlFileName = self::WSDL_DELIVERYDATE_NAME;
|
418 |
+
break;
|
419 |
+
case 'timeframe':
|
420 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_TIMEFRAME, $adminStoreId);
|
421 |
+
$wsdlFileName = self::WSDL_TIMEFRAME_NAME;
|
422 |
+
break;
|
423 |
+
case 'location':
|
424 |
+
$wsdlversion = Mage::getStoreConfig(self::XPATH_CIF_VERSION_LOCATION, $adminStoreId);
|
425 |
+
$wsdlFileName = self::WSDL_LOCATION_NAME;
|
426 |
+
break;
|
427 |
Â
default:
|
428 |
Â
throw new TIG_PostNL_Exception(
|
429 |
Â
Mage::helper('postnl')->__('Chosen wsdl type is not supported: %s', $wsdlType),
|
430 |
Â
'POSTNL-0053'
|
431 |
Â
);
|
432 |
Â
}
|
433 |
+
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
434 |
Â
/**
|
435 |
Â
* Check if we need the live or the sandbox wsdl
|
436 |
Â
*/
|
439 |
Â
} else {
|
440 |
Â
$wsdlUrl = self::WSDL_BASE_URL;
|
441 |
Â
}
|
442 |
+
|
443 |
Â
/**
|
444 |
Â
* Format the final wsdl URL
|
445 |
Â
*/
|
446 |
Â
$wsdlUrl .= $wsdlFileName
|
447 |
+
. '/'
|
448 |
+
. $wsdlversion
|
449 |
+
. '/?wsdl';
|
450 |
+
|
451 |
Â
return $wsdlUrl;
|
452 |
Â
}
|
453 |
+
|
454 |
Â
/**
|
455 |
+
* Builds soap headers array for CIF authentication.
|
456 |
+
*
|
457 |
+
* @return SOAPHeader
|
Â
|
|
Â
|
|
Â
|
|
458 |
Â
*/
|
459 |
+
protected function _getSoapHeader()
|
460 |
Â
{
|
461 |
+
$username = $this->getUserName();
|
462 |
+
$password = $this->getPassWord();
|
463 |
+
|
Â
|
|
Â
|
|
464 |
Â
$namespace = self::HEADER_SECURITY_NAMESPACE;
|
465 |
+
$node1 = new SoapVar($username, XSD_STRING, null, null, 'Username', $namespace);
|
466 |
+
$node2 = new SoapVar($password, XSD_STRING, null, null, 'Password', $namespace);
|
467 |
+
|
468 |
Â
$token = new SoapVar(array($node1, $node2), SOAP_ENC_OBJECT, null, null, 'UsernameToken', $namespace);
|
469 |
+
|
470 |
+
$security = new SoapVar(array($token), SOAP_ENC_OBJECT, null, null, 'Security', $namespace);
|
471 |
+
|
472 |
+
$header = new SOAPHeader($namespace, 'Security', $security, false);
|
473 |
+
|
474 |
Â
return $header;
|
475 |
Â
}
|
476 |
+
|
477 |
Â
/**
|
478 |
Â
* Check if warnings occurred while processing the CIF request. If so, parse and register them
|
479 |
+
*
|
480 |
+
* @param Zend_Soap_Client $client
|
481 |
+
*
|
482 |
Â
* @return TIG_PostNL_Model_Core_Cif_Abstract
|
483 |
Â
*/
|
484 |
Â
protected function _processWarnings($client)
|
486 |
Â
$responseXML = $client->getLastResponse();
|
487 |
Â
$responseDOMDoc = new DOMDocument();
|
488 |
Â
$responseDOMDoc->loadXML($responseXML);
|
489 |
+
|
490 |
Â
/**
|
491 |
+
* Search the CIF response for warnings.
|
492 |
Â
*/
|
493 |
Â
$warnings = $responseDOMDoc->getElementsByTagName('Warning');
|
494 |
+
|
495 |
Â
if (!$warnings || $warnings->length < 1) {
|
496 |
Â
return $this;
|
497 |
Â
}
|
498 |
+
|
499 |
Â
/**
|
500 |
+
* Add all warning codes and descriptions to an array.
|
501 |
+
*
|
502 |
+
* @var DOMDocument $warning
|
503 |
Â
*/
|
504 |
Â
$n = 0;
|
505 |
Â
$responseWarnings = array();
|
512 |
Â
}
|
513 |
Â
$n++;
|
514 |
Â
}
|
515 |
+
|
516 |
Â
/**
|
517 |
+
* Check if old warnings are still present in the registry. If so, merge these with the new warnings.
|
518 |
Â
*/
|
519 |
Â
if (Mage::registry('postnl_cif_warnings') !== null) {
|
520 |
Â
$existingWarnings = (array) Mage::registry('postnl_cif_warnings');
|
521 |
Â
$responseWarnings = array_merge($responseWarnings, $existingWarnings);
|
522 |
+
|
523 |
Â
/**
|
524 |
Â
* Remove the old warnings from the registry
|
525 |
Â
*/
|
526 |
+
Mage::unregister('postnl_cif_warnings');
|
527 |
Â
}
|
528 |
+
|
529 |
Â
/**
|
530 |
Â
* Register the warnings
|
531 |
Â
*/
|
532 |
Â
Mage::register('postnl_cif_warnings', $responseWarnings);
|
533 |
+
|
534 |
Â
return $this;
|
535 |
Â
}
|
536 |
+
|
537 |
Â
/**
|
538 |
+
* Handle a SoapFault thrown by CIF.
|
539 |
+
*
|
540 |
+
* @param SoapFault $e
|
541 |
+
* @param Zend_Soap_Client $client
|
542 |
+
*
|
543 |
Â
* @throws TIG_PostNL_Model_Core_Cif_Exception
|
544 |
Â
*/
|
545 |
+
protected function _handleCifException(SoapFault $e, $client = null)
|
546 |
Â
{
|
547 |
Â
$cifHelper = Mage::helper('postnl/cif');
|
548 |
+
$exception = new TIG_PostNL_Model_Core_Cif_Exception($e->getMessage(), null, $e);
|
549 |
+
|
550 |
+
$requestXML = '';
|
551 |
+
$responseXML = '';
|
552 |
+
|
553 |
Â
/**
|
554 |
Â
* Get the request and response XML data
|
555 |
Â
*/
|
557 |
Â
$requestXML = $cifHelper->formatXml($client->getLastRequest());
|
558 |
Â
$responseXML = $cifHelper->formatXml($client->getLastResponse());
|
559 |
Â
}
|
560 |
+
|
561 |
+
/**
|
562 |
+
* If we got a response, parse it for specific error messages and add these to the exception.
|
563 |
+
*/
|
564 |
+
if (!empty($responseXML)) {
|
565 |
Â
/**
|
566 |
Â
* If we received a response, parse it for errors and create an appropriate exception
|
567 |
Â
*/
|
568 |
Â
$errorResponse = new DOMDocument();
|
569 |
Â
$errorResponse->loadXML($responseXML);
|
570 |
+
|
571 |
+
/**
|
572 |
+
* Get all error messages.
|
573 |
+
*/
|
574 |
Â
$errors = $errorResponse->getElementsByTagNameNS(self::CIF_ERROR_NAMESPACE, 'ErrorMsg');
|
575 |
Â
if ($errors) {
|
576 |
Â
$message = '';
|
577 |
Â
foreach($errors as $error) {
|
578 |
Â
$message .= $error->nodeValue . PHP_EOL;
|
579 |
Â
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Update the exception.
|
583 |
+
*/
|
584 |
+
$exception->setMessage($message);
|
585 |
Â
}
|
586 |
+
|
587 |
+
/**
|
588 |
+
* Parse any CIF error numbers we may have received.
|
589 |
+
*/
|
590 |
Â
$errorNumbers = $errorResponse->getElementsByTagNameNS(self::CIF_ERROR_NAMESPACE, 'ErrorNumber');
|
591 |
+
if ($errorNumbers) {
|
592 |
Â
foreach ($errorNumbers as $errorNumber) {
|
593 |
Â
$exception->addErrorNumber($errorNumber->nodeValue);
|
594 |
Â
}
|
595 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
596 |
Â
}
|
597 |
+
|
598 |
Â
/**
|
599 |
Â
* Add the response and request data to the exception (to be logged later)
|
600 |
Â
*/
|
601 |
+
if (!empty($requestXML) || !empty($responseXML)) {
|
602 |
Â
$exception->setRequestXml($requestXML)
|
603 |
Â
->setResponseXml($responseXML);
|
604 |
Â
}
|
605 |
+
|
606 |
Â
/**
|
607 |
Â
* Log the exception and throw it
|
608 |
+
*/
|
609 |
Â
$cifHelper->logCifException($exception);
|
610 |
+
|
611 |
Â
throw $exception;
|
612 |
Â
}
|
613 |
Â
}
|
@@ -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,120 +36,123 @@
|
|
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 |
Â
* Custom Exception class for CIF exceptions
|
42 |
-
*
|
43 |
Â
* @see TIG_PostNL_Exception
|
44 |
Â
* @see Mage_Core_Exception
|
45 |
-
*
|
46 |
Â
* @link http://php.net/manual/en/language.exceptions.extending.php
|
47 |
Â
*/
|
48 |
Â
class TIG_PostNL_Model_Core_Cif_Exception extends TIG_PostNL_Exception
|
49 |
Â
{
|
50 |
Â
/**
|
51 |
Â
* XML sent to CIF by the extension
|
52 |
-
*
|
53 |
Â
* @var string The XML string sent to CIF
|
54 |
Â
*/
|
55 |
Â
protected $_requestXml;
|
56 |
-
|
57 |
Â
/**
|
58 |
Â
* XML received in response
|
59 |
-
*
|
60 |
Â
* @var string The XML string CIF returned
|
61 |
Â
*/
|
62 |
Â
protected $_responseXml;
|
63 |
-
|
64 |
Â
/**
|
65 |
Â
* Array of error numbers
|
66 |
-
*
|
67 |
Â
* @var array
|
68 |
Â
*/
|
69 |
Â
protected $_errorNumbers = array();
|
70 |
-
|
71 |
Â
/**
|
72 |
Â
* Set $_requestXml to specified value
|
73 |
-
*
|
Â
|
|
Â
|
|
74 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
75 |
Â
*/
|
76 |
Â
public function setRequestXml($xml)
|
77 |
Â
{
|
78 |
Â
$this->_requestXml = $xml;
|
79 |
-
|
80 |
Â
return $this;
|
81 |
Â
}
|
82 |
-
|
83 |
Â
/**
|
84 |
Â
* Set $_responseXml to specified value
|
85 |
-
*
|
Â
|
|
86 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
87 |
Â
*/
|
88 |
Â
public function setResponseXml($xml)
|
89 |
Â
{
|
90 |
Â
$this->_responseXml = $xml;
|
91 |
-
|
92 |
Â
return $this;
|
93 |
Â
}
|
94 |
-
|
95 |
Â
/**
|
96 |
Â
* Set the error numbers array
|
97 |
-
*
|
98 |
Â
* @param array $errorNumbers
|
99 |
-
*
|
100 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
101 |
Â
*/
|
102 |
Â
public function setErrorNumbers($errorNumbers)
|
103 |
Â
{
|
104 |
Â
$this->_errorNumbers = $errorNumbers;
|
105 |
-
|
106 |
Â
return $this;
|
107 |
Â
}
|
108 |
-
|
109 |
Â
/**
|
110 |
Â
* Get $_requestXml
|
111 |
-
*
|
112 |
Â
* @return string
|
113 |
Â
*/
|
114 |
Â
public function getRequestXml()
|
115 |
Â
{
|
116 |
Â
return $this->_requestXml;
|
117 |
Â
}
|
118 |
-
|
119 |
Â
/**
|
120 |
Â
* Get $_responseXml
|
121 |
-
*
|
122 |
Â
* @return string
|
123 |
Â
*/
|
124 |
Â
public function getResponseXml()
|
125 |
Â
{
|
126 |
Â
return $this->_responseXml;
|
127 |
Â
}
|
128 |
-
|
129 |
Â
/**
|
130 |
Â
* get the error numbers array
|
131 |
-
*
|
132 |
Â
* @return array
|
133 |
Â
*/
|
134 |
Â
public function getErrorNumbers()
|
135 |
Â
{
|
136 |
Â
return $this->_errorNumbers;
|
137 |
Â
}
|
138 |
-
|
139 |
Â
/**
|
140 |
Â
* Add an error number to the error numbers array
|
141 |
-
*
|
142 |
Â
* @param int $errorNumber
|
143 |
-
*
|
144 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
145 |
Â
*/
|
146 |
Â
public function addErrorNumber($errorNumber)
|
147 |
Â
{
|
148 |
Â
$errorNumbers = $this->getErrorNumbers();
|
149 |
Â
$errorNumbers[] = $errorNumber;
|
150 |
-
|
151 |
Â
$this->setErrorNumbers($errorNumbers);
|
152 |
-
|
153 |
Â
return $this;
|
154 |
Â
}
|
155 |
Â
}
|
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 |
Â
* Custom Exception class for CIF exceptions
|
42 |
+
*
|
43 |
Â
* @see TIG_PostNL_Exception
|
44 |
Â
* @see Mage_Core_Exception
|
45 |
+
*
|
46 |
Â
* @link http://php.net/manual/en/language.exceptions.extending.php
|
47 |
Â
*/
|
48 |
Â
class TIG_PostNL_Model_Core_Cif_Exception extends TIG_PostNL_Exception
|
49 |
Â
{
|
50 |
Â
/**
|
51 |
Â
* XML sent to CIF by the extension
|
52 |
+
*
|
53 |
Â
* @var string The XML string sent to CIF
|
54 |
Â
*/
|
55 |
Â
protected $_requestXml;
|
56 |
+
|
57 |
Â
/**
|
58 |
Â
* XML received in response
|
59 |
+
*
|
60 |
Â
* @var string The XML string CIF returned
|
61 |
Â
*/
|
62 |
Â
protected $_responseXml;
|
63 |
+
|
64 |
Â
/**
|
65 |
Â
* Array of error numbers
|
66 |
+
*
|
67 |
Â
* @var array
|
68 |
Â
*/
|
69 |
Â
protected $_errorNumbers = array();
|
70 |
+
|
71 |
Â
/**
|
72 |
Â
* Set $_requestXml to specified value
|
73 |
+
*
|
74 |
+
* @param $xml
|
75 |
+
*
|
76 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
77 |
Â
*/
|
78 |
Â
public function setRequestXml($xml)
|
79 |
Â
{
|
80 |
Â
$this->_requestXml = $xml;
|
81 |
+
|
82 |
Â
return $this;
|
83 |
Â
}
|
84 |
+
|
85 |
Â
/**
|
86 |
Â
* Set $_responseXml to specified value
|
87 |
+
*
|
88 |
+
* @param $xml
|
89 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
90 |
Â
*/
|
91 |
Â
public function setResponseXml($xml)
|
92 |
Â
{
|
93 |
Â
$this->_responseXml = $xml;
|
94 |
+
|
95 |
Â
return $this;
|
96 |
Â
}
|
97 |
+
|
98 |
Â
/**
|
99 |
Â
* Set the error numbers array
|
100 |
+
*
|
101 |
Â
* @param array $errorNumbers
|
102 |
+
*
|
103 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
104 |
Â
*/
|
105 |
Â
public function setErrorNumbers($errorNumbers)
|
106 |
Â
{
|
107 |
Â
$this->_errorNumbers = $errorNumbers;
|
108 |
+
|
109 |
Â
return $this;
|
110 |
Â
}
|
111 |
+
|
112 |
Â
/**
|
113 |
Â
* Get $_requestXml
|
114 |
+
*
|
115 |
Â
* @return string
|
116 |
Â
*/
|
117 |
Â
public function getRequestXml()
|
118 |
Â
{
|
119 |
Â
return $this->_requestXml;
|
120 |
Â
}
|
121 |
+
|
122 |
Â
/**
|
123 |
Â
* Get $_responseXml
|
124 |
+
*
|
125 |
Â
* @return string
|
126 |
Â
*/
|
127 |
Â
public function getResponseXml()
|
128 |
Â
{
|
129 |
Â
return $this->_responseXml;
|
130 |
Â
}
|
131 |
+
|
132 |
Â
/**
|
133 |
Â
* get the error numbers array
|
134 |
+
*
|
135 |
Â
* @return array
|
136 |
Â
*/
|
137 |
Â
public function getErrorNumbers()
|
138 |
Â
{
|
139 |
Â
return $this->_errorNumbers;
|
140 |
Â
}
|
141 |
+
|
142 |
Â
/**
|
143 |
Â
* Add an error number to the error numbers array
|
144 |
+
*
|
145 |
Â
* @param int $errorNumber
|
146 |
+
*
|
147 |
Â
* @return TIG_PostNL_Model_Core_Cif_Exception
|
148 |
Â
*/
|
149 |
Â
public function addErrorNumber($errorNumber)
|
150 |
Â
{
|
151 |
Â
$errorNumbers = $this->getErrorNumbers();
|
152 |
Â
$errorNumbers[] = $errorNumber;
|
153 |
+
|
154 |
Â
$this->setErrorNumbers($errorNumbers);
|
155 |
+
|
156 |
Â
return $this;
|
157 |
Â
}
|
158 |
Â
}
|
@@ -33,8 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Label extends Varien_Object
|
40 |
Â
{
|
@@ -64,6 +66,33 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
64 |
Â
*/
|
65 |
Â
protected $_labelCounter = null;
|
66 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
/**
|
68 |
Â
* Get the array of saved temporary labels
|
69 |
Â
*
|
@@ -125,7 +154,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
125 |
Â
|
126 |
Â
$labelSize = Mage::getStoreConfig(self::XML_PATH_LABEL_SIZE, Mage_Core_Model_App::ADMIN_STORE_ID);
|
127 |
Â
|
128 |
-
$this->
|
129 |
Â
return $labelSize;
|
130 |
Â
}
|
131 |
Â
|
@@ -229,12 +258,13 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
229 |
Â
$this->_destroyTempLabels();
|
230 |
Â
|
231 |
Â
/**
|
232 |
-
*
|
233 |
Â
*/
|
234 |
-
$pdf->Output('PostNL Shipping Labels.pdf', '
|
235 |
Â
|
236 |
Â
Varien_Profiler::stop('tig::postnl::core::label_createpdf');
|
237 |
-
|
Â
|
|
238 |
Â
}
|
239 |
Â
|
240 |
Â
/**
|
@@ -268,6 +298,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
268 |
Â
);
|
269 |
Â
}
|
270 |
Â
|
Â
|
|
271 |
Â
$labels = $this->_sortLabels($labels);
|
272 |
Â
foreach ($labels as $label) {
|
273 |
Â
$pdf = $this->_addPdfTemplate($pdf, $label);
|
@@ -279,9 +310,10 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
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
|
283 |
-
* @param
|
284 |
-
*
|
Â
|
|
285 |
Â
*
|
286 |
Â
* @return TIG_PostNL_Fpdi $pdf
|
287 |
Â
*/
|
@@ -293,6 +325,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
293 |
Â
$tempFilename = $this->_saveTempLabel($label->getLabel());
|
294 |
Â
|
295 |
Â
switch ($label->getLabelType()) {
|
Â
|
|
296 |
Â
case 'Label-combi':
|
297 |
Â
$this->_convertTempLabelToCombi($tempFilename); //NO BREAK
|
298 |
Â
case 'Label':
|
@@ -304,34 +337,9 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
304 |
Â
) {
|
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 |
-
*/
|
312 |
-
if($this->getLabelSize() == 'A6') {
|
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 |
-
*/
|
330 |
-
if ($this->getLabelSize() == 'A4'
|
331 |
-
&& (!$this->getLabelCounter() || $this->getLabelCounter() > 4)
|
332 |
-
) {
|
333 |
Â
$pdf->addOrientedPage('L', 'A4');
|
334 |
-
$this->
|
335 |
Â
}
|
336 |
Â
|
337 |
Â
/**
|
@@ -426,6 +434,8 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
426 |
Â
*
|
427 |
Â
* @param string $label
|
428 |
Â
*
|
Â
|
|
Â
|
|
429 |
Â
* @return string
|
430 |
Â
*/
|
431 |
Â
protected function _saveTempLabel($label)
|
@@ -489,8 +499,12 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
489 |
Â
protected function _sortLabels($labels)
|
490 |
Â
{
|
491 |
Â
$generalLabels = array();
|
492 |
-
$globalLabels
|
493 |
-
$codCards
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
494 |
Â
foreach ($labels as $label) {
|
495 |
Â
/**
|
496 |
Â
* Seperate general labels from the rest
|
@@ -591,11 +605,12 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
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 |
Â
{
|
@@ -631,7 +646,7 @@ class TIG_PostNL_Model_Core_Label extends Varien_Object
|
|
631 |
Â
/**
|
632 |
Â
* Converts pixels to points. 3.8 pixels is 1 pt in pdfs
|
633 |
Â
*
|
634 |
-
* @param
|
635 |
Â
*
|
636 |
Â
* @return int
|
637 |
Â
*/
|
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 |
+
* @method TIG_PostNL_Model_Core_Label setLabelSize(string $value)
|
40 |
Â
*/
|
41 |
Â
class TIG_PostNL_Model_Core_Label extends Varien_Object
|
42 |
Â
{
|
66 |
Â
*/
|
67 |
Â
protected $_labelCounter = null;
|
68 |
Â
|
69 |
+
/**
|
70 |
+
* Flag if the current label is the first of a set of labels.
|
71 |
+
*
|
72 |
+
* @var bool
|
73 |
+
*/
|
74 |
+
protected $_isFirstLabel = false;
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @param boolean $isFirstLabel
|
78 |
+
*
|
79 |
+
* @return TIG_PostNL_Model_Core_Label
|
80 |
+
*/
|
81 |
+
public function setIsFirstLabel($isFirstLabel)
|
82 |
+
{
|
83 |
+
$this->_isFirstLabel = $isFirstLabel;
|
84 |
+
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @return boolean
|
90 |
+
*/
|
91 |
+
public function getIsFirstLabel()
|
92 |
+
{
|
93 |
+
return $this->_isFirstLabel;
|
94 |
+
}
|
95 |
+
|
96 |
Â
/**
|
97 |
Â
* Get the array of saved temporary labels
|
98 |
Â
*
|
154 |
Â
|
155 |
Â
$labelSize = Mage::getStoreConfig(self::XML_PATH_LABEL_SIZE, Mage_Core_Model_App::ADMIN_STORE_ID);
|
156 |
Â
|
157 |
+
$this->setLabelSize($labelSize);
|
158 |
Â
return $labelSize;
|
159 |
Â
}
|
160 |
Â
|
258 |
Â
$this->_destroyTempLabels();
|
259 |
Â
|
260 |
Â
/**
|
261 |
+
* Get the final label.
|
262 |
Â
*/
|
263 |
+
$label = $pdf->Output('PostNL Shipping Labels.pdf', 'I');
|
264 |
Â
|
265 |
Â
Varien_Profiler::stop('tig::postnl::core::label_createpdf');
|
266 |
+
|
267 |
+
return $label;
|
268 |
Â
}
|
269 |
Â
|
270 |
Â
/**
|
298 |
Â
);
|
299 |
Â
}
|
300 |
Â
|
301 |
+
$this->setIsFirstLabel(true);
|
302 |
Â
$labels = $this->_sortLabels($labels);
|
303 |
Â
foreach ($labels as $label) {
|
304 |
Â
$pdf = $this->_addPdfTemplate($pdf, $label);
|
310 |
Â
/**
|
311 |
Â
* Adds a lebl to the pdf by storing it in a temporary pdf file and then adding it to the master pdf object
|
312 |
Â
*
|
313 |
+
* @param TIG_PostNL_Fpdi $pdf
|
314 |
+
* @param TIG_PostNL_Model_Core_Shipment_Label $label
|
315 |
+
*
|
316 |
+
* @throws TIG_PostNL_Exception
|
317 |
Â
*
|
318 |
Â
* @return TIG_PostNL_Fpdi $pdf
|
319 |
Â
*/
|
325 |
Â
$tempFilename = $this->_saveTempLabel($label->getLabel());
|
326 |
Â
|
327 |
Â
switch ($label->getLabelType()) {
|
328 |
+
/** @noinspection PhpMissingBreakStatementInspection */
|
329 |
Â
case 'Label-combi':
|
330 |
Â
$this->_convertTempLabelToCombi($tempFilename); //NO BREAK
|
331 |
Â
case 'Label':
|
337 |
Â
) {
|
338 |
Â
$pdf->addOrientedPage('L', 'A4');
|
339 |
Â
$this->resetLabelCounter();
|
340 |
+
} elseif ($this->getLabelSize() == 'A4' && $this->getIsFirstLabel()) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
341 |
Â
$pdf->addOrientedPage('L', 'A4');
|
342 |
+
$this->setIsFirstLabel(false);
|
343 |
Â
}
|
344 |
Â
|
345 |
Â
/**
|
434 |
Â
*
|
435 |
Â
* @param string $label
|
436 |
Â
*
|
437 |
+
* @throws TIG_PostNL_Exception
|
438 |
+
*
|
439 |
Â
* @return string
|
440 |
Â
*/
|
441 |
Â
protected function _saveTempLabel($label)
|
499 |
Â
protected function _sortLabels($labels)
|
500 |
Â
{
|
501 |
Â
$generalLabels = array();
|
502 |
+
$globalLabels = array();
|
503 |
+
$codCards = array();
|
504 |
+
|
505 |
+
/**
|
506 |
+
* @var TIG_PostNL_Model_Core_Shipment_Label $label
|
507 |
+
*/
|
508 |
Â
foreach ($labels as $label) {
|
509 |
Â
/**
|
510 |
Â
* Seperate general labels from the rest
|
605 |
Â
* third: bottom left
|
606 |
Â
* fourth: bottom right
|
607 |
Â
*
|
608 |
+
* @param bool|int $counter
|
609 |
+
*
|
610 |
+
* @throws TIG_PostNL_Exception
|
611 |
Â
*
|
612 |
Â
* @return array
|
613 |
Â
*
|
Â
|
|
614 |
Â
*/
|
615 |
Â
protected function _getPosition($counter = false)
|
616 |
Â
{
|
646 |
Â
/**
|
647 |
Â
* Converts pixels to points. 3.8 pixels is 1 pt in pdfs
|
648 |
Â
*
|
649 |
+
* @param int $pixels
|
650 |
Â
*
|
651 |
Â
* @return int
|
652 |
Â
*/
|
@@ -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.
|
@@ -33,23 +33,21 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Observer_Barcode
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Generates a barcode for the shipment if it is new
|
43 |
-
*
|
44 |
Â
* @param Varien_Event_Observer $observer
|
45 |
-
*
|
46 |
Â
* @return TIG_PostNL_Model_Core_Observer_Barcode
|
47 |
-
*
|
48 |
Â
* @event sales_order_shipment_save_after
|
49 |
-
*
|
50 |
Â
* @observer postnl_shipment_generate_barcode
|
51 |
-
*
|
52 |
-
* @todo change confirm date to the correct value, taking into account 'ordered before X, delivered on Y' settings
|
53 |
Â
*/
|
54 |
Â
public function generateBarcode(Varien_Event_Observer $observer)
|
55 |
Â
{
|
@@ -59,56 +57,83 @@ class TIG_PostNL_Model_Core_Observer_Barcode
|
|
59 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
60 |
Â
return $this;
|
61 |
Â
}
|
62 |
-
|
Â
|
|
Â
|
|
Â
|
|
63 |
Â
$shipment = $observer->getShipment();
|
64 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
65 |
Â
/**
|
66 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
*/
|
68 |
Â
if (Mage::helper('postnl/cif')->postnlShipmentExists($shipment->getId())) {
|
69 |
Â
return $this;
|
70 |
Â
}
|
71 |
-
|
72 |
Â
/**
|
73 |
-
*
|
74 |
Â
*/
|
75 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
76 |
-
$postnlShipment->setShipmentId($shipment->getId())
|
77 |
-
|
78 |
-
|
79 |
Â
/**
|
80 |
Â
* Check if this shipment has an associated PostNL Order. If so, copy it's data.
|
Â
|
|
Â
|
|
81 |
Â
*/
|
82 |
-
$postnlOrder = Mage::getModel('
|
Â
|
|
83 |
Â
if ($postnlOrder->getId()) {
|
84 |
Â
if ($postnlOrder->getConfirmDate()) {
|
85 |
Â
$postnlShipment->setConfirmDate(strtotime($postnlOrder->getConfirmDate()));
|
86 |
Â
}
|
87 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
88 |
Â
if ($postnlOrder->getIsPakjeGemak()) {
|
89 |
Â
$postnlShipment->setIsPakjeGemak($postnlOrder->getIsPakjeGemak());
|
90 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
91 |
Â
}
|
92 |
-
|
93 |
Â
/**
|
94 |
-
* We need an ID in order to save the barcodes
|
95 |
Â
*/
|
96 |
Â
$postnlShipment->save();
|
97 |
-
|
98 |
Â
/**
|
99 |
Â
* Barcode generation needs to be tried seperately. This functionality may throw a valid exception
|
100 |
Â
* in which case it needs to be tried again later without preventing the shipment from being
|
101 |
Â
* created. This may happen when CIF is overburdoned.
|
102 |
-
*/
|
103 |
Â
try {
|
104 |
Â
$postnlShipment->saveAdditionalShippingOptions()
|
105 |
Â
->generateBarcodes();
|
106 |
Â
} catch (Exception $e) {
|
107 |
Â
Mage::helper('postnl')->logException($e);
|
108 |
Â
}
|
109 |
-
|
110 |
Â
$postnlShipment->save();
|
111 |
-
|
112 |
Â
return $this;
|
113 |
Â
}
|
114 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Core_Observer_Barcode
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Generates a barcode for the shipment if it is new
|
43 |
+
*
|
44 |
Â
* @param Varien_Event_Observer $observer
|
45 |
+
*
|
46 |
Â
* @return TIG_PostNL_Model_Core_Observer_Barcode
|
47 |
+
*
|
48 |
Â
* @event sales_order_shipment_save_after
|
49 |
+
*
|
50 |
Â
* @observer postnl_shipment_generate_barcode
|
Â
|
|
Â
|
|
51 |
Â
*/
|
52 |
Â
public function generateBarcode(Varien_Event_Observer $observer)
|
53 |
Â
{
|
57 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
58 |
Â
return $this;
|
59 |
Â
}
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @var Mage_Sales_Model_Order_Shipment $shipment
|
63 |
+
*/
|
64 |
Â
$shipment = $observer->getShipment();
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Check if this shipment was placed using PostNL.
|
68 |
+
*/
|
69 |
+
$postnlShippingMethods = Mage::helper('postnl/carrier')->getPostnlShippingMethods();
|
70 |
+
$shippingMethod = $shipment->getOrder()->getShippingMethod();
|
71 |
+
|
72 |
Â
/**
|
73 |
+
* If this shipment's order was not placed with PostNL, remove any PakjeGemak addresses that may have been
|
74 |
+
* saved.
|
75 |
+
*/
|
76 |
+
if (!in_array($shippingMethod, $postnlShippingMethods)) {
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Check if a postnl shipment exists for this shipment.
|
82 |
Â
*/
|
83 |
Â
if (Mage::helper('postnl/cif')->postnlShipmentExists($shipment->getId())) {
|
84 |
Â
return $this;
|
85 |
Â
}
|
86 |
+
|
87 |
Â
/**
|
88 |
+
* Create a new postnl shipment entity.
|
89 |
Â
*/
|
90 |
Â
$postnlShipment = Mage::getModel('postnl_core/shipment');
|
91 |
+
$postnlShipment->setShipmentId($shipment->getId());
|
92 |
+
|
Â
|
|
93 |
Â
/**
|
94 |
Â
* Check if this shipment has an associated PostNL Order. If so, copy it's data.
|
95 |
+
*
|
96 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
97 |
Â
*/
|
98 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($shipment->getOrderId(), 'order_id');
|
99 |
+
|
100 |
Â
if ($postnlOrder->getId()) {
|
101 |
Â
if ($postnlOrder->getConfirmDate()) {
|
102 |
Â
$postnlShipment->setConfirmDate(strtotime($postnlOrder->getConfirmDate()));
|
103 |
Â
}
|
104 |
+
|
105 |
+
if ($postnlOrder->getDeliveryDate()) {
|
106 |
+
$postnlShipment->setDeliveryDate(strtotime($postnlOrder->getDeliveryDate()));
|
107 |
+
}
|
108 |
+
|
109 |
Â
if ($postnlOrder->getIsPakjeGemak()) {
|
110 |
Â
$postnlShipment->setIsPakjeGemak($postnlOrder->getIsPakjeGemak());
|
111 |
Â
}
|
112 |
+
|
113 |
+
if ($postnlOrder->getIsPakketautomaat()) {
|
114 |
+
$postnlShipment->setIsPakketautomaat($postnlOrder->getIsPakketautomaat());
|
115 |
+
}
|
116 |
Â
}
|
117 |
+
|
118 |
Â
/**
|
119 |
+
* We need an ID in order to save the barcodes.
|
120 |
Â
*/
|
121 |
Â
$postnlShipment->save();
|
122 |
+
|
123 |
Â
/**
|
124 |
Â
* Barcode generation needs to be tried seperately. This functionality may throw a valid exception
|
125 |
Â
* in which case it needs to be tried again later without preventing the shipment from being
|
126 |
Â
* created. This may happen when CIF is overburdoned.
|
127 |
+
*/
|
128 |
Â
try {
|
129 |
Â
$postnlShipment->saveAdditionalShippingOptions()
|
130 |
Â
->generateBarcodes();
|
131 |
Â
} catch (Exception $e) {
|
132 |
Â
Mage::helper('postnl')->logException($e);
|
133 |
Â
}
|
134 |
+
|
135 |
Â
$postnlShipment->save();
|
136 |
+
|
137 |
Â
return $this;
|
138 |
Â
}
|
139 |
Â
}
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Observer_Cron
|
@@ -102,6 +102,8 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
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;
|
@@ -200,7 +202,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
200 |
Â
if ($files === false) {
|
201 |
Â
$helper->cronLog('Lock storage is unreadable. Exiting cron.');
|
202 |
Â
throw new TIG_PostNL_Exception(
|
203 |
-
$helper->__('Unable to read directory: %s', $
|
204 |
Â
'POSTNL-0096'
|
205 |
Â
);
|
206 |
Â
}
|
@@ -280,13 +282,13 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
280 |
Â
|
281 |
Â
$helper->cronLog("Getting barcodes for {$postnlShipmentCollection->getSize()} shipments.");
|
282 |
Â
|
283 |
-
$
|
284 |
Â
foreach ($postnlShipmentCollection as $postnlShipment) {
|
285 |
Â
/**
|
286 |
Â
* Process a maximum of 1000 shipments (to prevent Cif from being overburdoned).
|
287 |
Â
* Only successfull requests count towards this number
|
288 |
Â
*/
|
289 |
-
if ($
|
290 |
Â
break;
|
291 |
Â
}
|
292 |
Â
|
@@ -298,7 +300,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
298 |
Â
$postnlShipment->generateBarcodes()
|
299 |
Â
->save();
|
300 |
Â
|
301 |
-
$
|
302 |
Â
} catch (Exception $e) {
|
303 |
Â
Mage::helper('postnl')->logException($e);
|
304 |
Â
}
|
@@ -327,6 +329,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
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;
|
@@ -373,6 +378,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
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 |
Â
}
|
@@ -475,6 +481,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
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;
|
@@ -563,7 +572,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
563 |
Â
* Check each storeview if sending track & trace emails is allowed
|
564 |
Â
*/
|
565 |
Â
$allowedStoreIds = array();
|
566 |
-
foreach (Mage::app()->getStores() as $storeId
|
567 |
Â
if (Mage::getStoreConfig(self::XML_PATH_SEND_TRACK_AND_TRACE_EMAIL, $storeId)) {
|
568 |
Â
$allowedStoreIds[] = $storeId;
|
569 |
Â
}
|
@@ -574,6 +583,9 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
574 |
Â
return $this;
|
575 |
Â
}
|
576 |
Â
|
Â
|
|
Â
|
|
Â
|
|
577 |
Â
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
578 |
Â
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
579 |
Â
|
@@ -584,6 +596,29 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
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(
|
@@ -666,6 +701,8 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
666 |
Â
|
667 |
Â
/**
|
668 |
Â
* Get the PostNL Shipment classname for later use
|
Â
|
|
Â
|
|
669 |
Â
*/
|
670 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
671 |
Â
|
@@ -731,7 +768,7 @@ class TIG_PostNL_Model_Core_Observer_Cron
|
|
731 |
Â
*/
|
732 |
Â
foreach ($labelsCollection as $label) {
|
733 |
Â
$helper->cronLog("Deleting label #{$label->getId()}.");
|
734 |
-
$label->delete()
|
735 |
Â
}
|
736 |
Â
$helper->cronLog('RemoveOldLabels cron has finished.');
|
737 |
Â
|
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 |
Â
class TIG_PostNL_Model_Core_Observer_Cron
|
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 |
+
* @var $labelModel TIG_PostNL_Model_Core_Label
|
107 |
Â
*/
|
108 |
Â
$labelModel = Mage::app()->getConfig()->getModelClassName('postnl_core/label');
|
109 |
Â
$tempLabelName = $labelModel::TEMP_LABEL_FILENAME;
|
202 |
Â
if ($files === false) {
|
203 |
Â
$helper->cronLog('Lock storage is unreadable. Exiting cron.');
|
204 |
Â
throw new TIG_PostNL_Exception(
|
205 |
+
$helper->__('Unable to read directory: %s', $locksDirectory),
|
206 |
Â
'POSTNL-0096'
|
207 |
Â
);
|
208 |
Â
}
|
282 |
Â
|
283 |
Â
$helper->cronLog("Getting barcodes for {$postnlShipmentCollection->getSize()} shipments.");
|
284 |
Â
|
285 |
+
$counter = 1000;
|
286 |
Â
foreach ($postnlShipmentCollection as $postnlShipment) {
|
287 |
Â
/**
|
288 |
Â
* Process a maximum of 1000 shipments (to prevent Cif from being overburdoned).
|
289 |
Â
* Only successfull requests count towards this number
|
290 |
Â
*/
|
291 |
+
if ($counter < 1) {
|
292 |
Â
break;
|
293 |
Â
}
|
294 |
Â
|
300 |
Â
$postnlShipment->generateBarcodes()
|
301 |
Â
->save();
|
302 |
Â
|
303 |
+
$counter--;
|
304 |
Â
} catch (Exception $e) {
|
305 |
Â
Mage::helper('postnl')->logException($e);
|
306 |
Â
}
|
329 |
Â
|
330 |
Â
$helper->cronLog('UpdateShippingStatus cron starting...');
|
331 |
Â
|
332 |
+
/**
|
333 |
+
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
334 |
+
*/
|
335 |
Â
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
336 |
Â
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
337 |
Â
$deliveredStatus = $postnlShipmentModelClass::SHIPPING_PHASE_DELIVERED;
|
378 |
Â
$helper->cronLog("Updating shipping status for shipment #{$postnlShipment->getShipment()->getId()}");
|
379 |
Â
|
380 |
Â
if (!$postnlShipment->canUpdateShippingStatus()) {
|
381 |
+
$postnlShipment->unlock();
|
382 |
Â
$helper->cronLog("Updating shipment #{$postnlShipment->getShipment()->getId()} is not allowed. Continuing with next shipment.");
|
383 |
Â
continue;
|
384 |
Â
}
|
481 |
Â
|
482 |
Â
$helper->cronLog('ExpireConfirmation cron starting...');
|
483 |
Â
|
484 |
+
/**
|
485 |
+
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
486 |
+
*/
|
487 |
Â
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
488 |
Â
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
489 |
Â
$collectionPhase = $postnlShipmentModelClass::SHIPPING_PHASE_COLLECTION;
|
572 |
Â
* Check each storeview if sending track & trace emails is allowed
|
573 |
Â
*/
|
574 |
Â
$allowedStoreIds = array();
|
575 |
+
foreach (array_keys(Mage::app()->getStores()) as $storeId) {
|
576 |
Â
if (Mage::getStoreConfig(self::XML_PATH_SEND_TRACK_AND_TRACE_EMAIL, $storeId)) {
|
577 |
Â
$allowedStoreIds[] = $storeId;
|
578 |
Â
}
|
583 |
Â
return $this;
|
584 |
Â
}
|
585 |
Â
|
586 |
+
/**
|
587 |
+
* @var $postnlShipmentModelClass TIG_PostNL_Model_Core_Shipment
|
588 |
+
*/
|
589 |
Â
$postnlShipmentModelClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
590 |
Â
$confirmedStatus = $postnlShipmentModelClass::CONFIRM_STATUS_CONFIRMED;
|
591 |
Â
|
596 |
Â
|
597 |
Â
/**
|
598 |
Â
* Get all postnl shipments that have been confirmed over 20 minutes ago whose track & trace e-mail has not yet been sent
|
599 |
+
*
|
600 |
+
* Resulting SQL:
|
601 |
+
* SELECT `main_table` . *
|
602 |
+
* FROM `tig_postnl_shipment` AS `main_table`
|
603 |
+
* WHERE (
|
604 |
+
* confirm_status = '{$confirmedStatus}'
|
605 |
+
* )
|
606 |
+
* AND (
|
607 |
+
* labels_printed =1
|
608 |
+
* )
|
609 |
+
* AND (
|
610 |
+
* confirmed_at <= '{$twentyMinutesAgo}'
|
611 |
+
* )
|
612 |
+
* AND (
|
613 |
+
* (
|
614 |
+
* (
|
615 |
+
* track_and_trace_email_sent IS NULL
|
616 |
+
* )
|
617 |
+
* OR (
|
618 |
+
* track_and_trace_email_sent = '0'
|
619 |
+
* )
|
620 |
+
* )
|
621 |
+
* )
|
622 |
Â
*/
|
623 |
Â
$postnlShipmentCollection = Mage::getResourceModel('postnl_core/shipment_collection');
|
624 |
Â
$postnlShipmentCollection->addFieldToFilter(
|
701 |
Â
|
702 |
Â
/**
|
703 |
Â
* Get the PostNL Shipment classname for later use
|
704 |
+
*
|
705 |
+
* @var $postnlShipmentClass TIG_PostNL_Model_Core_Shipment
|
706 |
Â
*/
|
707 |
Â
$postnlShipmentClass = Mage::getConfig()->getModelClassName('postnl_core/shipment');
|
708 |
Â
|
768 |
Â
*/
|
769 |
Â
foreach ($labelsCollection as $label) {
|
770 |
Â
$helper->cronLog("Deleting label #{$label->getId()}.");
|
771 |
+
$label->delete();
|
772 |
Â
}
|
773 |
Â
$helper->cronLog('RemoveOldLabels cron has finished.');
|
774 |
Â
|
@@ -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.
|
@@ -33,20 +33,20 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Observer_SaveShipment
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Registers a chosen product option
|
43 |
-
*
|
44 |
Â
* @param Varien_Event_Observer $observer
|
45 |
-
*
|
46 |
-
* @return
|
47 |
-
*
|
48 |
Â
* @event controller_action_predispatch_adminhtml_sales_order_shipment_save
|
49 |
-
*
|
50 |
Â
* @observer postnl_core_shipment_save
|
51 |
Â
*/
|
52 |
Â
public function registerProductOption(Varien_Event_Observer $observer)
|
@@ -57,22 +57,24 @@ class TIG_PostNL_Model_Core_Observer_SaveShipment
|
|
57 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
58 |
Â
return $this;
|
59 |
Â
}
|
60 |
-
|
61 |
Â
/**
|
62 |
-
* retrieve and register the chosen option, if any
|
Â
|
|
Â
|
|
63 |
Â
*/
|
64 |
Â
$controller = $observer->getControllerAction();
|
65 |
Â
$productOption = $controller->getRequest()->getParam('postnl');
|
66 |
-
|
67 |
Â
if ($productOption && isset($productOption['product_option'])) {
|
68 |
Â
Mage::register('postnl_product_option', $productOption['product_option']);
|
69 |
Â
unset($productOption['product_option']);
|
70 |
Â
}
|
71 |
-
|
72 |
Â
if ($productOption && !empty($productOption)) {
|
73 |
Â
Mage::register('postnl_additional_options', $productOption);
|
74 |
Â
}
|
75 |
-
|
76 |
Â
return $this;
|
77 |
Â
}
|
78 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Core_Observer_SaveShipment
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Registers a chosen product option
|
43 |
+
*
|
44 |
Â
* @param Varien_Event_Observer $observer
|
45 |
+
*
|
46 |
+
* @return $this
|
47 |
+
*
|
48 |
Â
* @event controller_action_predispatch_adminhtml_sales_order_shipment_save
|
49 |
+
*
|
50 |
Â
* @observer postnl_core_shipment_save
|
51 |
Â
*/
|
52 |
Â
public function registerProductOption(Varien_Event_Observer $observer)
|
57 |
Â
if (!Mage::helper('postnl')->isEnabled()) {
|
58 |
Â
return $this;
|
59 |
Â
}
|
60 |
+
|
61 |
Â
/**
|
62 |
+
* retrieve and register the chosen option, if any.
|
63 |
+
*
|
64 |
+
* @var Mage_Core_Controller_Varien_Front $controller
|
65 |
Â
*/
|
66 |
Â
$controller = $observer->getControllerAction();
|
67 |
Â
$productOption = $controller->getRequest()->getParam('postnl');
|
68 |
+
|
69 |
Â
if ($productOption && isset($productOption['product_option'])) {
|
70 |
Â
Mage::register('postnl_product_option', $productOption['product_option']);
|
71 |
Â
unset($productOption['product_option']);
|
72 |
Â
}
|
73 |
+
|
74 |
Â
if ($productOption && !empty($productOption)) {
|
75 |
Â
Mage::register('postnl_additional_options', $productOption);
|
76 |
Â
}
|
77 |
+
|
78 |
Â
return $this;
|
79 |
Â
}
|
80 |
Â
}
|
@@ -0,0 +1,247 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* Class TIG_PostNL_Model_Core_Order
|
40 |
+
*
|
41 |
+
* @method string getConfirmDate()
|
42 |
+
* @method TIG_PostNL_Model_Core_Order setConfirmDate(string $value)
|
43 |
+
* @method int getIsActive()
|
44 |
+
* @method TIG_PostNL_Model_Core_Order setIsActive(int $value)
|
45 |
+
* @method string getToken()
|
46 |
+
* @method TIG_PostNL_Model_Core_Order setToken(string $value)
|
47 |
+
* @method string getShipmentCosts()
|
48 |
+
* @method TIG_PostNL_Model_Core_Order setShipmentCosts(string $value)
|
49 |
+
* @method string getProductCode()
|
50 |
+
* @method TIG_PostNL_Model_Core_Order setProductCode(string $value)
|
51 |
+
* @method int getIsPakjeGemak()
|
52 |
+
* @method TIG_PostNL_Model_Core_Order setIsPakjeGemak(int $value)
|
53 |
+
* @method int getIsCanceled()
|
54 |
+
* @method TIG_PostNL_Model_Core_Order setIsCanceled(int $value)
|
55 |
+
* @method string getDeliveryDate()
|
56 |
+
* @method TIG_PostNL_Model_Core_Order setDeliveryDate(string $value)
|
57 |
+
* @method int getQuoteId()
|
58 |
+
* @method TIG_PostNL_Model_Core_Order setQuoteId(int $value)
|
59 |
+
* @method string getType()
|
60 |
+
* @method TIG_PostNL_Model_Core_Order setType(string $value)
|
61 |
+
* @method int getOrderId()
|
62 |
+
* @method TIG_PostNL_Model_Core_Order setOrderId(int $value)
|
63 |
+
* @method int getEntityId()
|
64 |
+
* @method string getMobilePhoneNumber()
|
65 |
+
* @method TIG_PostNL_Model_Core_Order setEntityId(int $value)
|
66 |
+
* @method TIG_PostNL_Model_Core_Order setOrder(Mage_Sales_Model_Order $value)
|
67 |
+
* @method TIG_PostNL_Model_Core_Order setQuote(Mage_Sales_Model_Quote $value)
|
68 |
+
* @method int getIsPakketautomaat()
|
69 |
+
* @method TIG_PostNL_Model_Core_Order setIsPakketautomaat(int $value)
|
70 |
+
*/
|
71 |
+
class TIG_PostNL_Model_Core_Order extends Mage_Core_Model_Abstract
|
72 |
+
{
|
73 |
+
/**
|
74 |
+
* Regexes for mobile phone number validation.
|
75 |
+
*/
|
76 |
+
const MOBILE_PHONE_NUMBER_REGEX = '/^(((\+31|0|0031)6){1}[1-9]{1}[0-9]{7})$/i';
|
77 |
+
const MOBILE_PHONE_NUMBER_PREFIX_REGEX = '/^(06|00316){1}(.*?)$/i';
|
78 |
+
const MOBILE_PHONE_NUMBER_PREFIX_REPLACEMENT = '+316$2';
|
79 |
+
const MOBILE_PHONE_NUMBER_CONTENT_REGEX = '/[^0-9+]/';
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Prefix of model events names.
|
83 |
+
*
|
84 |
+
* @var string
|
85 |
+
*/
|
86 |
+
protected $_eventPrefix = 'postnl_order';
|
87 |
+
|
88 |
+
public function _construct()
|
89 |
+
{
|
90 |
+
$this->_init('postnl_core/order');
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Gets the order associated with this PostNL Checkout Order.
|
95 |
+
*
|
96 |
+
* @return Mage_Sales_Model_Order|null
|
97 |
+
*/
|
98 |
+
public function getOrder()
|
99 |
+
{
|
100 |
+
if ($this->getData('order')) {
|
101 |
+
return $this->getData('order');
|
102 |
+
}
|
103 |
+
|
104 |
+
if (!$this->getOrderId()) {
|
105 |
+
return null;
|
106 |
+
}
|
107 |
+
|
108 |
+
/**
|
109 |
+
* @var Mage_Sales_Model_Order $order
|
110 |
+
*/
|
111 |
+
$order = Mage::getModel('sales/order')->load($this->getOrderId());
|
112 |
+
|
113 |
+
$this->setOrder($order);
|
114 |
+
return $order;
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Gets the quote associated with this PostNL Checkout Order.
|
119 |
+
*
|
120 |
+
* @return Mage_Sales_Model_Quote|null
|
121 |
+
*/
|
122 |
+
public function getQuote()
|
123 |
+
{
|
124 |
+
if ($this->getData('quote')) {
|
125 |
+
return $this->getData('quote');
|
126 |
+
}
|
127 |
+
|
128 |
+
if (!$this->getQuoteId()) {
|
129 |
+
return null;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @var Mage_Sales_Model_Quote $quote
|
134 |
+
*/
|
135 |
+
$quote = Mage::getModel('sales/quote')->load($this->getQuoteId());
|
136 |
+
|
137 |
+
$this->setQuote($quote);
|
138 |
+
return $quote;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Alias for magic getToken().
|
143 |
+
*
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
public function getOrderToken()
|
147 |
+
{
|
148 |
+
return $this->getToken();
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Alias for magic getQuoteId().
|
153 |
+
*
|
154 |
+
* @return int
|
155 |
+
*/
|
156 |
+
public function getExtRef()
|
157 |
+
{
|
158 |
+
return $this->getQuoteId();
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Set a mobile phone number.
|
163 |
+
*
|
164 |
+
* @param string $phoneNumber
|
165 |
+
* @param boolean $skipValidation
|
166 |
+
*
|
167 |
+
* @throws TIG_PostNL_Exception
|
168 |
+
*
|
169 |
+
* @return $this
|
170 |
+
*/
|
171 |
+
public function setMobilePhoneNumber($phoneNumber, $skipValidation = false)
|
172 |
+
{
|
173 |
+
if ($skipValidation || empty($phoneNumber)) {
|
174 |
+
$this->setData('mobile_phone_number', $phoneNumber);
|
175 |
+
return $this;
|
176 |
+
}
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Parse the number so that it starts with '+316' and remove any invalid characters.
|
180 |
+
*/
|
181 |
+
$parsedPhoneNumber = preg_replace(
|
182 |
+
array(self::MOBILE_PHONE_NUMBER_CONTENT_REGEX, self::MOBILE_PHONE_NUMBER_PREFIX_REGEX),
|
183 |
+
array('', self::MOBILE_PHONE_NUMBER_PREFIX_REPLACEMENT),
|
184 |
+
$phoneNumber
|
185 |
+
);
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Validate the phone number. It should be a valid Dutch mobile phone number.
|
189 |
+
*/
|
190 |
+
$validPhoneNumber = preg_match(self::MOBILE_PHONE_NUMBER_REGEX, $parsedPhoneNumber);
|
191 |
+
if (!$validPhoneNumber) {
|
192 |
+
throw new TIG_PostNL_Exception(
|
193 |
+
Mage::helper('postnl')->__('Invalid mobile phone number supplied: %s', $parsedPhoneNumber),
|
194 |
+
'POSTNL-0149'
|
195 |
+
);
|
196 |
+
}
|
197 |
+
|
198 |
+
$this->setData('mobile_phone_number', $parsedPhoneNumber);
|
199 |
+
return $this;
|
200 |
+
}
|
201 |
+
|
202 |
+
/**
|
203 |
+
* Cancels the PostNL order.
|
204 |
+
*
|
205 |
+
* @return $this
|
206 |
+
*
|
207 |
+
* @throws TIG_PostNL_Exception
|
208 |
+
*/
|
209 |
+
public function cancel()
|
210 |
+
{
|
211 |
+
$helper = Mage::helper('postnl');
|
212 |
+
if (!$this->getOrderId()) {
|
213 |
+
throw new TIG_PostNL_Exception(
|
214 |
+
$helper->__('This PostNL Checkout order cannot be cancelled: it has no associated magento order.'),
|
215 |
+
'POSTNL-0046'
|
216 |
+
);
|
217 |
+
}
|
218 |
+
|
219 |
+
if ($this->getIsCanceled()) {
|
220 |
+
throw new TIG_PostNL_Exception(
|
221 |
+
$helper->__('This PostNL Checkout order cannot be cancelled: it has already been canceled.'),
|
222 |
+
'POSTNL-0047'
|
223 |
+
);
|
224 |
+
}
|
225 |
+
|
226 |
+
$cif = Mage::getModel('postnl_checkout/cif');
|
227 |
+
$cif->updateOrder($this, true);
|
228 |
+
|
229 |
+
$this->setIsCanceled(true);
|
230 |
+
|
231 |
+
return $this;
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Sets new PostNL Orders to active before saving
|
236 |
+
*
|
237 |
+
* @return Mage_Core_Model_Abstract::_beforeSave();
|
238 |
+
*/
|
239 |
+
protected function _beforeSave()
|
240 |
+
{
|
241 |
+
if ($this->isObjectNew()) {
|
242 |
+
$this->setIsActive(1);
|
243 |
+
}
|
244 |
+
|
245 |
+
return parent::_beforeSave();
|
246 |
+
}
|
247 |
+
}
|
@@ -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.
|
@@ -33,13 +33,13 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
-
{
|
43 |
-
$this->_init('
|
44 |
Â
}
|
45 |
Â
}
|
1 |
+
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
+
class TIG_PostNL_Model_Core_Resource_Order extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
+
{
|
43 |
+
$this->_init('postnl_core/order', 'entity_id');
|
44 |
Â
}
|
45 |
Â
}
|
@@ -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.
|
@@ -33,10 +33,10 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
-
class
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Event prefix
|
@@ -51,10 +51,10 @@ class TIG_PostNL_Model_Checkout_Resource_Order_Collection extends TIG_PostNL_Mod
|
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_order_collection';
|
54 |
-
|
55 |
Â
public function _construct()
|
56 |
-
{
|
57 |
Â
parent::_construct();
|
58 |
-
$this->_init('
|
59 |
Â
}
|
60 |
Â
}
|
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.
|
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 |
+
class TIG_PostNL_Model_Core_Resource_Order_Collection extends TIG_PostNL_Model_Resource_Db_Collection_Postnl
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Event prefix
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_order_collection';
|
54 |
+
|
55 |
Â
public function _construct()
|
56 |
+
{
|
57 |
Â
parent::_construct();
|
58 |
+
$this->_init('postnl_core/order');
|
59 |
Â
}
|
60 |
Â
}
|
@@ -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.
|
@@ -33,13 +33,13 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
-
{
|
43 |
Â
$this->_init('postnl_core/shipment', 'entity_id');
|
44 |
Â
}
|
45 |
Â
}
|
1 |
+
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
+
{
|
43 |
Â
$this->_init('postnl_core/shipment', 'entity_id');
|
44 |
Â
}
|
45 |
Â
}
|
@@ -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.
|
@@ -39,7 +39,7 @@
|
|
39 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment_Barcode extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
-
{
|
43 |
Â
$this->_init('postnl_core/shipment_barcode', 'barcode_id');
|
44 |
Â
}
|
45 |
Â
}
|
1 |
+
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
39 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment_Barcode extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
+
{
|
43 |
Â
$this->_init('postnl_core/shipment_barcode', 'barcode_id');
|
44 |
Â
}
|
45 |
Â
}
|
@@ -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.
|
@@ -51,9 +51,9 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Barcode_Collection extends TIG_Pos
|
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_barcode_collection';
|
54 |
-
|
55 |
Â
public function _construct()
|
56 |
-
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment_barcode');
|
59 |
Â
}
|
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.
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_barcode_collection';
|
54 |
+
|
55 |
Â
public function _construct()
|
56 |
+
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment_barcode');
|
59 |
Â
}
|
@@ -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.
|
@@ -51,9 +51,9 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Collection extends TIG_PostNL_Mode
|
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_collection';
|
54 |
-
|
55 |
Â
public function _construct()
|
56 |
-
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment');
|
59 |
Â
}
|
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.
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_collection';
|
54 |
+
|
55 |
Â
public function _construct()
|
56 |
+
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment');
|
59 |
Â
}
|
@@ -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.
|
@@ -39,7 +39,7 @@
|
|
39 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment_Label extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
-
{
|
43 |
Â
$this->_init('postnl_core/shipment_label', 'label_id');
|
44 |
Â
}
|
45 |
Â
}
|
1 |
+
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
39 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment_Label extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
+
{
|
43 |
Â
$this->_init('postnl_core/shipment_label', 'label_id');
|
44 |
Â
}
|
45 |
Â
}
|
@@ -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.
|
@@ -51,9 +51,9 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection extends TIG_PostN
|
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_label_collection';
|
54 |
-
|
55 |
Â
public function _construct()
|
56 |
-
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment_label');
|
59 |
Â
}
|
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.
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_label_collection';
|
54 |
+
|
55 |
Â
public function _construct()
|
56 |
+
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment_label');
|
59 |
Â
}
|
@@ -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.
|
@@ -33,13 +33,13 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment_Status_History extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
-
{
|
43 |
Â
$this->_init('postnl_core/shipment_status_history', 'status_id');
|
44 |
Â
}
|
45 |
Â
}
|
1 |
+
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Model_Core_Resource_Shipment_Status_History extends Mage_Core_Model_Resource_Db_Abstract
|
40 |
Â
{
|
41 |
Â
public function _construct()
|
42 |
+
{
|
43 |
Â
$this->_init('postnl_core/shipment_status_history', 'status_id');
|
44 |
Â
}
|
45 |
Â
}
|
@@ -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.
|
@@ -51,9 +51,9 @@ class TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection extends
|
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_status_history_collection';
|
54 |
-
|
55 |
Â
public function _construct()
|
56 |
-
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment_status_history');
|
59 |
Â
}
|
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.
|
51 |
Â
* @var string
|
52 |
Â
*/
|
53 |
Â
protected $_eventObject = 'postnl_shipment_status_history_collection';
|
54 |
+
|
55 |
Â
public function _construct()
|
56 |
+
{
|
57 |
Â
parent::_construct();
|
58 |
Â
$this->_init('postnl_core/shipment_status_history');
|
59 |
Â
}
|
@@ -33,36 +33,120 @@
|
|
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
|
37 |
-
* @license
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
42 |
Â
*/
|
43 |
Â
class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
44 |
Â
{
|
45 |
Â
/**
|
46 |
-
* Prefix of model events names
|
47 |
Â
*
|
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
|
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 |
Â
*/
|
67 |
Â
const SHIPPING_PHASE_COLLECTION = '1';
|
68 |
Â
const SHIPPING_PHASE_SORTING = '2';
|
@@ -71,48 +155,56 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
71 |
Â
const SHIPPING_PHASE_NOT_APPLICABLE = '99';
|
72 |
Â
|
73 |
Â
/**
|
74 |
-
*
|
75 |
Â
*/
|
76 |
-
const
|
77 |
-
const
|
78 |
-
const
|
79 |
-
const
|
80 |
-
const
|
81 |
-
const
|
82 |
-
const
|
Â
|
|
Â
|
|
Â
|
|
83 |
Â
|
84 |
Â
/**
|
85 |
-
*
|
86 |
Â
*/
|
87 |
-
const
|
88 |
Â
|
89 |
Â
/**
|
90 |
-
*
|
91 |
Â
*/
|
92 |
-
const
|
93 |
Â
|
94 |
Â
/**
|
95 |
-
*
|
96 |
Â
*/
|
97 |
-
const
|
98 |
Â
|
99 |
Â
/**
|
100 |
-
*
|
101 |
Â
*/
|
102 |
-
const
|
103 |
Â
|
104 |
Â
/**
|
105 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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 |
Â
*/
|
@@ -136,9 +228,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
Â
|
|
140 |
Â
*
|
141 |
-
* @var
|
142 |
Â
*/
|
143 |
Â
protected $_process;
|
144 |
Â
|
@@ -150,9 +243,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
150 |
Â
$this->_init('postnl_core/shipment');
|
151 |
Â
}
|
152 |
Â
|
153 |
-
|
154 |
-
* GETTER
|
155 |
-
|
156 |
Â
|
157 |
Â
/**
|
158 |
Â
* Retrieves a Mage_Sales_Model_Order_Shipment entity linked to the postnl shipment.
|
@@ -161,8 +254,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
161 |
Â
*/
|
162 |
Â
public function getShipment()
|
163 |
Â
{
|
164 |
-
if ($this->
|
165 |
-
return $this->
|
166 |
Â
}
|
167 |
Â
|
168 |
Â
$shipmentId = $this->getShipmentId();
|
@@ -170,6 +263,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
170 |
Â
return null;
|
171 |
Â
}
|
172 |
Â
|
Â
|
|
Â
|
|
Â
|
|
173 |
Â
$shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
|
174 |
Â
|
175 |
Â
$this->setShipment($shipment);
|
@@ -179,12 +275,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
179 |
Â
/**
|
180 |
Â
* Retrieves the linked Shipment's shipping address
|
181 |
Â
*
|
182 |
-
* @return Mage_Sales_Model_Order_Address
|
183 |
Â
*/
|
184 |
Â
public function getShippingAddress()
|
185 |
Â
{
|
186 |
-
if ($this->
|
187 |
-
return $this->
|
188 |
Â
}
|
189 |
Â
|
190 |
Â
$shipmentId = $this->getShipmentId();
|
@@ -201,12 +297,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
201 |
Â
/**
|
202 |
Â
* Gets an optional address with the pakje_gemak address type
|
203 |
Â
*
|
204 |
-
* @return boolean
|
205 |
Â
*/
|
206 |
Â
public function getPakjeGemakAddress()
|
207 |
Â
{
|
208 |
-
if ($this->
|
209 |
-
return $this->
|
210 |
Â
}
|
211 |
Â
|
212 |
Â
$shipmentId = $this->getShipmentId();
|
@@ -214,6 +310,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
214 |
Â
return null;
|
215 |
Â
}
|
216 |
Â
|
Â
|
|
Â
|
|
Â
|
|
217 |
Â
$addresses = $this->getShipment()->getOrder()->getAddressesCollection();
|
218 |
Â
foreach ($addresses as $address) {
|
219 |
Â
if ($address->getAddressType() == self::ADDRESS_TYPE_PAKJEGEMAK) {
|
@@ -234,8 +333,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
234 |
Â
*/
|
235 |
Â
public function getStoreId()
|
236 |
Â
{
|
237 |
-
if ($this->
|
238 |
-
return $this->
|
239 |
Â
}
|
240 |
Â
|
241 |
Â
if ($this->getShipment()) {
|
@@ -258,8 +357,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
258 |
Â
*/
|
259 |
Â
public function getOrderId()
|
260 |
Â
{
|
261 |
-
if ($this->
|
262 |
-
return $this->
|
263 |
Â
}
|
264 |
Â
|
265 |
Â
$shipment = $this->getShipment();
|
@@ -276,12 +375,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
276 |
Â
/**
|
277 |
Â
* Gets a PostNL helper object
|
278 |
Â
*
|
279 |
-
* @
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
280 |
Â
*/
|
281 |
Â
public function getHelper($type = 'data')
|
282 |
Â
{
|
283 |
-
if ($this->
|
284 |
-
return $this->
|
285 |
Â
}
|
286 |
Â
|
287 |
Â
$helper = Mage::helper('postnl/' . $type);
|
@@ -299,34 +402,24 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
299 |
Â
{
|
300 |
Â
$process = $this->_process;
|
301 |
Â
if (is_null($process)) {
|
Â
|
|
Â
|
|
Â
|
|
302 |
Â
$process = Mage::getModel('postnl_core/shipment_process')
|
303 |
Â
->setId($this->getId());
|
Â
|
|
304 |
Â
$this->setProcess($process);
|
305 |
Â
}
|
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
|
330 |
Â
{
|
331 |
Â
return $this->_labelsToSave;
|
332 |
Â
}
|
@@ -348,8 +441,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
348 |
Â
*/
|
349 |
Â
public function getProductCode()
|
350 |
Â
{
|
351 |
-
if ($this->
|
352 |
-
return $this->
|
353 |
Â
}
|
354 |
Â
|
355 |
Â
$productCode = $this->_getProductCode();
|
@@ -370,7 +463,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
374 |
Â
*/
|
375 |
Â
if (!$this->getLabelsPrinted() && $labelCollection->getSize() > 0) {
|
376 |
Â
$this->deleteLabels();
|
@@ -384,12 +477,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
384 |
Â
/**
|
385 |
Â
* Get the amount of extra cover this shipment has.
|
386 |
Â
*
|
387 |
-
* @return int
|
388 |
Â
*/
|
389 |
Â
public function getExtraCoverAmount()
|
390 |
Â
{
|
391 |
-
if ($this->
|
392 |
-
return $this->
|
393 |
Â
}
|
394 |
Â
|
395 |
Â
return 0;
|
@@ -401,7 +494,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
405 |
Â
*/
|
406 |
Â
public function getTotalWeight($standardize = false, $toGrams = false)
|
407 |
Â
{
|
@@ -414,6 +507,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
414 |
Â
* calculate the total weight
|
415 |
Â
*/
|
416 |
Â
$weight = 0;
|
Â
|
|
Â
|
|
Â
|
|
417 |
Â
foreach ($items as $item) {
|
418 |
Â
$weight += ($item->getWeight() * $item->getQty());
|
419 |
Â
}
|
@@ -423,9 +519,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
423 |
Â
}
|
424 |
Â
|
425 |
Â
/**
|
426 |
-
*
|
Â
|
|
Â
|
|
427 |
Â
*/
|
428 |
-
$
|
Â
|
|
429 |
Â
$weight,
|
430 |
Â
$this->getStoreId(),
|
431 |
Â
$toGrams
|
@@ -437,12 +536,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
437 |
Â
/**
|
438 |
Â
* Calculates a shipment's base grand total based on it's shipment items
|
439 |
Â
*
|
440 |
-
* @return float
|
441 |
Â
*/
|
442 |
Â
public function getShipmentBaseGrandTotal()
|
443 |
Â
{
|
444 |
-
if ($this->
|
445 |
-
return $this->
|
446 |
Â
}
|
447 |
Â
|
448 |
Â
/**
|
@@ -458,8 +557,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
458 |
Â
*/
|
459 |
Â
$baseGrandTotal = 0;
|
460 |
Â
$shipmentItems = $shipment->getAllItems();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
461 |
Â
foreach ($shipmentItems as $shipmentItem) {
|
462 |
Â
$qty = $shipmentItem->getQty();
|
Â
|
|
463 |
Â
/**
|
464 |
Â
* The base price of a shipment item is only available through it's associated order item
|
465 |
Â
*/
|
@@ -488,7 +592,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
488 |
Â
public function getBarcodeUrl($forceNl = false)
|
489 |
Â
{
|
490 |
Â
if ($this->hasBarcodeUrl()) {
|
491 |
-
return $this->
|
492 |
Â
}
|
493 |
Â
|
494 |
Â
$barcode = $this->getMainBarcode();
|
@@ -496,6 +600,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
496 |
Â
return false;
|
497 |
Â
}
|
498 |
Â
|
Â
|
|
Â
|
|
Â
|
|
499 |
Â
$helper = $this->getHelper('carrier');
|
500 |
Â
|
501 |
Â
$locale = Mage::getStoreConfig('general/locale/code', $this->getStoreId());
|
@@ -508,64 +615,69 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
508 |
Â
}
|
509 |
Â
|
510 |
Â
/**
|
511 |
-
* Gets the shipment's shipment type for intrnational shipments.
|
512 |
-
*
|
513 |
Â
*
|
514 |
-
* @return string
|
515 |
Â
*/
|
516 |
-
public function
|
517 |
Â
{
|
518 |
-
if ($this->
|
519 |
-
return $this->
|
520 |
Â
}
|
521 |
Â
|
522 |
Â
if (!$this->isGlobalShipment()) {
|
523 |
Â
return null;
|
524 |
Â
}
|
525 |
Â
|
526 |
-
$
|
527 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
542 |
Â
/**
|
543 |
Â
* PakjeGemak default option
|
544 |
Â
*/
|
545 |
-
$
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
Â
/**
|
553 |
Â
* EU default option
|
554 |
Â
*/
|
555 |
-
$
|
556 |
-
|
557 |
-
|
558 |
-
return $productCode;
|
559 |
-
}
|
560 |
-
|
561 |
-
if ($this->isGlobalShipment()) {
|
562 |
Â
/**
|
563 |
Â
* Global default option
|
564 |
Â
*/
|
565 |
-
$
|
566 |
-
$this->_checkProductCodeAllowed($productCode);
|
567 |
-
|
568 |
-
return $productCode;
|
569 |
Â
}
|
570 |
Â
|
571 |
Â
/**
|
@@ -573,29 +685,31 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
573 |
Â
*/
|
574 |
Â
|
575 |
Â
/**
|
576 |
-
* Dutch shipments may use an alternative default option when the shipment's base grandtotal exceeds a specified
|
Â
|
|
577 |
Â
*/
|
578 |
-
$useAlternativeDefault = Mage::getStoreConfig(self::
|
579 |
-
if ($useAlternativeDefault) {
|
580 |
Â
/**
|
581 |
Â
* Alternative default option usage is enabled
|
582 |
Â
*/
|
583 |
-
$maxShipmentAmount = Mage::getStoreConfig(self::
|
584 |
Â
if ($this->getShipmentBaseGrandTotal() > $maxShipmentAmount) {
|
585 |
Â
/**
|
586 |
-
* The shipment's base
|
587 |
Â
*/
|
588 |
-
$
|
589 |
-
$this->_checkProductCodeAllowed($productCode);
|
590 |
-
|
591 |
-
return $productCode;
|
592 |
Â
}
|
593 |
Â
}
|
594 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
595 |
Â
/**
|
596 |
Â
* standard default option
|
597 |
Â
*/
|
598 |
-
$productCode = Mage::getStoreConfig(
|
599 |
Â
$this->_checkProductCodeAllowed($productCode);
|
600 |
Â
|
601 |
Â
return $productCode;
|
@@ -604,9 +718,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
604 |
Â
/**
|
605 |
Â
* Get a specific barcode for this shipment
|
606 |
Â
*
|
607 |
-
* @param int
|
608 |
Â
*
|
609 |
-
* @return string
|
610 |
Â
*/
|
611 |
Â
public function getBarcode($barcodeNumber = null)
|
612 |
Â
{
|
@@ -615,8 +729,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
615 |
Â
return $barcode;
|
616 |
Â
}
|
617 |
Â
|
618 |
-
|
619 |
-
|
Â
|
|
Â
|
|
Â
|
|
620 |
Â
|
621 |
Â
return $barcode->getBarcode();
|
622 |
Â
}
|
@@ -624,7 +741,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
624 |
Â
/**
|
625 |
Â
* Get all barcodes associated with this shipment
|
626 |
Â
*
|
627 |
-
* @param $asObject
|
628 |
Â
*
|
629 |
Â
* @return array
|
630 |
Â
*/
|
@@ -656,16 +773,151 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
669 |
Â
*/
|
670 |
Â
public function setLabelsToSave($labels)
|
671 |
Â
{
|
@@ -679,7 +931,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
679 |
Â
*
|
680 |
Â
* @param int $amount
|
681 |
Â
*
|
682 |
-
* @return TIG_PostNL_Model_Core_Shipment
|
683 |
Â
*/
|
684 |
Â
public function setExtraCoverAmount($amount)
|
685 |
Â
{
|
@@ -689,7 +941,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
689 |
Â
$productCode = $this->getProductCode();
|
690 |
Â
$extraCoverProductCodes = $this->getExtraCoverProductCodes();
|
691 |
Â
if (!in_array($productCode, $extraCoverProductCodes)) {
|
692 |
-
return
|
693 |
Â
}
|
694 |
Â
|
695 |
Â
$this->setData('extra_cover_amount', $amount);
|
@@ -702,9 +954,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
702 |
Â
*
|
703 |
Â
* @param string $type
|
704 |
Â
*
|
705 |
-
* @return
|
706 |
Â
*/
|
707 |
-
public function
|
708 |
Â
{
|
709 |
Â
/**
|
710 |
Â
* Only global shipments have a shipment type
|
@@ -719,7 +971,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
719 |
Â
$shipmentType = str_replace('_', ' ', $type);
|
720 |
Â
$shipmentType = ucwords($shipmentType);
|
721 |
Â
|
722 |
-
$this->setData('
|
723 |
Â
return $this;
|
724 |
Â
}
|
725 |
Â
|
@@ -728,11 +980,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
728 |
Â
*
|
729 |
Â
* @param int $count
|
730 |
Â
*
|
731 |
-
* @
|
Â
|
|
Â
|
|
732 |
Â
*/
|
733 |
Â
public function setParcelCount($count)
|
734 |
Â
{
|
735 |
-
$maxParcelCount = Mage::getStoreConfig(self::
|
736 |
Â
if (!$maxParcelCount) {
|
737 |
Â
$this->setData('parcel_count', $count);
|
738 |
Â
return $this;
|
@@ -753,52 +1007,87 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
753 |
Â
return $this;
|
754 |
Â
}
|
755 |
Â
|
756 |
-
/****************************************************************************************************************************
|
757 |
-
* SHIPMENT LOCKING AND UNLOCKING FUNCTIONS
|
758 |
-
***************************************************************************************************************************/
|
759 |
-
|
760 |
Â
/**
|
761 |
-
*
|
Â
|
|
Â
|
|
762 |
Â
*
|
763 |
-
* @return
|
764 |
Â
*/
|
765 |
-
public function
|
766 |
Â
{
|
767 |
-
|
768 |
-
$process->lockAndBlock();
|
769 |
-
|
770 |
-
return $this;
|
771 |
Â
}
|
772 |
Â
|
773 |
Â
/**
|
774 |
-
*
|
775 |
Â
*
|
776 |
-
* @
|
Â
|
|
Â
|
|
777 |
Â
*/
|
778 |
-
public function
|
779 |
Â
{
|
780 |
-
$
|
781 |
-
$process->unlock();
|
782 |
Â
|
783 |
Â
return $this;
|
784 |
Â
}
|
785 |
Â
|
786 |
Â
/**
|
787 |
-
*
|
Â
|
|
Â
|
|
788 |
Â
*
|
789 |
-
* @
|
Â
|
|
Â
|
|
790 |
Â
*/
|
791 |
-
public function
|
792 |
Â
{
|
793 |
-
$
|
794 |
-
|
Â
|
|
Â
|
|
795 |
Â
|
796 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
797 |
Â
}
|
798 |
Â
|
799 |
-
|
800 |
Â
* HAS- METHODS
|
801 |
-
|
802 |
Â
|
803 |
Â
/**
|
804 |
Â
* Check if the shipment has any associated labels
|
@@ -847,6 +1136,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
847 |
Â
*/
|
848 |
Â
public function hasLabelType($labelType)
|
849 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
850 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
851 |
Â
$readConn = $coreResource->getConnection('core/read');
|
852 |
Â
|
@@ -864,14 +1156,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
Â
*/
|
@@ -887,6 +1179,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
887 |
Â
*/
|
888 |
Â
public function isDutchShipment()
|
889 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
890 |
Â
$shippingDestination = $this->getShippingAddress()->getCountryId();
|
891 |
Â
|
892 |
Â
if ($shippingDestination == 'NL') {
|
@@ -903,9 +1199,17 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
903 |
Â
*/
|
904 |
Â
public function isEuShipment()
|
905 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
906 |
Â
$shippingDestination = $this->getShippingAddress()->getCountryId();
|
907 |
Â
|
908 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
909 |
Â
|
910 |
Â
if (in_array($shippingDestination, $euCountries)) {
|
911 |
Â
return true;
|
@@ -921,6 +1225,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
921 |
Â
*/
|
922 |
Â
public function isGlobalShipment()
|
923 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
924 |
Â
if (!$this->isDutchShipment() && !$this->isEuShipment()) {
|
925 |
Â
return true;
|
926 |
Â
}
|
@@ -928,6 +1236,60 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
928 |
Â
return false;
|
929 |
Â
}
|
930 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
931 |
Â
/**
|
932 |
Â
* Check if the currrent shipment is a PakjeGemak shipment.
|
933 |
Â
*
|
@@ -939,13 +1301,27 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
939 |
Â
return true;
|
940 |
Â
}
|
941 |
Â
|
942 |
-
|
943 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
944 |
Â
return true;
|
945 |
Â
}
|
946 |
Â
|
947 |
-
|
948 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
949 |
Â
|
950 |
Â
if (!$productCode) {
|
951 |
Â
return false;
|
@@ -959,6 +1335,35 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
959 |
Â
return false;
|
960 |
Â
}
|
961 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
962 |
Â
/**
|
963 |
Â
* Checks if this shipment is a COD shipment
|
964 |
Â
*
|
@@ -968,7 +1373,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
968 |
Â
*/
|
969 |
Â
public function isCod()
|
970 |
Â
{
|
971 |
-
return false;
|
972 |
Â
}
|
973 |
Â
|
974 |
Â
/**
|
@@ -986,6 +1391,28 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
986 |
Â
return false;
|
987 |
Â
}
|
988 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
989 |
Â
/**
|
990 |
Â
* Checks if the current entity may generate a barcode.
|
991 |
Â
*
|
@@ -1003,6 +1430,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1003 |
Â
/**
|
1004 |
Â
* Checks if the current entity can be confirmed.
|
1005 |
Â
*
|
Â
|
|
Â
|
|
1006 |
Â
* @return boolean
|
1007 |
Â
*/
|
1008 |
Â
public function canConfirm($skipEuCheck = false)
|
@@ -1035,7 +1464,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
Â
|
|
1039 |
Â
*
|
1040 |
Â
* @return boolean
|
1041 |
Â
*/
|
@@ -1070,7 +1500,8 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
Â
|
|
1074 |
Â
*
|
1075 |
Â
* @return boolean
|
1076 |
Â
*
|
@@ -1085,10 +1516,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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)
|
1092 |
Â
{
|
1093 |
Â
if ($this->isLocked()) {
|
1094 |
Â
return false;
|
@@ -1098,10 +1530,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1098 |
Â
return false;
|
1099 |
Â
}
|
1100 |
Â
|
1101 |
-
$
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
Â
|
|
Â
|
|
1105 |
Â
}
|
1106 |
Â
|
1107 |
Â
return true;
|
@@ -1135,15 +1569,61 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
Â
|
|
1145 |
Â
*
|
1146 |
-
* @return
|
1147 |
Â
*
|
1148 |
Â
* @throws TIG_PostNL_Exception
|
1149 |
Â
*/
|
@@ -1172,9 +1652,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1172 |
Â
}
|
1173 |
Â
|
1174 |
Â
/**
|
1175 |
-
* If this shipment consists of a single parcel
|
1176 |
Â
*/
|
1177 |
-
if ($parcelCount < 2
|
1178 |
Â
Mage::dispatchEvent('postnl_shipment_generatebarcode_after', array('shipment' => $this));
|
1179 |
Â
$this->unlock();
|
1180 |
Â
|
@@ -1200,19 +1680,26 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
-
$
|
Â
|
|
Â
|
|
1210 |
Â
|
1211 |
Â
$barcode = $cif->generateBarcode($shipment, $barcodeType);
|
1212 |
Â
|
1213 |
Â
if (!$barcode) {
|
1214 |
Â
throw new TIG_PostNL_Exception(
|
1215 |
-
|
1216 |
Â
'POSTNL-0070'
|
1217 |
Â
);
|
1218 |
Â
}
|
@@ -1220,7 +1707,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1220 |
Â
/**
|
1221 |
Â
* If the generated barcode already exists a new one needs to be generated.
|
1222 |
Â
*/
|
1223 |
-
if ($
|
1224 |
Â
return $this->_generateBarcode();
|
1225 |
Â
}
|
1226 |
Â
|
@@ -1230,7 +1717,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1230 |
Â
/**
|
1231 |
Â
* Generates a shipping labels for a shipment without confirming it with PostNL.
|
1232 |
Â
*
|
1233 |
-
* @return
|
1234 |
Â
*
|
1235 |
Â
* @throws TIG_PostNL_Exception
|
1236 |
Â
*/
|
@@ -1277,11 +1764,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1277 |
Â
}
|
1278 |
Â
|
1279 |
Â
/**
|
1280 |
-
* Get a shipping label from PostNL for a single parcel or a whole shipment
|
1281 |
Â
*
|
1282 |
-
* @param boolean
|
1283 |
-
* @param int
|
Â
|
|
1284 |
Â
*
|
Â
|
|
1285 |
Â
* @return array
|
1286 |
Â
*/
|
1287 |
Â
protected function _generateLabel($confirm = false, $barcodeNumber = false)
|
@@ -1293,25 +1782,31 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1293 |
Â
*/
|
1294 |
Â
if ($barcodeNumber === false) {
|
1295 |
Â
$barcode = $mainBarcode;
|
1296 |
-
$mainbarcode = false;
|
1297 |
Â
} else {
|
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
|
1311 |
Â
throw new TIG_PostNL_Exception(
|
1312 |
Â
Mage::helper('postnl')->__(
|
1313 |
Â
'The confirmAndPrintLabel action returned an invalid response: %s',
|
1314 |
-
var_export($
|
1315 |
Â
),
|
1316 |
Â
'POSTNL-0071'
|
1317 |
Â
);
|
@@ -1319,7 +1814,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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);
|
@@ -1328,10 +1823,34 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1328 |
Â
return $labels;
|
1329 |
Â
}
|
1330 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1331 |
Â
/**
|
1332 |
Â
* Confirm the shipment with PostNL without generating new labels
|
1333 |
Â
*
|
1334 |
-
* @return
|
1335 |
Â
*
|
1336 |
Â
* @throws TIG_PostNL_Exception
|
1337 |
Â
*/
|
@@ -1359,8 +1878,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1359 |
Â
if ($parcelCount < 2) {
|
1360 |
Â
$this->_confirm();
|
1361 |
Â
|
1362 |
-
$this->
|
1363 |
-
->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
|
1364 |
Â
|
1365 |
Â
Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
|
1366 |
Â
|
@@ -1375,8 +1893,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1375 |
Â
$this->_confirm($i);
|
1376 |
Â
}
|
1377 |
Â
|
1378 |
-
$this->
|
1379 |
-
->setConfirmedAt(Mage::getModel('core/date')->gmtTimestamp());
|
1380 |
Â
|
1381 |
Â
Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
|
1382 |
Â
|
@@ -1385,13 +1902,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1385 |
Â
}
|
1386 |
Â
|
1387 |
Â
/**
|
1388 |
-
* Confirms the shipment using CIF
|
1389 |
-
*
|
1390 |
-
* @param int | null $barcodeNumber
|
1391 |
Â
*
|
1392 |
-
* @
|
1393 |
Â
*
|
1394 |
Â
* @throws TIG_PostNL_Exception
|
Â
|
|
Â
|
|
1395 |
Â
*/
|
1396 |
Â
protected function _confirm($barcodeNumber = false)
|
1397 |
Â
{
|
@@ -1402,20 +1919,24 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1402 |
Â
*/
|
1403 |
Â
if ($barcodeNumber === false) {
|
1404 |
Â
$barcode = $mainBarcode;
|
1405 |
-
$mainbarcode = false;
|
1406 |
Â
} else {
|
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
|
1418 |
-
* has to be the shipment's main barcode.
|
1419 |
Â
*/
|
1420 |
Â
if (is_object($responseShipment)
|
1421 |
Â
&& isset($responseShipment->Barcode)
|
@@ -1425,11 +1946,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1425 |
Â
}
|
1426 |
Â
|
1427 |
Â
/**
|
1428 |
-
* If the ConfirmingResponseShipment is an array, it may indicate multiple shipments were confirmed. We need to
|
1429 |
-
* first shipment's barcode to see if it matches the main bartcode.
|
1430 |
Â
*/
|
1431 |
Â
if (is_array($responseShipment)) {
|
1432 |
-
$mainResponseShipment = $responseShipment
|
1433 |
Â
|
1434 |
Â
if (is_object($mainResponseShipment)
|
1435 |
Â
&& isset($mainResponseShipment->Barcode)
|
@@ -1451,7 +1972,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1451 |
Â
/**
|
1452 |
Â
* Generates a shipping label and confirms the shipment with postNL.
|
1453 |
Â
*
|
1454 |
-
* @return
|
1455 |
Â
*
|
1456 |
Â
* @throws TIG_PostNL_Exception
|
1457 |
Â
*/
|
@@ -1474,6 +1995,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1474 |
Â
$parcelCount = $this->_calculateParcelCount();
|
1475 |
Â
}
|
1476 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1477 |
Â
/**
|
1478 |
Â
* Confirm and generate labels purely for the main shipment
|
1479 |
Â
*/
|
@@ -1482,7 +2008,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1482 |
Â
$this->addLabels($labels);
|
1483 |
Â
|
1484 |
Â
$this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
|
1485 |
-
->setConfirmedAt(
|
1486 |
Â
|
1487 |
Â
$this->_saveLabels();
|
1488 |
Â
|
@@ -1502,7 +2028,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1502 |
Â
}
|
1503 |
Â
|
1504 |
Â
$this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
|
1505 |
-
->setConfirmedAt(
|
1506 |
Â
|
1507 |
Â
$this->_saveLabels();
|
1508 |
Â
|
@@ -1516,7 +2042,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1516 |
Â
/**
|
1517 |
Â
* Requests a shipping status update for this shipment
|
1518 |
Â
*
|
1519 |
-
* @return
|
1520 |
Â
*
|
1521 |
Â
* @throws TIG_PostNL_Exception
|
1522 |
Â
*/
|
@@ -1533,7 +2059,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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;
|
@@ -1553,9 +2083,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1553 |
Â
/**
|
1554 |
Â
* Update this shipment's status history
|
1555 |
Â
*
|
1556 |
-
* @
|
1557 |
Â
*
|
1558 |
-
* @return
|
1559 |
Â
*/
|
1560 |
Â
public function updateCompleteShippingStatus()
|
1561 |
Â
{
|
@@ -1570,7 +2100,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
Â
/**
|
@@ -1590,10 +2125,18 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
Â
/**
|
@@ -1604,7 +2147,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1604 |
Â
continue;
|
1605 |
Â
}
|
1606 |
Â
|
1607 |
-
$timestamp =
|
1608 |
Â
$statusHistory->setParentId($this->getId())
|
1609 |
Â
->setCode($status->Code)
|
1610 |
Â
->setDescription($status->Description)
|
@@ -1616,7 +2159,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1616 |
Â
->save();
|
1617 |
Â
}
|
1618 |
Â
|
1619 |
-
$this->setStatusHistoryUpdatedAt(
|
1620 |
Â
|
1621 |
Â
Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_after', array('shipment' => $this));
|
1622 |
Â
|
@@ -1625,14 +2168,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
1636 |
Â
*
|
1637 |
Â
* @throws TIG_PostNL_Exception
|
1638 |
Â
*/
|
@@ -1657,16 +2200,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
Â
*/
|
1666 |
-
$
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
Â
|
1671 |
Â
return $this;
|
1672 |
Â
}
|
@@ -1675,29 +2223,35 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
1681 |
Â
*/
|
1682 |
-
public function sendTrackAndTraceEmail($ignoreAlreadySent = false)
|
1683 |
Â
{
|
1684 |
-
if (!$this->canSendTrackAndTraceEmail($ignoreAlreadySent)) {
|
1685 |
Â
throw new TIG_PostNL_Exception(
|
1686 |
Â
Mage::helper('postnl')->__('The sendTrackAndTraceEmail action is currently unavailable.'),
|
1687 |
Â
'POSTNL-0076'
|
1688 |
Â
);
|
1689 |
Â
}
|
1690 |
Â
|
1691 |
-
$oldStoreId = Mage::app()->getStore()->getId();
|
1692 |
Â
$storeId = $this->getStoreId();
|
1693 |
Â
|
1694 |
-
$template = Mage::getStoreConfig(self::
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1695 |
Â
$mailTemplate = Mage::getModel('core/email_template');
|
1696 |
Â
|
1697 |
Â
$shippingAddress = $this->getShippingAddress();
|
1698 |
Â
$recipient = array(
|
1699 |
Â
'email' => $this->getShipment()->getOrder()->getCustomerEmail(),
|
1700 |
-
'name' => $shippingAddress->
|
1701 |
Â
);
|
1702 |
Â
|
1703 |
Â
$mailTemplate->setDesignConfig(
|
@@ -1707,8 +2261,12 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1707 |
Â
)
|
1708 |
Â
);
|
1709 |
Â
|
Â
|
|
Â
|
|
Â
|
|
1710 |
Â
$shipment = $this->getShipment();
|
1711 |
Â
$order = $shipment->getOrder();
|
Â
|
|
1712 |
Â
$templateVariables = array(
|
1713 |
Â
'postnlshipment' => $this,
|
1714 |
Â
'barcode' => $this->getMainBarcode(),
|
@@ -1719,6 +2277,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1719 |
Â
'quote' => $order->getQuote(),
|
1720 |
Â
);
|
1721 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1722 |
Â
$orderModel = Mage::getConfig()->getModelClassName('sales/order');
|
1723 |
Â
$success = $mailTemplate->sendTransactional(
|
1724 |
Â
$template,
|
@@ -1730,17 +2292,27 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1730 |
Â
|
1731 |
Â
if ($success === false) {
|
1732 |
Â
throw new TIG_PostNL_Exception(
|
1733 |
-
Mage::helper('postnl')->__(
|
Â
|
|
Â
|
|
Â
|
|
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
|
@@ -1748,10 +2320,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1748 |
Â
* @param string $barcode The barcode to add
|
1749 |
Â
* @param int $barcodeNumber The number of this barcode
|
1750 |
Â
*
|
1751 |
-
* @return
|
1752 |
Â
*/
|
1753 |
Â
protected function _addBarcode($barcode, $barcodeNumber)
|
1754 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
1755 |
Â
$barcodeModel = Mage::getModel('postnl_core/shipment_barcode');
|
1756 |
Â
$barcodeModel->setParentId($this->getId())
|
1757 |
Â
->setBarcode($barcode)
|
@@ -1761,16 +2336,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
1774 |
Â
*/
|
1775 |
Â
public function addLabels($labels)
|
1776 |
Â
{
|
@@ -1797,7 +2372,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1797 |
Â
*
|
1798 |
Â
* @param stdClass $label
|
1799 |
Â
*
|
1800 |
-
* @return
|
1801 |
Â
*/
|
1802 |
Â
protected function _addLabel($label)
|
1803 |
Â
{
|
@@ -1807,6 +2382,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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))
|
@@ -1822,11 +2400,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1822 |
Â
*
|
1823 |
Â
* @param TIG_PostNL_Model_Core_Shipment_Label $label
|
1824 |
Â
*
|
1825 |
-
* @return
|
1826 |
Â
*/
|
1827 |
Â
protected function _addLabelToSave($label)
|
1828 |
Â
{
|
1829 |
-
$labelsToSave = $this->
|
1830 |
Â
|
1831 |
Â
$labelsToSave[] = $label;
|
1832 |
Â
|
@@ -1838,10 +2416,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1838 |
Â
/**
|
1839 |
Â
* Save all newly added labels at once
|
1840 |
Â
*
|
1841 |
-
* @return
|
1842 |
Â
*/
|
1843 |
Â
protected function _saveLabels()
|
1844 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
1845 |
Â
$transactionSave = Mage::getModel('core/resource_transaction');
|
1846 |
Â
|
1847 |
Â
/**
|
@@ -1849,7 +2430,10 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1849 |
Â
*/
|
1850 |
Â
$labelsToSave = $this->getLabelsToSave();
|
1851 |
Â
|
1852 |
-
Mage::dispatchEvent(
|
Â
|
|
Â
|
|
Â
|
|
1853 |
Â
|
1854 |
Â
foreach ($labelsToSave as $label) {
|
1855 |
Â
$transactionSave->addObject($label);
|
@@ -1860,13 +2444,16 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1860 |
Â
*/
|
1861 |
Â
$transactionSave->save();
|
1862 |
Â
|
1863 |
-
Mage::dispatchEvent(
|
Â
|
|
Â
|
|
Â
|
|
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 |
Â
*
|
@@ -1899,9 +2486,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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
|
@@ -1934,9 +2521,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
1934 |
Â
return array_values($sortedHistory);
|
1935 |
Â
}
|
1936 |
Â
|
1937 |
-
|
1938 |
Â
* PRODUCT CODE METHODS
|
1939 |
-
|
1940 |
Â
|
1941 |
Â
/**
|
1942 |
Â
* Gets the product code for this shipment. If specific options have been selected
|
@@ -1975,38 +2562,11 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
-
*
|
1990 |
Â
*/
|
1991 |
-
|
1992 |
-
|
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(
|
2003 |
-
$cifHelper->__('Product code %s is not allowed for this shipment.', $productCode),
|
2004 |
-
'POSTNL-0078'
|
2005 |
-
);
|
2006 |
-
}
|
2007 |
-
|
2008 |
-
$allowedProductCodes = $cifHelper->getGlobalProductCodes();
|
2009 |
-
}
|
2010 |
Â
|
2011 |
Â
/**
|
2012 |
Â
* Check if the product code is allowed
|
@@ -2043,11 +2603,17 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2051 |
Â
|
2052 |
Â
/**
|
2053 |
Â
* Check if the supplied code is restricted
|
@@ -2063,14 +2629,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2063 |
Â
return $allowedCountries;
|
2064 |
Â
}
|
2065 |
Â
|
2066 |
-
|
2067 |
Â
* ADDITIONAL SHIPMENT OPTIONS
|
2068 |
-
|
2069 |
Â
|
2070 |
Â
/**
|
2071 |
Â
* Public alias for _saveAdditionalShippingOptions()
|
2072 |
Â
*
|
2073 |
-
* @return
|
2074 |
Â
*
|
2075 |
Â
* @see TIG_PostNL_Model_Core_Shipment::_saveAdditionalShippingOptions()
|
2076 |
Â
*/
|
@@ -2082,7 +2648,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2082 |
Â
/**
|
2083 |
Â
* Stores additionally selected shipping options
|
2084 |
Â
*
|
2085 |
-
* @return
|
2086 |
Â
*/
|
2087 |
Â
protected function _saveAdditionalShippingOptions()
|
2088 |
Â
{
|
@@ -2099,7 +2665,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2099 |
Â
'postnl_shipment_saveadditionaloptions_after',
|
2100 |
Â
array(
|
2101 |
Â
'shipment' => $this,
|
2102 |
-
'options'
|
2103 |
Â
)
|
2104 |
Â
);
|
2105 |
Â
|
@@ -2128,10 +2694,13 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2128 |
Â
$weight = $this->getTotalWeight(true);
|
2129 |
Â
|
2130 |
Â
/**
|
2131 |
-
* get the weight per parcel
|
Â
|
|
Â
|
|
2132 |
Â
*/
|
2133 |
-
$
|
2134 |
-
$weightPerParcel =
|
Â
|
|
2135 |
Â
|
2136 |
Â
/**
|
2137 |
Â
* calculate the number of parcels needed to ship the total weight of this shipment
|
@@ -2141,9 +2710,9 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2141 |
Â
return $parcelCount;
|
2142 |
Â
}
|
2143 |
Â
|
2144 |
-
|
2145 |
Â
* RESET AND DELETE METHODS
|
2146 |
-
|
2147 |
Â
|
2148 |
Â
/**
|
2149 |
Â
* Resets this shipment to a pre-confirmed state
|
@@ -2161,13 +2730,15 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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()
|
Â
|
|
2171 |
Â
}
|
2172 |
Â
|
2173 |
Â
return $this;
|
@@ -2196,18 +2767,19 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2196 |
Â
/**
|
2197 |
Â
* Removes all labels associated with this shipment
|
2198 |
Â
*
|
2199 |
-
* @return
|
2200 |
Â
*/
|
2201 |
Â
public function deleteLabels()
|
2202 |
Â
{
|
2203 |
-
$labelCollection =
|
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;
|
@@ -2216,15 +2788,17 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2216 |
Â
/**
|
2217 |
Â
* Removes all barcodes associated with this shipment
|
2218 |
Â
*
|
2219 |
-
* @return
|
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);
|
@@ -2235,24 +2809,26 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2235 |
Â
/**
|
2236 |
Â
* Deletes all status history items associated with this shipment
|
2237 |
Â
*
|
2238 |
-
* @return
|
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
|
@@ -2261,24 +2837,28 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2261 |
Â
*/
|
2262 |
Â
protected function _beforeSave()
|
2263 |
Â
{
|
2264 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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 |
Â
*/
|
2283 |
Â
if ($this->getConfirmedStatus() == self::CONFIRM_STATUS_CONFIRMED
|
2284 |
Â
&& $this->getConfirmedAt() === null
|
@@ -2287,14 +2867,14 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
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 |
Â
*/
|
2299 |
Â
if (!$this->getProductCode() || Mage::registry('postnl_product_option') !== null) {
|
2300 |
Â
$productCode = $this->_getProductCode();
|
@@ -2302,7 +2882,7 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2302 |
Â
}
|
2303 |
Â
|
2304 |
Â
/**
|
2305 |
-
* Set the parcel count
|
2306 |
Â
*/
|
2307 |
Â
if (!$this->getParcelCount()) {
|
2308 |
Â
$parcelCount = $this->_calculateParcelCount();
|
@@ -2310,21 +2890,21 @@ class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
|
2310 |
Â
}
|
2311 |
Â
|
2312 |
Â
/**
|
2313 |
-
* Set the confirm date
|
2314 |
Â
*/
|
2315 |
Â
if (!$this->getConfirmDate()) {
|
2316 |
-
$this->setConfirmDate(
|
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 |
Â
|
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 |
+
* @package TIG
|
39 |
+
* @module PostNL
|
40 |
+
* @author Total Internet Group
|
41 |
+
*
|
42 |
+
* PostNL Shipment base class. Contains the majority of PostNL shipping functionality
|
43 |
+
*
|
44 |
+
* Supported events:
|
45 |
+
* - postnl_shipment_generatebarcode_before
|
46 |
+
* - postnl_shipment_generatebarcode_after
|
47 |
+
* - postnl_shipment_generatelabel_before
|
48 |
+
* - postnl_shipment_generatelabel_after
|
49 |
+
* - postnl_shipment_register_confirmation_before
|
50 |
+
* - postnl_shipment_register_confirmation_after
|
51 |
+
* - postnl_shipment_confirm_before
|
52 |
+
* - postnl_shipment_confirm_after
|
53 |
+
* - postnl_shipment_confirmandgeneratelabel_before
|
54 |
+
* - postnl_shipment_confirmandgeneratelabel_after
|
55 |
+
* - postnl_shipment_updateshippingstatus_before
|
56 |
+
* - postnl_shipment_updateshippingstatus_after
|
57 |
+
* - postnl_shipment_updatecompleteshippingstatus_before
|
58 |
+
* - postnl_shipment_updatecompleteshippingstatus_after
|
59 |
+
* - postnl_shipment_savelabels_before
|
60 |
+
* - postnl_shipment_savelabels_after
|
61 |
+
* - postnl_shipment_saveadditionaloptions_after
|
62 |
+
*
|
63 |
+
* @method bool getIsDutchShipment()
|
64 |
+
* @method bool getIsEuShipment()
|
65 |
+
* @method bool getIsGlobalShipment()
|
66 |
+
* @method int getParcelCount()
|
67 |
+
* @method string|null getConfirmedStatus
|
68 |
+
* @method string getStatusHistoryUpdatedAt()
|
69 |
+
* @method string getConfirmStatus()
|
70 |
+
* @method string getMainBarcode()
|
71 |
+
* @method string getCreatedAt()
|
72 |
+
* @method int getIsPakjeGemak()
|
73 |
+
* @method string getConfirmDate()
|
74 |
+
* @method string getUpdatedAt()
|
75 |
+
* @method string getConfirmedAt()
|
76 |
+
* @method int getEntityId()
|
77 |
+
* @method int getIsParcelwareExported()
|
78 |
+
* @method int getTrackAndTraceEmailSent()
|
79 |
+
* @method int getShippingPhase()
|
80 |
+
* @method int getTreatAsAbandoned()
|
81 |
+
* @method int|null getShipmentId
|
82 |
+
* @method int getLabelsPrinted()
|
83 |
+
* @method bool|int getIsPakketautomaat()
|
84 |
+
*
|
85 |
+
* @method TIG_PostNL_Model_Core_Shipment setLabelsPrinted(int $value)
|
86 |
+
* @method TIG_PostNL_Model_Core_Shipment setTreatAsAbandoned(int $value)
|
87 |
+
* @method TIG_PostNL_Model_Core_Shipment setShippingPhase(int $value)
|
88 |
+
* @method TIG_PostNL_Model_Core_Shipment setTrackAndTraceEmailSent(int $value)
|
89 |
+
* @method TIG_PostNL_Model_Core_Shipment setIsParcelwareExported(int $value)
|
90 |
+
* @method TIG_PostNL_Model_Core_Shipment setEntityId(int $value)
|
91 |
+
* @method TIG_PostNL_Model_Core_Shipment setConfirmedAt(string $value)
|
92 |
+
* @method TIG_PostNL_Model_Core_Shipment setUpdatedAt(string $value)
|
93 |
+
* @method TIG_PostNL_Model_Core_Shipment setProductCode(string $value)
|
94 |
+
* @method TIG_PostNL_Model_Core_Shipment setIsPakjeGemak(int $value)
|
95 |
+
* @method TIG_PostNL_Model_Core_Shipment setCreatedAt(string $value)
|
96 |
+
* @method TIG_PostNL_Model_Core_Shipment setShipmentId(int $value)
|
97 |
+
* @method TIG_PostNL_Model_Core_Shipment setMainBarcode(string $value)
|
98 |
+
* @method TIG_PostNL_Model_Core_Shipment setConfirmStatus(string $value)
|
99 |
+
* @method TIG_PostNL_Model_Core_Shipment setStatusHistoryUpdatedAt(string $value)
|
100 |
+
* @method TIG_PostNL_Model_Core_Shipment setShipment(Mage_Sales_Model_Order_Shipment $value)
|
101 |
+
* @method TIG_PostNL_Model_Core_Shipment setShippingAddress(Mage_Sales_Model_Order_Address $value)
|
102 |
+
* @method TIG_PostNL_Model_Core_Shipment setPakjeGemakAddress(Mage_Sales_Model_Order_Address $value)
|
103 |
+
* @method TIG_PostNL_Model_Core_Shipment setStoreId(int $value)
|
104 |
+
* @method TIG_PostNL_Model_Core_Shipment setOrderId(int $value)
|
105 |
+
* @method TIG_PostNL_Model_Core_Shipment setShipmentBaseGrandTotal(float $value)
|
106 |
+
* @method TIG_PostNL_Model_Core_Shipment setBarcodeUrl(string $value)
|
107 |
+
* @method TIG_PostNL_Model_Core_Shipment setPostnlOrder(mixed $value)
|
108 |
+
* @method TIG_PostNL_Model_Core_Shipment setLabelCollection(TIG_PostNL_Model_Core_Resource_Shipment_LabeL_Collection $value)
|
109 |
+
* @method TIG_PostNL_Model_Core_Shipment setDeliveryDate(string $value)
|
110 |
+
* @method TIG_PostNL_Model_Core_Shipment setIsPakketautomaat(bool $value)
|
111 |
+
*
|
112 |
+
* @method bool hasBarcodeUrl()
|
113 |
+
* @method bool hasPostnlOrder()
|
114 |
+
* @method bool hasShipment()
|
115 |
+
* @method bool hasShipmentBaseGrandTotal()
|
116 |
+
* @method bool hasGlobalpackShipmentType()
|
117 |
+
* @method bool hasProductCode()
|
118 |
+
* @method bool hasShippingAddress()
|
119 |
+
* @method bool hasPakjeGemakAddress()
|
120 |
+
* @method bool hasStoreId()
|
121 |
+
* @method bool hasOrderId()
|
122 |
+
* @method bool hasExtraCoverAmount()
|
123 |
+
* @method bool hasLabelCollection()
|
124 |
+
* @method bool hasIsPakketautomaat()
|
125 |
+
* @method bool hasDeliveryDate()
|
126 |
Â
*/
|
127 |
Â
class TIG_PostNL_Model_Core_Shipment extends Mage_Core_Model_Abstract
|
128 |
Â
{
|
129 |
Â
/**
|
130 |
+
* Prefix of model events names.
|
131 |
Â
*
|
132 |
Â
* @var string
|
133 |
Â
*/
|
134 |
Â
protected $_eventPrefix = 'postnl_shipment';
|
135 |
Â
|
136 |
Â
/**
|
137 |
+
* Carrier code used by postnl.
|
138 |
Â
*/
|
139 |
Â
const POSTNL_CARRIER_CODE = 'postnl';
|
140 |
Â
|
141 |
Â
/**
|
142 |
+
* Possible confirm statuses.
|
143 |
Â
*/
|
144 |
Â
const CONFIRM_STATUS_CONFIRMED = 'confirmed';
|
145 |
Â
const CONFIRM_STATUS_UNCONFIRMED = 'unconfirmed';
|
146 |
Â
const CONFIRM_STATUS_CONFIRM_EXPIRED = 'confirm_expired';
|
147 |
Â
|
148 |
Â
/**
|
149 |
+
* Possible shipping phases.
|
150 |
Â
*/
|
151 |
Â
const SHIPPING_PHASE_COLLECTION = '1';
|
152 |
Â
const SHIPPING_PHASE_SORTING = '2';
|
155 |
Â
const SHIPPING_PHASE_NOT_APPLICABLE = '99';
|
156 |
Â
|
157 |
Â
/**
|
158 |
+
* Xpaths to default product options settings.
|
159 |
Â
*/
|
160 |
+
const XPATH_DEFAULT_STANDARD_PRODUCT_OPTION = 'postnl/cif_product_options/default_product_option';
|
161 |
+
const XPATH_DEFAULT_EVENING_PRODUCT_OPTION = 'postnl/cif_product_options/default_evening_product_option';
|
162 |
+
const XPATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION = 'postnl/cif_product_options/default_pakjegemak_product_option';
|
163 |
+
const XPATH_DEFAULT_PGE_PRODUCT_OPTION = 'postnl/cif_product_options/default_pge_product_option';
|
164 |
+
const XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION = 'postnl/cif_product_options/default_pakketautomaat_product_option';
|
165 |
+
const XPATH_DEFAULT_EU_PRODUCT_OPTION = 'postnl/cif_product_options/default_eu_product_option';
|
166 |
+
const XPATH_DEFAULT_GLOBAL_PRODUCT_OPTION = 'postnl/cif_product_options/default_global_product_option';
|
167 |
+
const XPATH_USE_ALTERNATIVE_DEFAULT = 'postnl/cif_product_options/use_alternative_default';
|
168 |
+
const XPATH_ALTERNATIVE_DEFAULT_MAX_AMOUNT = 'postnl/cif_product_options/alternative_default_max_amount';
|
169 |
+
const XPATH_ALTERNATIVE_DEFAULT_OPTION = 'postnl/cif_product_options/alternative_default_option';
|
170 |
Â
|
171 |
Â
/**
|
172 |
+
* Xpath to weight per parcel config setting.
|
173 |
Â
*/
|
174 |
+
const XPATH_WEIGHT_PER_PARCEL = 'postnl/cif_labels_and_confirming/weight_per_parcel';
|
175 |
Â
|
176 |
Â
/**
|
177 |
+
* Xpath to setting that determines whether or not to send track and trace emails.
|
178 |
Â
*/
|
179 |
+
const XPATH_SEND_TRACK_AND_TRACE_EMAIL = 'postnl/cif_labels_and_confirming/send_track_and_trace_email';
|
180 |
Â
|
181 |
Â
/**
|
182 |
+
* Xpath to track and trace email template setting.
|
183 |
Â
*/
|
184 |
+
const XPATH_TRACK_AND_TRACE_EMAIL_TEMPLATE = 'postnl/cif_labels_and_confirming/track_and_trace_email_template';
|
185 |
Â
|
186 |
Â
/**
|
187 |
+
* Xpath to maximum allowed parcel count settings.
|
188 |
Â
*/
|
189 |
+
const XPATH_MAX_PARCEL_COUNT = 'postnl/advanced/max_parcel_count';
|
190 |
Â
|
191 |
Â
/**
|
192 |
+
* Xpath to default GlobalPack shipment type.
|
193 |
+
*/
|
194 |
+
const XPATH_DEFAULT_SHIPMENT_TYPE = 'postnl/cif_globalpack_settings/default_shipment_type';
|
195 |
+
|
196 |
+
/**
|
197 |
+
* CIF warning code returned when an EPS combi label is not available.
|
198 |
Â
*/
|
199 |
Â
const EPS_COMBI_LABEL_WARNING_CODE = 'LIRS_0';
|
200 |
Â
|
201 |
Â
/**
|
202 |
+
* Newly added 'pakje_gemak' address type.
|
203 |
Â
*/
|
204 |
Â
const ADDRESS_TYPE_PAKJEGEMAK = 'pakje_gemak';
|
205 |
Â
|
206 |
Â
/**
|
207 |
+
* Array of product codes that have extra cover.
|
208 |
Â
*
|
209 |
Â
* @var array
|
210 |
Â
*/
|
228 |
Â
protected $_labelsToSave = array();
|
229 |
Â
|
230 |
Â
/**
|
231 |
+
* Contains an instance of TIG_PostNL_Model_Core_Shipment_Process which locks a shipment and prevents it from being
|
232 |
+
* modified.
|
233 |
Â
*
|
234 |
+
* @var TIG_PostNL_Model_Core_Shipment_Process
|
235 |
Â
*/
|
236 |
Â
protected $_process;
|
237 |
Â
|
243 |
Â
$this->_init('postnl_core/shipment');
|
244 |
Â
}
|
245 |
Â
|
246 |
+
/*******************************************************************************************************************
|
247 |
+
* GETTER METHODS
|
248 |
+
******************************************************************************************************************/
|
249 |
Â
|
250 |
Â
/**
|
251 |
Â
* Retrieves a Mage_Sales_Model_Order_Shipment entity linked to the postnl shipment.
|
254 |
Â
*/
|
255 |
Â
public function getShipment()
|
256 |
Â
{
|
257 |
+
if ($this->hasShipment()) {
|
258 |
+
return $this->_getData('shipment');
|
259 |
Â
}
|
260 |
Â
|
261 |
Â
$shipmentId = $this->getShipmentId();
|
263 |
Â
return null;
|
264 |
Â
}
|
265 |
Â
|
266 |
+
/**
|
267 |
+
* @var Mage_Sales_Model_Order_Shipment $shipment
|
268 |
+
*/
|
269 |
Â
$shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
|
270 |
Â
|
271 |
Â
$this->setShipment($shipment);
|
275 |
Â
/**
|
276 |
Â
* Retrieves the linked Shipment's shipping address
|
277 |
Â
*
|
278 |
+
* @return Mage_Sales_Model_Order_Address|null
|
279 |
Â
*/
|
280 |
Â
public function getShippingAddress()
|
281 |
Â
{
|
282 |
+
if ($this->hasShippingAddress()) {
|
283 |
+
return $this->_getData('shipping_address');
|
284 |
Â
}
|
285 |
Â
|
286 |
Â
$shipmentId = $this->getShipmentId();
|
297 |
Â
/**
|
298 |
Â
* Gets an optional address with the pakje_gemak address type
|
299 |
Â
*
|
300 |
+
* @return boolean|Mage_Sales_Model_Order_Address
|
301 |
Â
*/
|
302 |
Â
public function getPakjeGemakAddress()
|
303 |
Â
{
|
304 |
+
if ($this->hasPakjeGemakAddress()) {
|
305 |
+
return $this->_getData('pakje_gemak_address');
|
306 |
Â
}
|
307 |
Â
|
308 |
Â
$shipmentId = $this->getShipmentId();
|
310 |
Â
return null;
|
311 |
Â
}
|
312 |
Â
|
313 |
+
/**
|
314 |
+
* @var Mage_Sales_Model_Order_Address $address
|
315 |
+
*/
|
316 |
Â
$addresses = $this->getShipment()->getOrder()->getAddressesCollection();
|
317 |
Â
foreach ($addresses as $address) {
|
318 |
Â
if ($address->getAddressType() == self::ADDRESS_TYPE_PAKJEGEMAK) {
|
333 |
Â
*/
|
334 |
Â
public function getStoreId()
|
335 |
Â
{
|
336 |
+
if ($this->hasStoreId()) {
|
337 |
+
return $this->_getData('store_id');
|
338 |
Â
}
|
339 |
Â
|
340 |
Â
if ($this->getShipment()) {
|
357 |
Â
*/
|
358 |
Â
public function getOrderId()
|
359 |
Â
{
|
360 |
+
if ($this->hasOrderId()) {
|
361 |
+
return $this->_getData('order_id');
|
362 |
Â
}
|
363 |
Â
|
364 |
Â
$shipment = $this->getShipment();
|
375 |
Â
/**
|
376 |
Â
* Gets a PostNL helper object
|
377 |
Â
*
|
378 |
+
* @param string $type
|
379 |
+
*
|
380 |
+
* @return TIG_PostNL_Helper_Data|TIG_PostNL_Helper_Cif|TIG_PostNL_Helper_Carrier|TIG_PostNL_Helper_Checkout
|
381 |
+
* |TIG_PostNL_Helper_AddressValidation|TIG_PostNL_Helper_DeliveryOptions|TIG_PostNL_Helper_Parcelware
|
382 |
+
* |TIG_PostNL_Helper_Webservices|TIG_PostNL_Helper_Mijnpakket
|
383 |
Â
*/
|
384 |
Â
public function getHelper($type = 'data')
|
385 |
Â
{
|
386 |
+
if ($this->hasData('helper_' . $type)) {
|
387 |
+
return $this->_getData('helper_' . $type);
|
388 |
Â
}
|
389 |
Â
|
390 |
Â
$helper = Mage::helper('postnl/' . $type);
|
402 |
Â
{
|
403 |
Â
$process = $this->_process;
|
404 |
Â
if (is_null($process)) {
|
405 |
+
/**
|
406 |
+
* @var TIG_PostNL_Model_Core_Shipment_Process $process
|
407 |
+
*/
|
408 |
Â
$process = Mage::getModel('postnl_core/shipment_process')
|
409 |
Â
->setId($this->getId());
|
410 |
+
|
411 |
Â
$this->setProcess($process);
|
412 |
Â
}
|
413 |
Â
|
414 |
Â
return $process;
|
415 |
Â
}
|
416 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
417 |
Â
/**
|
418 |
Â
* Get an array of labels that have to be saved together
|
419 |
Â
*
|
420 |
Â
* @return array
|
421 |
Â
*/
|
422 |
+
public function getLabelsToSave()
|
423 |
Â
{
|
424 |
Â
return $this->_labelsToSave;
|
425 |
Â
}
|
441 |
Â
*/
|
442 |
Â
public function getProductCode()
|
443 |
Â
{
|
444 |
+
if ($this->hasProductCode()) {
|
445 |
+
return $this->_getData('product_code');
|
446 |
Â
}
|
447 |
Â
|
448 |
Â
$productCode = $this->_getProductCode();
|
463 |
Â
|
464 |
Â
/**
|
465 |
Â
* If the 'labels_printed' flag is false, yet there are labels present something has gone wrong.
|
466 |
+
* Delete the labels so the extension will generate new ones.
|
467 |
Â
*/
|
468 |
Â
if (!$this->getLabelsPrinted() && $labelCollection->getSize() > 0) {
|
469 |
Â
$this->deleteLabels();
|
477 |
Â
/**
|
478 |
Â
* Get the amount of extra cover this shipment has.
|
479 |
Â
*
|
480 |
+
* @return int|float
|
481 |
Â
*/
|
482 |
Â
public function getExtraCoverAmount()
|
483 |
Â
{
|
484 |
+
if ($this->hasExtraCoverAmount()) {
|
485 |
+
return $this->_getData('extra_cover_amount');
|
486 |
Â
}
|
487 |
Â
|
488 |
Â
return 0;
|
494 |
Â
* @param boolean $standardize Whether or not to convert the weight to kg
|
495 |
Â
* @param boolean $toGrams whether or not to convert the standardized weight to g
|
496 |
Â
*
|
497 |
+
* @return float|int
|
498 |
Â
*/
|
499 |
Â
public function getTotalWeight($standardize = false, $toGrams = false)
|
500 |
Â
{
|
507 |
Â
* calculate the total weight
|
508 |
Â
*/
|
509 |
Â
$weight = 0;
|
510 |
+
/**
|
511 |
+
* @var Mage_Sales_Model_Order_Shipment_Item $item
|
512 |
+
*/
|
513 |
Â
foreach ($items as $item) {
|
514 |
Â
$weight += ($item->getWeight() * $item->getQty());
|
515 |
Â
}
|
519 |
Â
}
|
520 |
Â
|
521 |
Â
/**
|
522 |
+
* Standardize the weight to kg or g.
|
523 |
+
*
|
524 |
+
* @var TIG_PostNL_Helper_Cif $helper
|
525 |
Â
*/
|
526 |
+
$helper = $this->getHelper('cif');
|
527 |
+
$weight = $helper->standardizeWeight(
|
528 |
Â
$weight,
|
529 |
Â
$this->getStoreId(),
|
530 |
Â
$toGrams
|
536 |
Â
/**
|
537 |
Â
* Calculates a shipment's base grand total based on it's shipment items
|
538 |
Â
*
|
539 |
+
* @return float|null
|
540 |
Â
*/
|
541 |
Â
public function getShipmentBaseGrandTotal()
|
542 |
Â
{
|
543 |
+
if ($this->hasShipmentBaseGrandTotal()) {
|
544 |
+
return $this->_getData('shipment_base_grand_total');
|
545 |
Â
}
|
546 |
Â
|
547 |
Â
/**
|
557 |
Â
*/
|
558 |
Â
$baseGrandTotal = 0;
|
559 |
Â
$shipmentItems = $shipment->getAllItems();
|
560 |
+
|
561 |
+
/**
|
562 |
+
* @var Mage_Sales_Model_Order_Shipment_Item $shipmentItem
|
563 |
+
*/
|
564 |
Â
foreach ($shipmentItems as $shipmentItem) {
|
565 |
Â
$qty = $shipmentItem->getQty();
|
566 |
+
|
567 |
Â
/**
|
568 |
Â
* The base price of a shipment item is only available through it's associated order item
|
569 |
Â
*/
|
592 |
Â
public function getBarcodeUrl($forceNl = false)
|
593 |
Â
{
|
594 |
Â
if ($this->hasBarcodeUrl()) {
|
595 |
+
return $this->_getData('barcode_url');
|
596 |
Â
}
|
597 |
Â
|
598 |
Â
$barcode = $this->getMainBarcode();
|
600 |
Â
return false;
|
601 |
Â
}
|
602 |
Â
|
603 |
+
/**
|
604 |
+
* @var TIG_PostNL_Helper_Carrier $helper
|
605 |
+
*/
|
606 |
Â
$helper = $this->getHelper('carrier');
|
607 |
Â
|
608 |
Â
$locale = Mage::getStoreConfig('general/locale/code', $this->getStoreId());
|
615 |
Â
}
|
616 |
Â
|
617 |
Â
/**
|
618 |
+
* Gets the shipment's shipment type for intrnational shipments. If no shipment type is defined, use the default
|
619 |
+
* value. This in turn defaults to 'Commercial Goods' if none is specified.
|
620 |
Â
*
|
621 |
+
* @return string|null
|
622 |
Â
*/
|
623 |
+
public function getGlobalpackShipmentType()
|
624 |
Â
{
|
625 |
+
if ($this->hasGlobalpackShipmentType()) {
|
626 |
+
return $this->_getData('globalpack_shipment_type');
|
627 |
Â
}
|
628 |
Â
|
629 |
Â
if (!$this->isGlobalShipment()) {
|
630 |
Â
return null;
|
631 |
Â
}
|
632 |
Â
|
633 |
+
$defaultShipmentType = Mage::getStoreConfig(self::XPATH_DEFAULT_SHIPMENT_TYPE, $this->getStoreId());
|
634 |
+
if (!$defaultShipmentType) {
|
635 |
+
$defaultShipmentType = 'Commercial Goods';
|
636 |
+
}
|
637 |
+
|
638 |
+
return $defaultShipmentType;
|
639 |
Â
}
|
640 |
Â
|
641 |
Â
/**
|
642 |
Â
* Gets the default product code for this shipment from the module's configuration
|
643 |
Â
*
|
644 |
Â
* @return string
|
Â
|
|
Â
|
|
645 |
Â
*/
|
646 |
Â
public function getDefaultProductCode()
|
647 |
Â
{
|
648 |
Â
$storeId = $this->getStoreId();
|
649 |
Â
|
650 |
+
$xpath = false;
|
651 |
+
if ($this->isPgeShipment()) {
|
652 |
+
/**
|
653 |
+
* PakjeGemak Express default option
|
654 |
+
*/
|
655 |
+
$xpath = self::XPATH_DEFAULT_PGE_PRODUCT_OPTION;
|
656 |
+
} elseif ($this->isAvondshipment()) {
|
657 |
+
/**
|
658 |
+
* Evening delivery default option
|
659 |
+
*/
|
660 |
+
$xpath = self::XPATH_DEFAULT_EVENING_PRODUCT_OPTION;
|
661 |
+
} elseif ($this->isPakjeGemakShipment()) {
|
662 |
Â
/**
|
663 |
Â
* PakjeGemak default option
|
664 |
Â
*/
|
665 |
+
$xpath = self::XPATH_DEFAULT_PAKJEGEMAK_PRODUCT_OPTION;
|
666 |
+
} elseif ($this->isPakketautomaatShipment()) {
|
667 |
+
/**
|
668 |
+
* PakjeGemak default option
|
669 |
+
*/
|
670 |
+
$xpath = self::XPATH_DEFAULT_PAKKETAUTOMAAT_PRODUCT_OPTION;
|
671 |
+
} elseif ($this->isEuShipment()) {
|
672 |
Â
/**
|
673 |
Â
* EU default option
|
674 |
Â
*/
|
675 |
+
$xpath = self::XPATH_DEFAULT_EU_PRODUCT_OPTION;
|
676 |
+
} elseif ($this->isGlobalShipment()) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
677 |
Â
/**
|
678 |
Â
* Global default option
|
679 |
Â
*/
|
680 |
+
$xpath = self::XPATH_DEFAULT_GLOBAL_PRODUCT_OPTION;
|
Â
|
|
Â
|
|
Â
|
|
681 |
Â
}
|
682 |
Â
|
683 |
Â
/**
|
685 |
Â
*/
|
686 |
Â
|
687 |
Â
/**
|
688 |
+
* Dutch shipments may use an alternative default option when the shipment's base grandtotal exceeds a specified
|
689 |
+
* amount.
|
690 |
Â
*/
|
691 |
+
$useAlternativeDefault = Mage::getStoreConfig(self::XPATH_USE_ALTERNATIVE_DEFAULT, $storeId);
|
692 |
+
if (!$xpath && $useAlternativeDefault) {
|
693 |
Â
/**
|
694 |
Â
* Alternative default option usage is enabled
|
695 |
Â
*/
|
696 |
+
$maxShipmentAmount = Mage::getStoreConfig(self::XPATH_ALTERNATIVE_DEFAULT_MAX_AMOUNT, $storeId);
|
697 |
Â
if ($this->getShipmentBaseGrandTotal() > $maxShipmentAmount) {
|
698 |
Â
/**
|
699 |
+
* The shipment's base grand total exceeds the specified amount: use the alternative default
|
700 |
Â
*/
|
701 |
+
$xpath = self::XPATH_ALTERNATIVE_DEFAULT_OPTION;
|
Â
|
|
Â
|
|
Â
|
|
702 |
Â
}
|
703 |
Â
}
|
704 |
Â
|
705 |
+
if (!$xpath) {
|
706 |
+
$xpath = self::XPATH_DEFAULT_STANDARD_PRODUCT_OPTION;
|
707 |
+
}
|
708 |
+
|
709 |
Â
/**
|
710 |
Â
* standard default option
|
711 |
Â
*/
|
712 |
+
$productCode = Mage::getStoreConfig($xpath, $storeId);
|
713 |
Â
$this->_checkProductCodeAllowed($productCode);
|
714 |
Â
|
715 |
Â
return $productCode;
|
718 |
Â
/**
|
719 |
Â
* Get a specific barcode for this shipment
|
720 |
Â
*
|
721 |
+
* @param int|null $barcodeNumber Which barcode to get
|
722 |
Â
*
|
723 |
+
* @return string|null
|
724 |
Â
*/
|
725 |
Â
public function getBarcode($barcodeNumber = null)
|
726 |
Â
{
|
729 |
Â
return $barcode;
|
730 |
Â
}
|
731 |
Â
|
732 |
+
/**
|
733 |
+
* @var TIG_PostNL_Model_Core_Shipment_Barcode $barcode
|
734 |
+
*/
|
735 |
+
$barcode = Mage::getModel('postnl_core/shipment_barcode');
|
736 |
+
$barcode->loadByParentAndBarcodeNumber($this->getId(), $barcodeNumber);
|
737 |
Â
|
738 |
Â
return $barcode->getBarcode();
|
739 |
Â
}
|
741 |
Â
/**
|
742 |
Â
* Get all barcodes associated with this shipment
|
743 |
Â
*
|
744 |
+
* @param boolean $asObject Optional value to get the barcodes as entities, rather than an array of values
|
745 |
Â
*
|
746 |
Â
* @return array
|
747 |
Â
*/
|
773 |
Â
return $barcodeCollection->getItems();
|
774 |
Â
}
|
775 |
Â
|
776 |
+
/**
|
777 |
+
* Alias for magic getIsParcelwareExported()
|
778 |
+
*
|
779 |
+
* @return string
|
780 |
+
*/
|
781 |
+
public function getIsExported()
|
782 |
+
{
|
783 |
+
return $this->getIsParcelwareExported();
|
784 |
+
}
|
785 |
+
|
786 |
+
/**
|
787 |
+
* Gets a PostNL order associated with this shipment (if any exist)
|
788 |
+
*
|
789 |
+
* @return boolean|TIG_PostNL_Model_Core_Order
|
790 |
+
*/
|
791 |
+
public function getPostnlOrder()
|
792 |
+
{
|
793 |
+
if ($this->hasPostnlOrder()) {
|
794 |
+
return $this->_getData('postnl_order');
|
795 |
+
}
|
796 |
+
|
797 |
+
$postnlOrder = Mage::getModel('postnl_core/order')->load($this->getOrderId(), 'order_id');
|
798 |
+
if (!$postnlOrder->getId()) {
|
799 |
+
$this->setPostnlOrder(false);
|
800 |
+
|
801 |
+
return false;
|
802 |
+
}
|
803 |
+
|
804 |
+
$this->setPostnlOrder($postnlOrder);
|
805 |
+
return $postnlOrder;
|
806 |
+
}
|
807 |
+
|
808 |
+
/**
|
809 |
+
* Get collection object for this shipment's labels.
|
810 |
+
*
|
811 |
+
* @return TIG_PostNL_Model_Core_Resource_Shipment_Label_Collection
|
812 |
+
*/
|
813 |
+
public function getLabelCollection()
|
814 |
+
{
|
815 |
+
if ($this->hasLabelCollection()) {
|
816 |
+
return $this->_getData('label_collection');
|
817 |
+
}
|
818 |
+
|
819 |
+
$labelCollection = Mage::getResourceModel('postnl_core/shipment_label_collection');
|
820 |
+
$labelCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
|
821 |
+
|
822 |
+
$this->setLabelCollection($labelCollection);
|
823 |
+
return $labelCollection;
|
824 |
+
}
|
825 |
+
|
826 |
+
/**
|
827 |
+
* Gets allowed product codes for the current shipment.
|
828 |
+
*
|
829 |
+
* @return array
|
830 |
+
*
|
831 |
+
* @throws TIG_PostNL_Exception
|
832 |
+
*/
|
833 |
+
public function getAllowedProductCodes()
|
834 |
+
{
|
835 |
+
$cifHelper = $this->getHelper('cif');
|
836 |
+
|
837 |
+
/**
|
838 |
+
* Please note the order of these checks as PakjeGemak, PakjeGemak Express, avond and pakketautomaat shipment
|
839 |
+
* would all also be considered Dutch shipments.
|
840 |
+
*/
|
841 |
+
|
842 |
+
if ($this->isPgeShipment()) {
|
843 |
+
$allowedProductCodes = $cifHelper->getPgeProductCodes();
|
844 |
+
return $allowedProductCodes;
|
845 |
+
}
|
846 |
+
|
847 |
+
if ($this->isAvondShipment()) {
|
848 |
+
$allowedProductCodes = $cifHelper->getAvondProductCodes();
|
849 |
+
return $allowedProductCodes;
|
850 |
+
}
|
851 |
+
|
852 |
+
if ($this->isPakjeGemakShipment()) {
|
853 |
+
$allowedProductCodes = $cifHelper->getPakjeGemakProductCodes();
|
854 |
+
return $allowedProductCodes;
|
855 |
+
}
|
856 |
+
|
857 |
+
if ($this->isPakketautomaatShipment()) {
|
858 |
+
$allowedProductCodes = $cifHelper->getPakketautomaatProductCodes();
|
859 |
+
return $allowedProductCodes;
|
860 |
+
}
|
861 |
+
|
862 |
+
if ($this->isDutchShipment()) {
|
863 |
+
$allowedProductCodes = $cifHelper->getStandardProductCodes();
|
864 |
+
return $allowedProductCodes;
|
865 |
+
}
|
866 |
+
|
867 |
+
if ($this->isEuShipment()) {
|
868 |
+
$allowedProductCodes = $cifHelper->getEuProductCodes();
|
869 |
+
return $allowedProductCodes;
|
870 |
+
}
|
871 |
+
|
872 |
+
if ($this->isGlobalShipment() && $cifHelper->isGlobalAllowed()) {
|
873 |
+
$allowedProductCodes = $cifHelper->getGlobalProductCodes();
|
874 |
+
return $allowedProductCodes;
|
875 |
+
}
|
876 |
+
|
877 |
+
/**
|
878 |
+
* If no matches were found, return an empty array.
|
879 |
+
*/
|
880 |
+
return array();
|
881 |
+
}
|
882 |
+
|
883 |
+
/**
|
884 |
+
* Gets the delivery date for this shipment.
|
885 |
+
*
|
886 |
+
* @return null|string
|
887 |
+
*/
|
888 |
+
public function getDeliveryDate()
|
889 |
+
{
|
890 |
+
if ($this->hasDeliveryDate()) {
|
891 |
+
return $this->_getData('delivery_date');
|
892 |
+
}
|
893 |
+
|
894 |
+
/**
|
895 |
+
* Try to get the delivery date fr a PostNL order.
|
896 |
+
*/
|
897 |
+
$postnlOrder = $this->getPostnlOrder();
|
898 |
+
if ($postnlOrder && $postnlOrder->getDeliveryDate()) {
|
899 |
+
$deliveryDate = $postnlOrder->getDeliveryDate();
|
900 |
+
|
901 |
+
$this->setDeliveryDate($deliveryDate);
|
902 |
+
return $deliveryDate;
|
903 |
+
}
|
904 |
+
|
905 |
+
/**
|
906 |
+
* If no delivery date is available, return null.
|
907 |
+
*/
|
908 |
+
return null;
|
909 |
+
}
|
910 |
+
|
911 |
+
/*******************************************************************************************************************
|
912 |
Â
* SETTER METHODS
|
913 |
+
******************************************************************************************************************/
|
914 |
Â
|
915 |
Â
/**
|
916 |
Â
* Set an array of labels that are to be saved together
|
917 |
Â
*
|
918 |
Â
* @param array $labels
|
919 |
Â
*
|
920 |
+
* @return $this
|
921 |
Â
*/
|
922 |
Â
public function setLabelsToSave($labels)
|
923 |
Â
{
|
931 |
Â
*
|
932 |
Â
* @param int $amount
|
933 |
Â
*
|
934 |
+
* @return boolean|TIG_PostNL_Model_Core_Shipment
|
935 |
Â
*/
|
936 |
Â
public function setExtraCoverAmount($amount)
|
937 |
Â
{
|
941 |
Â
$productCode = $this->getProductCode();
|
942 |
Â
$extraCoverProductCodes = $this->getExtraCoverProductCodes();
|
943 |
Â
if (!in_array($productCode, $extraCoverProductCodes)) {
|
944 |
+
return false;
|
945 |
Â
}
|
946 |
Â
|
947 |
Â
$this->setData('extra_cover_amount', $amount);
|
954 |
Â
*
|
955 |
Â
* @param string $type
|
956 |
Â
*
|
957 |
+
* @return $this
|
958 |
Â
*/
|
959 |
+
public function setGlobalpackShipmentType($type)
|
960 |
Â
{
|
961 |
Â
/**
|
962 |
Â
* Only global shipments have a shipment type
|
971 |
Â
$shipmentType = str_replace('_', ' ', $type);
|
972 |
Â
$shipmentType = ucwords($shipmentType);
|
973 |
Â
|
974 |
+
$this->setData('globalpack_shipment_type', $shipmentType);
|
975 |
Â
return $this;
|
976 |
Â
}
|
977 |
Â
|
980 |
Â
*
|
981 |
Â
* @param int $count
|
982 |
Â
*
|
983 |
+
* @throws TIG_PostNL_Exception
|
984 |
+
*
|
985 |
+
* @return $this
|
986 |
Â
*/
|
987 |
Â
public function setParcelCount($count)
|
988 |
Â
{
|
989 |
+
$maxParcelCount = Mage::getStoreConfig(self::XPATH_MAX_PARCEL_COUNT, Mage_Core_Model_App::ADMIN_STORE_ID);
|
990 |
Â
if (!$maxParcelCount) {
|
991 |
Â
$this->setData('parcel_count', $count);
|
992 |
Â
return $this;
|
1007 |
Â
return $this;
|
1008 |
Â
}
|
1009 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1010 |
Â
/**
|
1011 |
+
* Alias for magic setIsParcelwareExported()
|
1012 |
+
*
|
1013 |
+
* @param mixed $isExported
|
1014 |
Â
*
|
1015 |
+
* @return $this
|
1016 |
Â
*/
|
1017 |
+
public function setIsExported($isExported)
|
1018 |
Â
{
|
1019 |
+
return $this->setIsParcelwareExported($isExported);
|
Â
|
|
Â
|
|
Â
|
|
1020 |
Â
}
|
1021 |
Â
|
1022 |
Â
/**
|
1023 |
+
* Sets the process used for locking and unlocking this shipment
|
1024 |
Â
*
|
1025 |
+
* @param TIG_PostNL_Model_Core_Shipment_Process
|
1026 |
+
*
|
1027 |
+
* @return $this
|
1028 |
Â
*/
|
1029 |
+
public function setProcess(TIG_PostNL_Model_Core_Shipment_Process $process)
|
1030 |
Â
{
|
1031 |
+
$this->_process = $process;
|
Â
|
|
1032 |
Â
|
1033 |
Â
return $this;
|
1034 |
Â
}
|
1035 |
Â
|
1036 |
Â
/**
|
1037 |
+
* Sets the confirm date. If no value is supplied, check if this shipment has an associated PostNL order which might
|
1038 |
+
* have a confirm date specified. Otherwise calculate the confirm date based on the delivery date or the current
|
1039 |
+
* timestamp.
|
1040 |
Â
*
|
1041 |
+
* @param boolean|string $date
|
1042 |
+
*
|
1043 |
+
* @return $this
|
1044 |
Â
*/
|
1045 |
+
public function setConfirmDate($date = false)
|
1046 |
Â
{
|
1047 |
+
if ($date !== false) {
|
1048 |
+
$this->setData('confirm_date', $date);
|
1049 |
+
return $this;
|
1050 |
+
}
|
1051 |
Â
|
1052 |
+
/**
|
1053 |
+
* If this shipment has an associated PostNL order with a confirm date, use that.
|
1054 |
+
*/
|
1055 |
+
$postnlOrder = $this->getPostnlOrder();
|
1056 |
+
if ($postnlOrder && $postnlOrder->getConfirmDate()) {
|
1057 |
+
$confirmDate = strtotime($postnlOrder->getConfirmDate());
|
1058 |
+
|
1059 |
+
$this->setData('confirm_date', $confirmDate);
|
1060 |
+
return $this;
|
1061 |
+
}
|
1062 |
+
|
1063 |
+
/**
|
1064 |
+
* Get the requested delivery date for this shipment.
|
1065 |
+
*/
|
1066 |
+
$deliveryDate = $this->getDeliveryDate();
|
1067 |
+
|
1068 |
+
/**
|
1069 |
+
* If no delivery date is available, set the confirm date to today.
|
1070 |
+
*/
|
1071 |
+
if (!$deliveryDate) {
|
1072 |
+
$confirmDate = Mage::getModel('core/date')->gmtTimestamp();
|
1073 |
+
|
1074 |
+
$this->setData('confirm_date', $confirmDate);
|
1075 |
+
return $this;
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
* Calculate the confirm based on the delivery date.
|
1080 |
+
*/
|
1081 |
+
$deliveryTimeStamp = strtotime($deliveryDate);
|
1082 |
+
$confirmDate = strtotime('-1 day', $deliveryTimeStamp);
|
1083 |
+
|
1084 |
+
$this->setData('confirm_date', $confirmDate);
|
1085 |
+
return $this;
|
1086 |
Â
}
|
1087 |
Â
|
1088 |
+
/*******************************************************************************************************************
|
1089 |
Â
* HAS- METHODS
|
1090 |
+
******************************************************************************************************************/
|
1091 |
Â
|
1092 |
Â
/**
|
1093 |
Â
* Check if the shipment has any associated labels
|
1136 |
Â
*/
|
1137 |
Â
public function hasLabelType($labelType)
|
1138 |
Â
{
|
1139 |
+
/**
|
1140 |
+
* @var Mage_Core_Model_Resource $coreResource
|
1141 |
+
*/
|
1142 |
Â
$coreResource = Mage::getSingleton('core/resource');
|
1143 |
Â
$readConn = $coreResource->getConnection('core/read');
|
1144 |
Â
|
1156 |
Â
return true;
|
1157 |
Â
}
|
1158 |
Â
|
1159 |
+
/*******************************************************************************************************************
|
1160 |
Â
* IS- AND CAN- METHODS
|
1161 |
+
******************************************************************************************************************/
|
1162 |
Â
|
1163 |
Â
/**
|
1164 |
Â
* Alias for magic getIsPakjeGemak()
|
1165 |
Â
*
|
1166 |
+
* Please note the difference between this method and TIG_PostNL_Model_Core_Shipment::isPakjeGemakShipment()
|
1167 |
Â
*
|
1168 |
Â
* @return integer
|
1169 |
Â
*/
|
1179 |
Â
*/
|
1180 |
Â
public function isDutchShipment()
|
1181 |
Â
{
|
1182 |
+
if ($this->getIsDutchShipment()) {
|
1183 |
+
return true;
|
1184 |
+
}
|
1185 |
+
|
1186 |
Â
$shippingDestination = $this->getShippingAddress()->getCountryId();
|
1187 |
Â
|
1188 |
Â
if ($shippingDestination == 'NL') {
|
1199 |
Â
*/
|
1200 |
Â
public function isEuShipment()
|
1201 |
Â
{
|
1202 |
+
if ($this->getIsEuShipment()) {
|
1203 |
+
return true;
|
1204 |
+
}
|
1205 |
+
|
1206 |
Â
$shippingDestination = $this->getShippingAddress()->getCountryId();
|
1207 |
Â
|
1208 |
+
/**
|
1209 |
+
* @var TIG_PostNL_Helper_Cif $helper
|
1210 |
+
*/
|
1211 |
+
$helper = $this->getHelper('cif');
|
1212 |
+
$euCountries = $helper->getEuCountries();
|
1213 |
Â
|
1214 |
Â
if (in_array($shippingDestination, $euCountries)) {
|
1215 |
Â
return true;
|
1225 |
Â
*/
|
1226 |
Â
public function isGlobalShipment()
|
1227 |
Â
{
|
1228 |
+
if ($this->getIsGlobalShipment()) {
|
1229 |
+
return true;
|
1230 |
+
}
|
1231 |
+
|
1232 |
Â
if (!$this->isDutchShipment() && !$this->isEuShipment()) {
|
1233 |
Â
return true;
|
1234 |
Â
}
|
1236 |
Â
return false;
|
1237 |
Â
}
|
1238 |
Â
|
1239 |
+
/**
|
1240 |
+
* Check if this shipment is a PakjeGemak Express shipment.
|
1241 |
+
*
|
1242 |
+
* @return bool
|
1243 |
+
*/
|
1244 |
+
public function isPgeShipment()
|
1245 |
+
{
|
1246 |
+
/**
|
1247 |
+
* We can check the PostNL order's type to see if it's PakjeGemak Express.
|
1248 |
+
*
|
1249 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
1250 |
+
*/
|
1251 |
+
$postnlOrder = $this->getPostnlOrder();
|
1252 |
+
if (!$postnlOrder
|
1253 |
+
|| !$postnlOrder->getId()
|
1254 |
+
) {
|
1255 |
+
return false;
|
1256 |
+
}
|
1257 |
+
|
1258 |
+
$type = $postnlOrder->getType();
|
1259 |
+
if ($type != 'PGE') {
|
1260 |
+
return false;
|
1261 |
+
}
|
1262 |
+
|
1263 |
+
return true;
|
1264 |
+
}
|
1265 |
+
|
1266 |
+
/**
|
1267 |
+
* Check if this shipment is an evening delivery shipment.
|
1268 |
+
*
|
1269 |
+
* @return bool
|
1270 |
+
*/
|
1271 |
+
public function isAvondShipment()
|
1272 |
+
{
|
1273 |
+
/**
|
1274 |
+
* We can check the PostNL order's type to see if it's evening delivery.
|
1275 |
+
*
|
1276 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
1277 |
+
*/
|
1278 |
+
$postnlOrder = $this->getPostnlOrder();
|
1279 |
+
if (!$postnlOrder
|
1280 |
+
|| !$postnlOrder->getId()
|
1281 |
+
) {
|
1282 |
+
return false;
|
1283 |
+
}
|
1284 |
+
|
1285 |
+
$type = $postnlOrder->getType();
|
1286 |
+
if ($type != 'Avond') {
|
1287 |
+
return false;
|
1288 |
+
}
|
1289 |
+
|
1290 |
+
return true;
|
1291 |
+
}
|
1292 |
+
|
1293 |
Â
/**
|
1294 |
Â
* Check if the currrent shipment is a PakjeGemak shipment.
|
1295 |
Â
*
|
1301 |
Â
return true;
|
1302 |
Â
}
|
1303 |
Â
|
1304 |
+
/**
|
1305 |
+
* If the order was placed using PostNL Checkout, we can check if it was a PakjeGemak order directly.
|
1306 |
+
*
|
1307 |
+
* @var TIG_PostNL_Model_Core_Order $postnlOrder
|
1308 |
+
*/
|
1309 |
+
$postnlOrder = $this->getPostnlOrder();
|
1310 |
+
if ($postnlOrder
|
1311 |
+
&& $postnlOrder->getId()
|
1312 |
+
&& $postnlOrder->getIsPakjeGemak()
|
1313 |
+
) {
|
1314 |
Â
return true;
|
1315 |
Â
}
|
1316 |
Â
|
1317 |
+
/**
|
1318 |
+
* Otherwise we need to check the product code by comparing it to known PakjeGemak product codes.
|
1319 |
+
*
|
1320 |
+
* @var TIG_PostNL_Helper_Cif $helper
|
1321 |
+
*/
|
1322 |
+
$helper = $this->getHelper('cif');
|
1323 |
+
$pakjeGemakProductCodes = $helper->getPakjeGemakProductCodes();
|
1324 |
+
$productCode = $this->_getData('product_code');
|
1325 |
Â
|
1326 |
Â
if (!$productCode) {
|
1327 |
Â
return false;
|
1335 |
Â
return false;
|
1336 |
Â
}
|
1337 |
Â
|
1338 |
+
/**
|
1339 |
+
* Check if this shipment is a pakketautomaat shipment.
|
1340 |
+
*
|
1341 |
+
* @return boolean
|
1342 |
+
*/
|
1343 |
+
public function isPakketautomaatShipment()
|
1344 |
+
{
|
1345 |
+
if ($this->hasIsPakketautomaat()) {
|
1346 |
+
return $this->getIsPakketautomaat();
|
1347 |
+
}
|
1348 |
+
|
1349 |
+
$postnlOrder = $this->getPostnlOrder();
|
1350 |
+
if (!$postnlOrder
|
1351 |
+
|| !$postnlOrder->getId()
|
1352 |
+
|| !$postnlOrder->getType()
|
1353 |
+
) {
|
1354 |
+
$this->setIsPakketautomaat(false);
|
1355 |
+
return false;
|
1356 |
+
}
|
1357 |
+
|
1358 |
+
$type = $postnlOrder->getType();
|
1359 |
+
if ($type == 'PA') {
|
1360 |
+
$this->setIsPakketautomaat(true);
|
1361 |
+
return true;
|
1362 |
+
}
|
1363 |
+
|
1364 |
+
return false;
|
1365 |
+
}
|
1366 |
+
|
1367 |
Â
/**
|
1368 |
Â
* Checks if this shipment is a COD shipment
|
1369 |
Â
*
|
1373 |
Â
*/
|
1374 |
Â
public function isCod()
|
1375 |
Â
{
|
1376 |
+
return false;
|
1377 |
Â
}
|
1378 |
Â
|
1379 |
Â
/**
|
1391 |
Â
return false;
|
1392 |
Â
}
|
1393 |
Â
|
1394 |
+
/**
|
1395 |
+
* Alias for isParcelwareExported()
|
1396 |
+
*
|
1397 |
+
* @return boolean
|
1398 |
+
*/
|
1399 |
+
public function isExported()
|
1400 |
+
{
|
1401 |
+
return $this->isParcelwareExported();
|
1402 |
+
}
|
1403 |
+
|
1404 |
+
/**
|
1405 |
+
* Checks if this shipment has been exported to parcelware
|
1406 |
+
*
|
1407 |
+
* @return boolean
|
1408 |
+
*/
|
1409 |
+
public function isParcelwareExported()
|
1410 |
+
{
|
1411 |
+
$isExported = (bool) $this->getIsParcelwareExported();
|
1412 |
+
|
1413 |
+
return $isExported;
|
1414 |
+
}
|
1415 |
+
|
1416 |
Â
/**
|
1417 |
Â
* Checks if the current entity may generate a barcode.
|
1418 |
Â
*
|
1430 |
Â
/**
|
1431 |
Â
* Checks if the current entity can be confirmed.
|
1432 |
Â
*
|
1433 |
+
* @param bool $skipEuCheck
|
1434 |
+
*
|
1435 |
Â
* @return boolean
|
1436 |
Â
*/
|
1437 |
Â
public function canConfirm($skipEuCheck = false)
|
1464 |
Â
|
1465 |
Â
/**
|
1466 |
Â
* Checks if the current shipment is eligible for a shipping status update.
|
1467 |
+
* Unconfirmed shipments, shipments whose labels are not yet printed or shipments that are already delivered are
|
1468 |
+
* inelligible.
|
1469 |
Â
*
|
1470 |
Â
* @return boolean
|
1471 |
Â
*/
|
1500 |
Â
|
1501 |
Â
/**
|
1502 |
Â
* Checks if the current shipment is eligible for a complete shipping status update.
|
1503 |
+
* For now the same conditions apply as a regular status update. This may change in a future update of the
|
1504 |
+
* extension.
|
1505 |
Â
*
|
1506 |
Â
* @return boolean
|
1507 |
Â
*
|
1516 |
Â
* Checks if the current shipment can send a track & trace email to the customer.
|
1517 |
Â
*
|
1518 |
Â
* @param boolean $ignoreAlreadySent Flag to ignore the 'already sent' check
|
1519 |
+
* @param boolean $ignoreConfig Flag to ignore the 'send_track_and_trace_email' config setting.
|
1520 |
Â
*
|
1521 |
Â
* @return boolean
|
1522 |
Â
*/
|
1523 |
+
public function canSendTrackAndTraceEmail($ignoreAlreadySent = false, $ignoreConfig = false)
|
1524 |
Â
{
|
1525 |
Â
if ($this->isLocked()) {
|
1526 |
Â
return false;
|
1530 |
Â
return false;
|
1531 |
Â
}
|
1532 |
Â
|
1533 |
+
if ($ignoreConfig !== true) {
|
1534 |
+
$storeId = $this->getStoreId();
|
1535 |
+
$canSendTrackAndTrace = Mage::getStoreConfig(self::XPATH_SEND_TRACK_AND_TRACE_EMAIL, $storeId);
|
1536 |
+
if (!$canSendTrackAndTrace) {
|
1537 |
+
return false;
|
1538 |
+
}
|
1539 |
Â
}
|
1540 |
Â
|
1541 |
Â
return true;
|
1569 |
Â
return true;
|
1570 |
Â
}
|
1571 |
Â
|
1572 |
+
/*******************************************************************************************************************
|
1573 |
+
* SHIPMENT LOCKING AND UNLOCKING FUNCTIONS
|
1574 |
+
******************************************************************************************************************/
|
1575 |
+
|
1576 |
+
/**
|
1577 |
+
* Lock this shipment to prevent simultaneous execution
|
1578 |
+
*
|
1579 |
+
* @return $this
|
1580 |
+
*/
|
1581 |
+
public function lock()
|
1582 |
+
{
|
1583 |
+
$process = $this->getProcess();
|
1584 |
+
$process->lockAndBlock();
|
1585 |
+
|
1586 |
+
$this->isLocked();
|
1587 |
+
$this->isLocked();
|
1588 |
+
return $this;
|
1589 |
+
}
|
1590 |
+
|
1591 |
+
/**
|
1592 |
+
* Unlock this shipment
|
1593 |
+
*
|
1594 |
+
* @return $this
|
1595 |
+
*/
|
1596 |
+
public function unlock()
|
1597 |
+
{
|
1598 |
+
$process = $this->getProcess();
|
1599 |
+
$process->unlock();
|
1600 |
+
|
1601 |
+
return $this;
|
1602 |
+
}
|
1603 |
+
|
1604 |
+
/**
|
1605 |
+
* Check if this shipment is locked
|
1606 |
+
*
|
1607 |
+
* @return boolean
|
1608 |
+
*/
|
1609 |
+
public function isLocked()
|
1610 |
+
{
|
1611 |
+
$process = $this->getProcess();
|
1612 |
+
$isLocked = $process->isLocked();
|
1613 |
+
|
1614 |
+
return $isLocked;
|
1615 |
+
}
|
1616 |
+
|
1617 |
+
/*******************************************************************************************************************
|
1618 |
Â
* CIF FUNCTIONALITY METHODS
|
1619 |
+
******************************************************************************************************************/
|
1620 |
Â
|
1621 |
Â
/**
|
1622 |
Â
* Generates barcodes for this postnl shipment.
|
1623 |
+
* Barcodes are the basis for all CIF functionality and must therefore be generated before any further action is
|
1624 |
+
* possible.
|
1625 |
Â
*
|
1626 |
+
* @return $this
|
1627 |
Â
*
|
1628 |
Â
* @throws TIG_PostNL_Exception
|
1629 |
Â
*/
|
1652 |
Â
}
|
1653 |
Â
|
1654 |
Â
/**
|
1655 |
+
* If this shipment consists of a single parcel we only need the main barcode
|
1656 |
Â
*/
|
1657 |
+
if ($parcelCount < 2) {
|
1658 |
Â
Mage::dispatchEvent('postnl_shipment_generatebarcode_after', array('shipment' => $this));
|
1659 |
Â
$this->unlock();
|
1660 |
Â
|
1680 |
Â
* @return string
|
1681 |
Â
*
|
1682 |
Â
* @throws TIG_PostNL_Exception
|
1683 |
+
*
|
1684 |
Â
*/
|
1685 |
Â
protected function _generateBarcode()
|
1686 |
Â
{
|
1687 |
Â
$shipment = $this->getShipment();
|
1688 |
Â
|
1689 |
+
/**
|
1690 |
+
* @var TIG_PostNL_Model_Core_Cif $cif
|
1691 |
+
* @var TIG_PostNL_Helper_Cif $helper
|
1692 |
+
*/
|
1693 |
Â
$cif = Mage::getModel('postnl_core/cif');
|
1694 |
+
$cif->setStoreId($this->getStoreId());
|
1695 |
+
$helper = $this->getHelper('cif');
|
1696 |
+
$barcodeType = $helper->getBarcodeTypeForShipment($this);
|
1697 |
Â
|
1698 |
Â
$barcode = $cif->generateBarcode($shipment, $barcodeType);
|
1699 |
Â
|
1700 |
Â
if (!$barcode) {
|
1701 |
Â
throw new TIG_PostNL_Exception(
|
1702 |
+
$helper->__('Unable to generate barcode for this shipment: %s', $shipment->getId()),
|
1703 |
Â
'POSTNL-0070'
|
1704 |
Â
);
|
1705 |
Â
}
|
1707 |
Â
/**
|
1708 |
Â
* If the generated barcode already exists a new one needs to be generated.
|
1709 |
Â
*/
|
1710 |
+
if ($helper->barcodeExists($barcode)) {
|
1711 |
Â
return $this->_generateBarcode();
|
1712 |
Â
}
|
1713 |
Â
|
1717 |
Â
/**
|
1718 |
Â
* Generates a shipping labels for a shipment without confirming it with PostNL.
|
1719 |
Â
*
|
1720 |
+
* @return $this
|
1721 |
Â
*
|
1722 |
Â
* @throws TIG_PostNL_Exception
|
1723 |
Â
*/
|
1764 |
Â
}
|
1765 |
Â
|
1766 |
Â
/**
|
1767 |
+
* Get a shipping label from PostNL for a single parcel or a whole shipment.
|
1768 |
Â
*
|
1769 |
+
* @param boolean $confirm Whether or not to also confirm the shipment.
|
1770 |
+
* @param bool|int|null $barcodeNumber An optional barcode number. If this parameter is null, the main barcode will
|
1771 |
+
* be used.
|
1772 |
Â
*
|
1773 |
+
* @throws TIG_PostNL_Exception
|
1774 |
Â
* @return array
|
1775 |
Â
*/
|
1776 |
Â
protected function _generateLabel($confirm = false, $barcodeNumber = false)
|
1782 |
Â
*/
|
1783 |
Â
if ($barcodeNumber === false) {
|
1784 |
Â
$barcode = $mainBarcode;
|
Â
|
|
1785 |
Â
} else {
|
1786 |
Â
$barcode = $this->getBarcode($barcodeNumber);
|
1787 |
Â
$barcodeNumber++; //while barcode numbers start at 0, shipment numbers start at 1
|
1788 |
Â
}
|
1789 |
Â
|
1790 |
+
/**
|
1791 |
+
* @var TIG_PostNL_Model_Core_Cif $cif
|
1792 |
+
*/
|
1793 |
Â
$cif = Mage::getModel('postnl_core/cif');
|
1794 |
+
$cif->setStoreId($this->getStoreId());
|
1795 |
Â
|
1796 |
+
/**
|
1797 |
+
* @var StdClass $result
|
1798 |
+
*/
|
1799 |
Â
if ($confirm === false) {
|
1800 |
Â
$result = $cif->generateLabelsWithoutConfirm($this, $barcode, $mainBarcode, $barcodeNumber);
|
1801 |
Â
} else {
|
1802 |
Â
$result = $cif->generateLabels($this, $barcode, $mainBarcode, $barcodeNumber);
|
1803 |
Â
}
|
1804 |
Â
|
1805 |
+
if (!isset($result->Labels, $result->Labels->Label)) {
|
1806 |
Â
throw new TIG_PostNL_Exception(
|
1807 |
Â
Mage::helper('postnl')->__(
|
1808 |
Â
'The confirmAndPrintLabel action returned an invalid response: %s',
|
1809 |
+
var_export($result, true)
|
1810 |
Â
),
|
1811 |
Â
'POSTNL-0071'
|
1812 |
Â
);
|
1814 |
Â
$labels = $result->Labels->Label;
|
1815 |
Â
|
1816 |
Â
/**
|
1817 |
+
* If this is an EU shipment and a non-combi label was returned, the product code needs to be updated.
|
1818 |
Â
*/
|
1819 |
Â
if ($this->isEuShipment() && !$this->_isCombiLabel()) {
|
1820 |
Â
$this->setProductCode($result->ProductCodeDelivery);
|
1823 |
Â
return $labels;
|
1824 |
Â
}
|
1825 |
Â
|
1826 |
+
/**
|
1827 |
+
* Manually confirms a shipment without communicating with PostNL. This should be used if you wish to update the
|
1828 |
+
* confirmation status in Magento, while actually confirming the shipment through other means, such as Parcelware.
|
1829 |
+
*
|
1830 |
+
* @return $this
|
1831 |
+
*
|
1832 |
+
* @throws TIG_PostNL_Exception
|
1833 |
+
*/
|
1834 |
+
public function registerConfirmation()
|
1835 |
+
{
|
1836 |
+
Mage::dispatchEvent('postnl_shipment_register_confirmation_before', array('shipment' => $this));
|
1837 |
+
|
1838 |
+
/**
|
1839 |
+
* @var Mage_Core_Model_Date $dateModel
|
1840 |
+
*/
|
1841 |
+
$dateModel = Mage::getModel('core/date');
|
1842 |
+
$this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
|
1843 |
+
->setConfirmedAt($dateModel->gmtTimestamp());
|
1844 |
+
|
1845 |
+
Mage::dispatchEvent('postnl_shipment_register_confirmation_after', array('shipment' => $this));
|
1846 |
+
|
1847 |
+
return $this;
|
1848 |
+
}
|
1849 |
+
|
1850 |
Â
/**
|
1851 |
Â
* Confirm the shipment with PostNL without generating new labels
|
1852 |
Â
*
|
1853 |
+
* @return $this
|
1854 |
Â
*
|
1855 |
Â
* @throws TIG_PostNL_Exception
|
1856 |
Â
*/
|
1878 |
Â
if ($parcelCount < 2) {
|
1879 |
Â
$this->_confirm();
|
1880 |
Â
|
1881 |
+
$this->registerConfirmation();
|
Â
|
|
1882 |
Â
|
1883 |
Â
Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
|
1884 |
Â
|
1893 |
Â
$this->_confirm($i);
|
1894 |
Â
}
|
1895 |
Â
|
1896 |
+
$this->registerConfirmation();
|
Â
|
|
1897 |
Â
|
1898 |
Â
Mage::dispatchEvent('postnl_shipment_confirm_after', array('shipment' => $this));
|
1899 |
Â
|
1902 |
Â
}
|
1903 |
Â
|
1904 |
Â
/**
|
1905 |
+
* Confirms the shipment using CIF.
|
Â
|
|
Â
|
|
1906 |
Â
*
|
1907 |
+
* @param bool|int|null $barcodeNumber
|
1908 |
Â
*
|
1909 |
Â
* @throws TIG_PostNL_Exception
|
1910 |
+
*
|
1911 |
+
* @return $this
|
1912 |
Â
*/
|
1913 |
Â
protected function _confirm($barcodeNumber = false)
|
1914 |
Â
{
|
1919 |
Â
*/
|
1920 |
Â
if ($barcodeNumber === false) {
|
1921 |
Â
$barcode = $mainBarcode;
|
Â
|
|
1922 |
Â
} else {
|
1923 |
Â
$barcode = $this->getBarcode($barcodeNumber);
|
1924 |
Â
$barcodeNumber++; //while barcode numbers start at 0, shipment numbers start at 1
|
1925 |
Â
}
|
1926 |
Â
|
1927 |
+
/**
|
1928 |
+
* @var TIG_PostNL_Model_Core_Cif $cif
|
1929 |
+
* @var StdClass $result
|
1930 |
+
*/
|
1931 |
Â
$cif = Mage::getModel('postnl_core/cif');
|
1932 |
+
$cif->setStoreId($this->getStoreId());
|
1933 |
Â
$result = $cif->confirmShipment($this, $barcode, $mainBarcode, $barcodeNumber);
|
1934 |
Â
|
1935 |
Â
$responseShipment = $result->ConfirmingResponseShipment;
|
1936 |
Â
|
1937 |
Â
/**
|
1938 |
+
* If the ConfirmingResponseShipment is an object, it means only one shipment was confirmed and the returned
|
1939 |
+
* barcode has to be the shipment's main barcode.
|
1940 |
Â
*/
|
1941 |
Â
if (is_object($responseShipment)
|
1942 |
Â
&& isset($responseShipment->Barcode)
|
1946 |
Â
}
|
1947 |
Â
|
1948 |
Â
/**
|
1949 |
+
* If the ConfirmingResponseShipment is an array, it may indicate multiple shipments were confirmed. We need to
|
1950 |
+
* check the first shipment's barcode to see if it matches the main bartcode.
|
1951 |
Â
*/
|
1952 |
Â
if (is_array($responseShipment)) {
|
1953 |
+
$mainResponseShipment = reset($responseShipment);
|
1954 |
Â
|
1955 |
Â
if (is_object($mainResponseShipment)
|
1956 |
Â
&& isset($mainResponseShipment->Barcode)
|
1972 |
Â
/**
|
1973 |
Â
* Generates a shipping label and confirms the shipment with postNL.
|
1974 |
Â
*
|
1975 |
+
* @return $this
|
1976 |
Â
*
|
1977 |
Â
* @throws TIG_PostNL_Exception
|
1978 |
Â
*/
|
1995 |
Â
$parcelCount = $this->_calculateParcelCount();
|
1996 |
Â
}
|
1997 |
Â
|
1998 |
+
/**
|
1999 |
+
* @var Mage_Core_Model_Date $dateModel
|
2000 |
+
*/
|
2001 |
+
$dateModel = Mage::getModel('core/date');
|
2002 |
+
|
2003 |
Â
/**
|
2004 |
Â
* Confirm and generate labels purely for the main shipment
|
2005 |
Â
*/
|
2008 |
Â
$this->addLabels($labels);
|
2009 |
Â
|
2010 |
Â
$this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
|
2011 |
+
->setConfirmedAt($dateModel->gmtTimestamp());
|
2012 |
Â
|
2013 |
Â
$this->_saveLabels();
|
2014 |
Â
|
2028 |
Â
}
|
2029 |
Â
|
2030 |
Â
$this->setConfirmStatus(self::CONFIRM_STATUS_CONFIRMED)
|
2031 |
+
->setConfirmedAt($dateModel->gmtTimestamp());
|
2032 |
Â
|
2033 |
Â
$this->_saveLabels();
|
2034 |
Â
|
2042 |
Â
/**
|
2043 |
Â
* Requests a shipping status update for this shipment
|
2044 |
Â
*
|
2045 |
+
* @return $this
|
2046 |
Â
*
|
2047 |
Â
* @throws TIG_PostNL_Exception
|
2048 |
Â
*/
|
2059 |
Â
|
2060 |
Â
Mage::dispatchEvent('postnl_shipment_updateshippingstatus_before', array('shipment' => $this));
|
2061 |
Â
|
2062 |
+
/**
|
2063 |
+
* @var TIG_PostNL_Model_Core_Cif $cif
|
2064 |
+
*/
|
2065 |
Â
$cif = Mage::getModel('postnl_core/cif');
|
2066 |
+
$cif->setStoreId($this->getStoreId());
|
2067 |
Â
$result = $cif->getShipmentStatus($this);
|
2068 |
Â
|
2069 |
Â
$currentPhase = $result->Status->CurrentPhaseCode;
|
2083 |
Â
/**
|
2084 |
Â
* Update this shipment's status history
|
2085 |
Â
*
|
2086 |
+
* @throws TIG_PostNL_Exception
|
2087 |
Â
*
|
2088 |
+
* @return $this
|
2089 |
Â
*/
|
2090 |
Â
public function updateCompleteShippingStatus()
|
2091 |
Â
{
|
2100 |
Â
|
2101 |
Â
Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_before', array('shipment' => $this));
|
2102 |
Â
|
2103 |
+
/**
|
2104 |
+
* @var TIG_PostNL_Model_Core_Cif $cif
|
2105 |
+
* @var StdClass $result
|
2106 |
+
*/
|
2107 |
Â
$cif = Mage::getModel('postnl_core/cif');
|
2108 |
+
$cif->setStoreId($this->getStoreId());
|
2109 |
Â
$result = $cif->getCompleteShipmentStatus($this);
|
2110 |
Â
|
2111 |
Â
/**
|
2125 |
Â
$completeStatusHistory = $result->Events->CompleteStatusResponseEvent;
|
2126 |
Â
$completeStatusHistory = $this->_sortStatusHistory($completeStatusHistory);
|
2127 |
Â
|
2128 |
+
/**
|
2129 |
+
* @var MAge_Core_Model_Date $dateModel
|
2130 |
+
*/
|
2131 |
+
$dateModel = Mage::getModel('core/date');
|
2132 |
+
|
2133 |
Â
/**
|
2134 |
Â
* Update the shipments status history
|
2135 |
Â
*/
|
2136 |
Â
foreach ($completeStatusHistory as $status) {
|
2137 |
+
/**
|
2138 |
+
* @var TIG_PostNL_Model_Core_Shipment_Status_History $statusHistory
|
2139 |
+
*/
|
2140 |
Â
$statusHistory = Mage::getModel('postnl_core/shipment_status_history');
|
2141 |
Â
|
2142 |
Â
/**
|
2147 |
Â
continue;
|
2148 |
Â
}
|
2149 |
Â
|
2150 |
+
$timestamp = $dateModel->gmtTimestamp($status->TimeStamp);
|
2151 |
Â
$statusHistory->setParentId($this->getId())
|
2152 |
Â
->setCode($status->Code)
|
2153 |
Â
->setDescription($status->Description)
|
2159 |
Â
->save();
|
2160 |
Â
}
|
2161 |
Â
|
2162 |
+
$this->setStatusHistoryUpdatedAt($dateModel->gmtTimestamp());
|
2163 |
Â
|
2164 |
Â
Mage::dispatchEvent('postnl_shipment_updatecompleteshippingstatus_after', array('shipment' => $this));
|
2165 |
Â
|
2168 |
Â
return $this;
|
2169 |
Â
}
|
2170 |
Â
|
2171 |
+
/*******************************************************************************************************************
|
2172 |
Â
* TRACKING METHODS
|
2173 |
+
******************************************************************************************************************/
|
2174 |
Â
|
2175 |
Â
/**
|
2176 |
Â
* Adds Magento tracking information to the order containing the previously retrieved barcode
|
2177 |
Â
*
|
2178 |
+
* @return $this
|
2179 |
Â
*
|
2180 |
Â
* @throws TIG_PostNL_Exception
|
2181 |
Â
*/
|
2200 |
Â
'number' => $barcode,
|
2201 |
Â
);
|
2202 |
Â
|
2203 |
+
/**
|
2204 |
+
* @var Mage_Sales_Model_Order_Shipment_Track $track
|
2205 |
+
*/
|
2206 |
Â
$track = Mage::getModel('sales/order_shipment_track')->addData($data);
|
2207 |
Â
$shipment->addTrack($track);
|
2208 |
Â
|
2209 |
Â
/**
|
2210 |
+
* Save the Mage_Sales_Order_Shipment object and the TIG_PostNL_Model_Core_Shipment objects simultaneously.
|
2211 |
+
*
|
2212 |
+
* @var Mage_Core_Model_Resource_Transaction $transaction
|
2213 |
Â
*/
|
2214 |
+
$transaction = Mage::getModel('core/resource_transaction');
|
2215 |
+
$transaction->addObject($this)
|
2216 |
+
->addObject($shipment)
|
2217 |
+
->save();
|
2218 |
Â
|
2219 |
Â
return $this;
|
2220 |
Â
}
|
2223 |
Â
* Send a track & trace email to the customer containing a link to the 'mijnpakket' environment where they
|
2224 |
Â
* can track their shipment.
|
2225 |
Â
*
|
2226 |
+
* @param boolean $ignoreAlreadySent Flag to ignore the 'already sent' check.
|
2227 |
+
* @param boolean $ignoreConfig Flag to ignore the configuration settings related to track&trace e-mails.
|
2228 |
+
*
|
2229 |
+
* @throws TIG_PostNL_Exception
|
2230 |
Â
*
|
2231 |
+
* @return $this
|
2232 |
Â
*/
|
2233 |
+
public function sendTrackAndTraceEmail($ignoreAlreadySent = false, $ignoreConfig = false)
|
2234 |
Â
{
|
2235 |
+
if (!$this->canSendTrackAndTraceEmail($ignoreAlreadySent, $ignoreConfig)) {
|
2236 |
Â
throw new TIG_PostNL_Exception(
|
2237 |
Â
Mage::helper('postnl')->__('The sendTrackAndTraceEmail action is currently unavailable.'),
|
2238 |
Â
'POSTNL-0076'
|
2239 |
Â
);
|
2240 |
Â
}
|
2241 |
Â
|
Â
|
|
2242 |
Â
$storeId = $this->getStoreId();
|
2243 |
Â
|
2244 |
+
$template = Mage::getStoreConfig(self::XPATH_TRACK_AND_TRACE_EMAIL_TEMPLATE, $storeId);
|
2245 |
+
|
2246 |
+
/**
|
2247 |
+
* @var Mage_Core_Model_Email_Template $mailTemplate
|
2248 |
+
*/
|
2249 |
Â
$mailTemplate = Mage::getModel('core/email_template');
|
2250 |
Â
|
2251 |
Â
$shippingAddress = $this->getShippingAddress();
|
2252 |
Â
$recipient = array(
|
2253 |
Â
'email' => $this->getShipment()->getOrder()->getCustomerEmail(),
|
2254 |
+
'name' => $shippingAddress->getName(),
|
2255 |
Â
);
|
2256 |
Â
|
2257 |
Â
$mailTemplate->setDesignConfig(
|
2261 |
Â
)
|
2262 |
Â
);
|
2263 |
Â
|
2264 |
+
/**
|
2265 |
+
* @var Mage_Sales_Model_Order $order
|
2266 |
+
*/
|
2267 |
Â
$shipment = $this->getShipment();
|
2268 |
Â
$order = $shipment->getOrder();
|
2269 |
+
/** @noinspection PhpUndefinedMethodInspection */
|
2270 |
Â
$templateVariables = array(
|
2271 |
Â
'postnlshipment' => $this,
|
2272 |
Â
'barcode' => $this->getMainBarcode(),
|
2277 |
Â
'quote' => $order->getQuote(),
|
2278 |
Â
);
|
2279 |
Â
|
2280 |
+
/**
|
2281 |
+
* @var $orderModel Mage_Sales_Model_Order
|
2282 |
+
*/
|
2283 |
+
/** @noinspection PhpParamsInspection */
|
2284 |
Â
$orderModel = Mage::getConfig()->getModelClassName('sales/order');
|
2285 |
Â
$success = $mailTemplate->sendTransactional(
|
2286 |
Â
$template,
|
2292 |
Â
|
2293 |
Â
if ($success === false) {
|
2294 |
Â
throw new TIG_PostNL_Exception(
|
2295 |
+
Mage::helper('postnl')->__(
|
2296 |
+
'Unable to send track and trace email for shipment #',
|
2297 |
+
$this->getShipmentId()
|
2298 |
+
),
|
2299 |
Â
'POSTNL-0077'
|
2300 |
Â
);
|
2301 |
Â
}
|
2302 |
Â
|
2303 |
+
/**
|
2304 |
+
* Set the 'email sent' flag to true for this shipment.
|
2305 |
+
*/
|
2306 |
+
$this->getShipment()
|
2307 |
+
->setEmailSent(true)
|
2308 |
+
->save();
|
2309 |
+
|
2310 |
Â
return $this;
|
2311 |
Â
}
|
2312 |
Â
|
2313 |
+
/*******************************************************************************************************************
|
2314 |
Â
* BARCODE PROCESSING METHODS
|
2315 |
+
******************************************************************************************************************/
|
2316 |
Â
|
2317 |
Â
/**
|
2318 |
Â
* Add a barcode to this shipment's barcode collection
|
2320 |
Â
* @param string $barcode The barcode to add
|
2321 |
Â
* @param int $barcodeNumber The number of this barcode
|
2322 |
Â
*
|
2323 |
+
* @return $this
|
2324 |
Â
*/
|
2325 |
Â
protected function _addBarcode($barcode, $barcodeNumber)
|
2326 |
Â
{
|
2327 |
+
/**
|
2328 |
+
* @var TIG_PostNL_Model_Core_Shipment_Barcode $barcodeModel
|
2329 |
+
*/
|
2330 |
Â
$barcodeModel = Mage::getModel('postnl_core/shipment_barcode');
|
2331 |
Â
$barcodeModel->setParentId($this->getId())
|
2332 |
Â
->setBarcode($barcode)
|
2336 |
Â
return $this;
|
2337 |
Â
}
|
2338 |
Â
|
2339 |
+
/*******************************************************************************************************************
|
2340 |
Â
* LABEL PROCESSING METHODS
|
2341 |
+
******************************************************************************************************************/
|
2342 |
Â
|
2343 |
Â
/**
|
2344 |
Â
* Add labels to this shipment
|
2345 |
Â
*
|
2346 |
Â
* @param mixed $labels An array of labels or a single label object
|
2347 |
Â
*
|
2348 |
+
* @return $this
|
2349 |
Â
*/
|
2350 |
Â
public function addLabels($labels)
|
2351 |
Â
{
|
2372 |
Â
*
|
2373 |
Â
* @param stdClass $label
|
2374 |
Â
*
|
2375 |
+
* @return $this
|
2376 |
Â
*/
|
2377 |
Â
protected function _addLabel($label)
|
2378 |
Â
{
|
2382 |
Â
$labelType = 'Label-combi';
|
2383 |
Â
}
|
2384 |
Â
|
2385 |
+
/**
|
2386 |
+
* @var TIG_PostNL_Model_Core_Shipment_Label $postnlLabel
|
2387 |
+
*/
|
2388 |
Â
$postnlLabel = Mage::getModel('postnl_core/shipment_label');
|
2389 |
Â
$postnlLabel->setParentId($this->getId())
|
2390 |
Â
->setLabel(base64_encode($label->Content))
|
2400 |
Â
*
|
2401 |
Â
* @param TIG_PostNL_Model_Core_Shipment_Label $label
|
2402 |
Â
*
|
2403 |
+
* @return $this
|
2404 |
Â
*/
|
2405 |
Â
protected function _addLabelToSave($label)
|
2406 |
Â
{
|
2407 |
+
$labelsToSave = $this->getLabelsToSave();
|
2408 |
Â
|
2409 |
Â
$labelsToSave[] = $label;
|
2410 |
Â
|
2416 |
Â
/**
|
2417 |
Â
* Save all newly added labels at once
|
2418 |
Â
*
|
2419 |
+
* @return $this
|
2420 |
Â
*/
|
2421 |
Â
protected function _saveLabels()
|
2422 |
Â
{
|
2423 |
+
/**
|
2424 |
+
* @var Mage_Core_Model_Resource_Transaction $transactionSave
|
2425 |
+
*/
|
2426 |
Â
$transactionSave = Mage::getModel('core/resource_transaction');
|
2427 |
Â
|
2428 |
Â
/**
|
2430 |
Â
*/
|
2431 |
Â
$labelsToSave = $this->getLabelsToSave();
|
2432 |
Â
|
2433 |
+
Mage::dispatchEvent(
|
2434 |
+
'postnl_shipment_savelabels_before',
|
2435 |
+
array('shipment' => $this, 'labels' => $labelsToSave)
|
2436 |
+
);
|
2437 |
Â
|
2438 |
Â
foreach ($labelsToSave as $label) {
|
2439 |
Â
$transactionSave->addObject($label);
|
2444 |
Â
*/
|
2445 |
Â
$transactionSave->save();
|
2446 |
Â
|
2447 |
+
Mage::dispatchEvent(
|
2448 |
+
'postnl_shipment_savelabels_after',
|
2449 |
+
array('shipment' => $this, 'labels' => $labelsToSave)
|
2450 |
+
);
|
2451 |
Â
|
2452 |
Â
return $this;
|
2453 |
Â
}
|
2454 |
Â
|
2455 |
Â
/**
|
2456 |
+
* Check if the returned label is a combi-label.
|
2457 |
Â
*
|
2458 |
Â
* @param TIG_PostNL_Model_Core_Shipment_label
|
2459 |
Â
*
|
2486 |
Â
return true;
|
2487 |
Â
}
|
2488 |
Â
|
2489 |
+
/*******************************************************************************************************************
|
2490 |
Â
* STATUS PROCESSING METHODS
|
2491 |
+
******************************************************************************************************************/
|
2492 |
Â
|
2493 |
Â
/**
|
2494 |
Â
* Sort a status history array based on the time the status was assigned
|
2521 |
Â
return array_values($sortedHistory);
|
2522 |
Â
}
|
2523 |
Â
|
2524 |
+
/*******************************************************************************************************************
|
2525 |
Â
* PRODUCT CODE METHODS
|
2526 |
+
******************************************************************************************************************/
|
2527 |
Â
|
2528 |
Â
/**
|
2529 |
Â
* Gets the product code for this shipment. If specific options have been selected
|
2562 |
Â
*/
|
2563 |
Â
protected function _checkProductCodeAllowed($productCode)
|
2564 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2565 |
Â
/**
|
2566 |
+
* @var TIG_PostNL_Helper_Cif $cifHelper
|
2567 |
Â
*/
|
2568 |
+
$cifHelper = $this->getHelper('cif');
|
2569 |
+
$allowedProductCodes = $this->getAllowedProductCodes();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2570 |
Â
|
2571 |
Â
/**
|
2572 |
Â
* Check if the product code is allowed
|
2603 |
Â
/**
|
2604 |
Â
* Checks if a given product code is only allowed for a specific country
|
2605 |
Â
*
|
2606 |
+
* @param $code
|
2607 |
+
*
|
2608 |
Â
* @return boolean|array Either false if the code is not restricted, or otherwise an array of allowed country IDs
|
2609 |
Â
*/
|
2610 |
Â
protected function _isCodeRestricted($code)
|
2611 |
Â
{
|
2612 |
+
/**
|
2613 |
+
* @var TIG_PostNL_Helper_Cif $helper
|
2614 |
+
*/
|
2615 |
+
$helper = $this->getHelper('cif');
|
2616 |
+
$countryRestrictedCodes = $helper->getCountryRestrictedProductCodes();
|
2617 |
Â
|
2618 |
Â
/**
|
2619 |
Â
* Check if the supplied code is restricted
|
2629 |
Â
return $allowedCountries;
|
2630 |
Â
}
|
2631 |
Â
|
2632 |
+
/*******************************************************************************************************************
|
2633 |
Â
* ADDITIONAL SHIPMENT OPTIONS
|
2634 |
+
******************************************************************************************************************/
|
2635 |
Â
|
2636 |
Â
/**
|
2637 |
Â
* Public alias for _saveAdditionalShippingOptions()
|
2638 |
Â
*
|
2639 |
+
* @return $this
|
2640 |
Â
*
|
2641 |
Â
* @see TIG_PostNL_Model_Core_Shipment::_saveAdditionalShippingOptions()
|
2642 |
Â
*/
|
2648 |
Â
/**
|
2649 |
Â
* Stores additionally selected shipping options
|
2650 |
Â
*
|
2651 |
+
* @return $this
|
2652 |
Â
*/
|
2653 |
Â
protected function _saveAdditionalShippingOptions()
|
2654 |
Â
{
|
2665 |
Â
'postnl_shipment_saveadditionaloptions_after',
|
2666 |
Â
array(
|
2667 |
Â
'shipment' => $this,
|
2668 |
+
'options' => $additionalOptions
|
2669 |
Â
)
|
2670 |
Â
);
|
2671 |
Â
|
2694 |
Â
$weight = $this->getTotalWeight(true);
|
2695 |
Â
|
2696 |
Â
/**
|
2697 |
+
* get the weight per parcel.
|
2698 |
+
*
|
2699 |
+
* @var TIG_PostNL_Helper_Cif $helper
|
2700 |
Â
*/
|
2701 |
+
$helper = $this->getHelper('cif');
|
2702 |
+
$weightPerParcel = Mage::getStoreConfig(self::XPATH_WEIGHT_PER_PARCEL, $this->getStoreId());
|
2703 |
+
$weightPerParcel = $helper->standardizeWeight($weightPerParcel, $this->getStoreId());
|
2704 |
Â
|
2705 |
Â
/**
|
2706 |
Â
* calculate the number of parcels needed to ship the total weight of this shipment
|
2710 |
Â
return $parcelCount;
|
2711 |
Â
}
|
2712 |
Â
|
2713 |
+
/*******************************************************************************************************************
|
2714 |
Â
* RESET AND DELETE METHODS
|
2715 |
+
******************************************************************************************************************/
|
2716 |
Â
|
2717 |
Â
/**
|
2718 |
Â
* Resets this shipment to a pre-confirmed state
|
2730 |
Â
->deleteBarcodes() //delete all associated barcodes
|
2731 |
Â
->deleteStatusHistory(); //delete all associated status history items
|
2732 |
Â
|
2733 |
+
|
2734 |
Â
if ($deleteLabels) {
|
2735 |
Â
$this->setlabelsPrinted(false) //labels have not been printed
|
2736 |
Â
->deleteLabels(); //delete all associated labels
|
2737 |
Â
}
|
2738 |
Â
|
2739 |
Â
if ($deleteTracks) {
|
2740 |
+
$this->deleteShipmentTracks() //delete ale addociated tracks
|
2741 |
+
->setTrackAndTraceEmailSent(false); //make sure that a new T&T e-mail is sent
|
2742 |
Â
}
|
2743 |
Â
|
2744 |
Â
return $this;
|
2767 |
Â
/**
|
2768 |
Â
* Removes all labels associated with this shipment
|
2769 |
Â
*
|
2770 |
+
* @return $this
|
2771 |
Â
*/
|
2772 |
Â
public function deleteLabels()
|
2773 |
Â
{
|
2774 |
+
$labelCollection = $this->getLabelCollection();
|
Â
|
|
2775 |
Â
|
2776 |
Â
$labels = $labelCollection->getItems();
|
2777 |
Â
|
2778 |
+
/**
|
2779 |
+
* @var TIG_PostNL_Model_Core_Shipment_Label $label
|
2780 |
+
*/
|
2781 |
Â
foreach ($labels as $label) {
|
2782 |
+
$label->delete();
|
Â
|
|
2783 |
Â
}
|
2784 |
Â
|
2785 |
Â
return $this;
|
2788 |
Â
/**
|
2789 |
Â
* Removes all barcodes associated with this shipment
|
2790 |
Â
*
|
2791 |
+
* @return $this
|
2792 |
Â
*/
|
2793 |
Â
public function deleteBarcodes()
|
2794 |
Â
{
|
2795 |
Â
$barcodes = $this->getBarcodes(true);
|
2796 |
Â
|
2797 |
+
/**
|
2798 |
+
* @var TIG_PostNL_Model_Core_Shipment_Barcode $barcode
|
2799 |
+
*/
|
2800 |
Â
foreach ($barcodes as $barcode) {
|
2801 |
+
$barcode->delete();
|
Â
|
|
2802 |
Â
}
|
2803 |
Â
|
2804 |
Â
$this->setMainBarcode(false);
|
2809 |
Â
/**
|
2810 |
Â
* Deletes all status history items associated with this shipment
|
2811 |
Â
*
|
2812 |
+
* @return $this
|
2813 |
Â
*/
|
2814 |
Â
public function deleteStatusHistory()
|
2815 |
Â
{
|
2816 |
Â
$statusHistoryCollection = Mage::getResourceModel('postnl_core/shipment_status_history_collection');
|
2817 |
Â
$statusHistoryCollection->addFieldToFilter('parent_id', array('eq' => $this->getid()));
|
2818 |
Â
|
2819 |
+
/**
|
2820 |
+
* @var TIG_PostNL_Model_Core_Shipment_Status_History $status
|
2821 |
+
*/
|
2822 |
Â
foreach ($statusHistoryCollection as $status) {
|
2823 |
+
$status->delete();
|
Â
|
|
2824 |
Â
}
|
2825 |
Â
|
2826 |
Â
return $this;
|
2827 |
Â
}
|
2828 |
Â
|
2829 |
+
/*******************************************************************************************************************
|
2830 |
Â
* BEFORE- AND AFTERSAVE METHODS
|
2831 |
+
******************************************************************************************************************/
|
2832 |
Â
|
2833 |
Â
/**
|
2834 |
Â
* Updates the shipment's attributes before saving this shipment
|
2837 |
Â
*/
|
2838 |
Â
protected function _beforeSave()
|
2839 |
Â
{
|
2840 |
+
/**
|
2841 |
+
* @var Mage_Core_Model_Date $dateModel
|
2842 |
+
*/
|
2843 |
+
$dateModel = Mage::getModel('core/date');
|
2844 |
+
$currentTimestamp = $dateModel->gmtTimestamp();
|
2845 |
Â
|
2846 |
Â
/**
|
2847 |
+
* Store any shipment options that have been saved in the registry.
|
2848 |
Â
*/
|
2849 |
Â
if (Mage::registry('postnl_additional_options')) {
|
2850 |
Â
$this->_saveAdditionalShippingOptions();
|
2851 |
Â
}
|
2852 |
Â
|
2853 |
Â
/**
|
2854 |
+
* Set confirm status.
|
2855 |
Â
*/
|
2856 |
Â
if ($this->getConfirmStatus() === null) {
|
2857 |
Â
$this->setConfirmStatus(self::CONFIRM_STATUS_UNCONFIRMED);
|
2858 |
Â
}
|
2859 |
Â
|
2860 |
Â
/**
|
2861 |
+
* Set confrirmed at.
|
2862 |
Â
*/
|
2863 |
Â
if ($this->getConfirmedStatus() == self::CONFIRM_STATUS_CONFIRMED
|
2864 |
Â
&& $this->getConfirmedAt() === null
|
2867 |
Â
}
|
2868 |
Â
|
2869 |
Â
/**
|
2870 |
+
* Set whether labels have printed or not.
|
2871 |
Â
*/
|
2872 |
Â
if ($this->getlabelsPrinted() == 0 && $this->hasLabels()) {
|
2873 |
Â
$this->setLabelsPrinted(1);
|
2874 |
Â
}
|
2875 |
Â
|
2876 |
Â
/**
|
2877 |
+
* Set a product code.
|
2878 |
Â
*/
|
2879 |
Â
if (!$this->getProductCode() || Mage::registry('postnl_product_option') !== null) {
|
2880 |
Â
$productCode = $this->_getProductCode();
|
2882 |
Â
}
|
2883 |
Â
|
2884 |
Â
/**
|
2885 |
+
* Set the parcel count.
|
2886 |
Â
*/
|
2887 |
Â
if (!$this->getParcelCount()) {
|
2888 |
Â
$parcelCount = $this->_calculateParcelCount();
|
2890 |
Â
}
|
2891 |
Â
|
2892 |
Â
/**
|
2893 |
+
* Set the confirm date.
|
2894 |
Â
*/
|
2895 |
Â
if (!$this->getConfirmDate()) {
|
2896 |
+
$this->setConfirmDate();
|
2897 |
Â
}
|
2898 |
Â
|
2899 |
Â
/**
|
2900 |
+
* If this shipment is new, set it's created at date to the current timestamp.
|
2901 |
Â
*/
|
2902 |
Â
if (!$this->getId()) {
|
2903 |
Â
$this->setCreatedAt($currentTimestamp);
|
2904 |
Â
}
|
2905 |
Â
|
2906 |
Â
/**
|
2907 |
+
* Always update the updated at timestamp to the current timestamp.
|
2908 |
Â
*/
|
2909 |
Â
$this->setUpdatedAt($currentTimestamp);
|
2910 |
Â
|
@@ -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.
|
@@ -33,8 +33,18 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Shipment_Barcode extends Mage_Core_Model_Abstract
|
40 |
Â
{
|
@@ -44,28 +54,38 @@ class TIG_PostNL_Model_Core_Shipment_Barcode extends Mage_Core_Model_Abstract
|
|
44 |
Â
* @var string
|
45 |
Â
*/
|
46 |
Â
protected $_eventPrefix = 'postnl_shipment_barcode';
|
47 |
-
|
48 |
Â
public function _construct()
|
49 |
Â
{
|
50 |
Â
$this->_init('postnl_core/shipment_barcode');
|
51 |
Â
}
|
52 |
-
|
53 |
Â
/**
|
54 |
Â
* Load a barcode object based on a postnl shipment Id and a barcode number
|
55 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
56 |
Â
* @return TIG_PostNL_Model_Core_Shipment_Barcode
|
57 |
Â
*/
|
58 |
Â
public function loadByParentAndBarcodeNumber($parentId, $barcodeNumber)
|
59 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
60 |
Â
$collection = $this->getCollection();
|
61 |
Â
$collection->addFieldToSelect('*')
|
62 |
Â
->addFieldToFilter('parent_id', array('eq' => $parentId))
|
63 |
Â
->addFieldToFilter('barcode_number', array('eq' => $barcodeNumber));
|
64 |
-
|
65 |
Â
if ($collection->getSize()) {
|
66 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
}
|
68 |
-
|
69 |
Â
return $this;
|
70 |
Â
}
|
71 |
Â
}
|
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.
|
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 |
+
* Class TIG_PostNL_Model_Core_Shipment_Barcode@method getBarcode
|
40 |
+
*
|
41 |
+
* @method int getBarcodeNumber()
|
42 |
+
* @method TIG_PostNL_Model_Core_Shipment_Barcode setBarcodeNumber(int $value)
|
43 |
+
* @method int getBarcodeId()
|
44 |
+
* @method TIG_PostNL_Model_Core_Shipment_Barcode setBarcodeId(int $value)
|
45 |
+
* @method TIG_PostNL_Model_Core_Shipment_Barcode setBarcode(string $value)
|
46 |
+
* @method int getParentId()
|
47 |
+
* @method TIG_PostNL_Model_Core_Shipment_Barcode setParentId(int $value)
|
48 |
Â
*/
|
49 |
Â
class TIG_PostNL_Model_Core_Shipment_Barcode extends Mage_Core_Model_Abstract
|
50 |
Â
{
|
54 |
Â
* @var string
|
55 |
Â
*/
|
56 |
Â
protected $_eventPrefix = 'postnl_shipment_barcode';
|
57 |
+
|
58 |
Â
public function _construct()
|
59 |
Â
{
|
60 |
Â
$this->_init('postnl_core/shipment_barcode');
|
61 |
Â
}
|
62 |
+
|
63 |
Â
/**
|
64 |
Â
* Load a barcode object based on a postnl shipment Id and a barcode number
|
65 |
+
*
|
66 |
+
* @param $parentId
|
67 |
+
* @param $barcodeNumber
|
68 |
+
*
|
69 |
Â
* @return TIG_PostNL_Model_Core_Shipment_Barcode
|
70 |
Â
*/
|
71 |
Â
public function loadByParentAndBarcodeNumber($parentId, $barcodeNumber)
|
72 |
Â
{
|
73 |
+
/**
|
74 |
+
* @var TIG_PostNL_Model_Core_Resource_Shipment_Barcode_Collection $collection
|
75 |
+
*/
|
76 |
Â
$collection = $this->getCollection();
|
77 |
Â
$collection->addFieldToSelect('*')
|
78 |
Â
->addFieldToFilter('parent_id', array('eq' => $parentId))
|
79 |
Â
->addFieldToFilter('barcode_number', array('eq' => $barcodeNumber));
|
80 |
+
|
81 |
Â
if ($collection->getSize()) {
|
82 |
+
$barcode = $collection->getFirstItem();
|
83 |
+
|
84 |
+
$this->setData($barcode->getData());
|
85 |
+
$this->setOrigData();
|
86 |
+
$this->_afterLoad();
|
87 |
Â
}
|
88 |
+
|
89 |
Â
return $this;
|
90 |
Â
}
|
91 |
Â
}
|
@@ -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,6 +35,16 @@
|
|
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_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
40 |
Â
{
|
@@ -44,27 +54,27 @@ class TIG_PostNL_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
|
44 |
Â
* @var string
|
45 |
Â
*/
|
46 |
Â
protected $_eventPrefix = 'postnl_shipment_label';
|
47 |
-
|
48 |
Â
public function _construct()
|
49 |
Â
{
|
50 |
Â
$this->_init('postnl_core/shipment_label');
|
51 |
Â
}
|
52 |
-
|
53 |
Â
/**
|
54 |
Â
* Alias for magic getLabelType()
|
55 |
-
*
|
56 |
Â
* @return mixed
|
57 |
Â
*/
|
58 |
Â
public function getType()
|
59 |
Â
{
|
60 |
Â
return $this->getLabelType();
|
61 |
Â
}
|
62 |
-
|
63 |
Â
/**
|
64 |
Â
* Gets label contents. Optional parameter to base64 decode the content
|
65 |
-
*
|
66 |
Â
* @param boolean $decode
|
67 |
-
*
|
68 |
Â
* @return string
|
69 |
Â
*/
|
70 |
Â
public function getLabel($decode = false)
|
@@ -73,7 +83,7 @@ class TIG_PostNL_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
|
73 |
Â
if ($decode && $label) {
|
74 |
Â
$label = base64_decode($label);
|
75 |
Â
}
|
76 |
-
|
77 |
Â
return $label;
|
78 |
Â
}
|
79 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@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 |
+
* Class TIG_PostNL_Model_Core_Shipment_Label
|
40 |
+
*
|
41 |
+
* @method string getLabelType()
|
42 |
+
* @method TIG_PostNL_Model_Core_Shipment_Label setLabelType(string $value)
|
43 |
+
* @method int getLabelId()
|
44 |
+
* @method TIG_PostNL_Model_Core_Shipment_Label setLabelId(int $value)
|
45 |
+
* @method TIG_PostNL_Model_Core_Shipment_Label setLabel(string $value)
|
46 |
+
* @method int getParentId()
|
47 |
+
* @method TIG_PostNL_Model_Core_Shipment_Label setParentId(int $value)
|
48 |
Â
*/
|
49 |
Â
class TIG_PostNL_Model_Core_Shipment_Label extends Mage_Core_Model_Abstract
|
50 |
Â
{
|
54 |
Â
* @var string
|
55 |
Â
*/
|
56 |
Â
protected $_eventPrefix = 'postnl_shipment_label';
|
57 |
+
|
58 |
Â
public function _construct()
|
59 |
Â
{
|
60 |
Â
$this->_init('postnl_core/shipment_label');
|
61 |
Â
}
|
62 |
+
|
63 |
Â
/**
|
64 |
Â
* Alias for magic getLabelType()
|
65 |
+
*
|
66 |
Â
* @return mixed
|
67 |
Â
*/
|
68 |
Â
public function getType()
|
69 |
Â
{
|
70 |
Â
return $this->getLabelType();
|
71 |
Â
}
|
72 |
+
|
73 |
Â
/**
|
74 |
Â
* Gets label contents. Optional parameter to base64 decode the content
|
75 |
+
*
|
76 |
Â
* @param boolean $decode
|
77 |
+
*
|
78 |
Â
* @return string
|
79 |
Â
*/
|
80 |
Â
public function getLabel($decode = false)
|
83 |
Â
if ($decode && $label) {
|
84 |
Â
$label = base64_decode($label);
|
85 |
Â
}
|
86 |
+
|
87 |
Â
return $label;
|
88 |
Â
}
|
89 |
Â
}
|
@@ -33,26 +33,21 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
40 |
Â
{
|
41 |
-
|
42 |
-
|
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(
|
56 |
Â
{
|
57 |
Â
if ($this->_lockFile !== null) {
|
58 |
Â
return $this->_lockFile;
|
@@ -61,15 +56,19 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
61 |
Â
$varDir = Mage::getConfig()->getVarDir('locks');
|
62 |
Â
$file = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
|
63 |
Â
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
Â
|
|
Â
|
|
71 |
Â
}
|
72 |
Â
|
Â
|
|
Â
|
|
73 |
Â
return $this->_lockFile;
|
74 |
Â
}
|
75 |
Â
|
@@ -82,6 +81,7 @@ 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 |
Â
|
@@ -96,7 +96,7 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
96 |
Â
public function lockAndBlock()
|
97 |
Â
{
|
98 |
Â
$this->_isLocked = true;
|
99 |
-
$
|
100 |
Â
|
101 |
Â
flock($this->_getLockFile(), LOCK_EX);
|
102 |
Â
|
@@ -111,6 +111,8 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
111 |
Â
public function unlock()
|
112 |
Â
{
|
113 |
Â
$this->_isLocked = false;
|
Â
|
|
Â
|
|
114 |
Â
$file = $this->_getLockFile();
|
115 |
Â
|
116 |
Â
flock($file, LOCK_UN);
|
@@ -137,23 +139,31 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
137 |
Â
return $this->_isLocked;
|
138 |
Â
}
|
139 |
Â
|
140 |
-
|
141 |
-
|
142 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
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 |
Â
|
@@ -162,34 +172,41 @@ class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
|
162 |
Â
*
|
163 |
Â
* @return bool
|
164 |
Â
*/
|
165 |
-
protected function _lockIsExpired()
|
166 |
-
|
167 |
-
$file
|
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 =
|
Â
|
|
177 |
Â
$contents = file_get_contents($file);
|
178 |
-
$
|
Â
|
|
179 |
Â
|
180 |
-
if($
|
181 |
-
$fp = fopen($file,'w');
|
182 |
-
flock($fp, LOCK_UN);
|
183 |
-
fclose($fp);
|
184 |
-
@unlink($file);
|
185 |
Â
return true;
|
186 |
Â
}
|
187 |
Â
|
188 |
Â
return false;
|
189 |
Â
}
|
190 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
191 |
Â
public function __destruct()
|
192 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
193 |
Â
|
Â
|
|
194 |
Â
}
|
195 |
Â
}
|
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 |
Â
class TIG_PostNL_Model_Core_Shipment_Process extends Mage_Index_Model_Process
|
40 |
Â
{
|
41 |
+
protected $_own = false;
|
42 |
+
|
Â
|
|
Â
|
|
Â
|
|
43 |
Â
protected $_isLocked = null;
|
44 |
Â
|
45 |
Â
/**
|
46 |
Â
* Get lock file resource
|
47 |
Â
*
|
Â
|
|
Â
|
|
48 |
Â
* @return resource | TIG_PostNL_Model_Core_Shipment_Process
|
49 |
Â
*/
|
50 |
+
protected function _getLockFile()
|
51 |
Â
{
|
52 |
Â
if ($this->_lockFile !== null) {
|
53 |
Â
return $this->_lockFile;
|
56 |
Â
$varDir = Mage::getConfig()->getVarDir('locks');
|
57 |
Â
$file = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
|
58 |
Â
|
59 |
+
if (is_file($file)) {
|
60 |
+
if($this->_lockIsExpired()){
|
61 |
+
unlink($file);//remove file
|
62 |
+
$this->_lockFile = fopen($file, 'x');//create new lock file
|
63 |
+
}else{
|
64 |
+
$this->_lockFile = fopen($file, 'w');
|
65 |
+
}
|
66 |
+
} else {
|
67 |
+
$this->_lockFile = fopen($file, 'x');
|
68 |
Â
}
|
69 |
Â
|
70 |
+
fwrite($this->_lockFile, date('r', Mage::getModel('core/date')->gmtTimestamp()));
|
71 |
+
|
72 |
Â
return $this->_lockFile;
|
73 |
Â
}
|
74 |
Â
|
81 |
Â
public function lock()
|
82 |
Â
{
|
83 |
Â
$this->_isLocked = true;
|
84 |
+
$this->_own = true;
|
85 |
Â
|
86 |
Â
flock($this->_getLockFile(), LOCK_EX | LOCK_NB);
|
87 |
Â
|
96 |
Â
public function lockAndBlock()
|
97 |
Â
{
|
98 |
Â
$this->_isLocked = true;
|
99 |
+
$this->_getLockFile();
|
100 |
Â
|
101 |
Â
flock($this->_getLockFile(), LOCK_EX);
|
102 |
Â
|
111 |
Â
public function unlock()
|
112 |
Â
{
|
113 |
Â
$this->_isLocked = false;
|
114 |
+
$this->_own = false;
|
115 |
+
|
116 |
Â
$file = $this->_getLockFile();
|
117 |
Â
|
118 |
Â
flock($file, LOCK_UN);
|
139 |
Â
return $this->_isLocked;
|
140 |
Â
}
|
141 |
Â
|
142 |
+
if ($this->_own === true) {
|
143 |
+
$this->_isLocked = false;
|
144 |
+
|
145 |
+
return false;
|
146 |
+
}
|
147 |
+
|
148 |
+
$varDir = Mage::getConfig()->getVarDir('locks');
|
149 |
+
$lockFile = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
|
150 |
+
|
151 |
+
if (!is_file($lockFile)) {
|
152 |
+
$this->_isLocked = false;
|
153 |
+
|
154 |
Â
return false;
|
155 |
Â
}
|
Â
|
|
156 |
Â
|
157 |
Â
//if the lock exists and exists for longer then 5minutes then remove lock & return false
|
158 |
Â
if($this->_lockIsExpired()){
|
Â
|
|
Â
|
|
159 |
Â
@unlink($lockFile);
|
160 |
+
$this->_isLocked = false;
|
161 |
Â
|
Â
|
|
162 |
Â
return false;
|
163 |
Â
}
|
164 |
Â
|
165 |
+
$this->_isLocked = true;
|
166 |
+
|
167 |
Â
return true;
|
168 |
Â
}
|
169 |
Â
|
172 |
Â
*
|
173 |
Â
* @return bool
|
174 |
Â
*/
|
175 |
+
protected function _lockIsExpired(){
|
176 |
+
$varDir = Mage::getConfig()->getVarDir('locks');
|
177 |
+
$file = $varDir . DS . 'postnl_process_'.$this->getId().'.lock';
|
178 |
Â
|
179 |
Â
if(!is_file($file)){
|
Â
|
|
Â
|
|
Â
|
|
180 |
Â
return false;
|
181 |
Â
}
|
182 |
Â
|
183 |
+
$fiveMinAgo = Mage::getModel('core/date')->gmtTimestamp();
|
184 |
+
|
185 |
Â
$contents = file_get_contents($file);
|
186 |
+
$lockTime = strtotime($contents);
|
187 |
+
$lockExpiration = $lockTime + 300; //300s = 5min
|
188 |
Â
|
189 |
+
if($lockExpiration <= $fiveMinAgo){
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
190 |
Â
return true;
|
191 |
Â
}
|
192 |
Â
|
193 |
Â
return false;
|
194 |
Â
}
|
195 |
Â
|
196 |
+
/**
|
197 |
+
* Destroy the lock file if it still exists
|
198 |
+
*
|
199 |
+
* @return void
|
200 |
+
*/
|
201 |
Â
public function __destruct()
|
202 |
Â
{
|
203 |
+
$varDir = Mage::getConfig()->getVarDir('locks');
|
204 |
+
$lockFile = $varDir . DS . 'postnl_process_' . $this->getId() . '.lock';
|
205 |
+
|
206 |
+
if (is_file($lockFile)) {
|
207 |
+
@unlink($lockFile);
|
208 |
+
}
|
209 |
Â
|
210 |
+
return;
|
211 |
Â
}
|
212 |
Â
}
|
@@ -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,6 +35,27 @@
|
|
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_Model_Core_Shipment_Status_History extends Mage_Core_Model_Abstract
|
40 |
Â
{
|
@@ -44,17 +65,17 @@ class TIG_PostNL_Model_Core_Shipment_Status_History extends Mage_Core_Model_Abst
|
|
44 |
Â
* @var string
|
45 |
Â
*/
|
46 |
Â
protected $_eventPrefix = 'postnl_shipment_status_history';
|
47 |
-
|
48 |
Â
public function _construct()
|
49 |
Â
{
|
50 |
Â
$this->_init('postnl_core/shipment_status_history');
|
51 |
Â
}
|
52 |
-
|
53 |
Â
/**
|
54 |
Â
* Set the 'phase' attribute. The phase must be formatted as a 2 digit number (i.e. 01, 04, 12, 99 etc.)
|
55 |
-
*
|
56 |
Â
* @param string | int $phase
|
57 |
-
*
|
58 |
Â
* @return TIG_PostNL_Model_Core_Shipment_Status_History
|
59 |
Â
*/
|
60 |
Â
public function setPhase($phase)
|
@@ -62,72 +83,78 @@ class TIG_PostNL_Model_Core_Shipment_Status_History extends Mage_Core_Model_Abst
|
|
62 |
Â
if (strlen($phase) < 2) {
|
63 |
Â
$phase = '0' . $phase;
|
64 |
Â
}
|
65 |
-
|
66 |
Â
$this->setData('phase', $phase);
|
67 |
Â
return $this;
|
68 |
Â
}
|
69 |
-
|
70 |
Â
/**
|
71 |
Â
* Load a history item based on a postnl shipment id and a status code.
|
72 |
-
*
|
73 |
Â
* @param int $shipmentId
|
74 |
Â
* @param string $code
|
75 |
-
*
|
76 |
Â
* @return TIG_PostNL_Model_Core_Shipment_Status_History
|
77 |
Â
*/
|
78 |
Â
public function loadByShipmentIdAndCode($shipmentId, $code)
|
79 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
80 |
Â
$collection = $this->getCollection();
|
81 |
Â
$collection->addFieldToSelect('status_id')
|
82 |
Â
->addFieldToFilter('parent_id', array('eq' => $shipmentId))
|
83 |
Â
->addFieldToFilter('code', array('eq' => $code));
|
84 |
-
|
85 |
Â
$collection->getSelect()->limit(1); //we only want 1 item
|
86 |
-
|
87 |
Â
$id = $collection->getFirstItem()->getId();
|
88 |
-
|
89 |
Â
if ($id) {
|
90 |
Â
$this->load($id);
|
91 |
Â
}
|
92 |
-
|
93 |
Â
return $this;
|
94 |
Â
}
|
95 |
-
|
96 |
Â
/**
|
97 |
Â
* Check if a status history item exists for the given postnl shipment and status
|
98 |
-
*
|
99 |
Â
* @param int $shipmentId
|
100 |
-
* @param
|
101 |
-
*
|
102 |
Â
* @return boolean
|
103 |
Â
*/
|
104 |
Â
public function statusHistoryIsNew($shipmentId, $status)
|
105 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
106 |
Â
$collection = $this->getCollection();
|
107 |
Â
$collection->addFieldToSelect('status_id')
|
108 |
Â
->addFieldToFilter('parent_id', array('eq' => $shipmentId))
|
109 |
Â
->addFieldToFilter('code', array('eq' => $status->Code));
|
110 |
-
|
111 |
Â
if ($status->LocationCode !== '') {
|
112 |
Â
$collection->addFieldToFilter('location_code', array('eq' => $status->LocationCode));
|
113 |
Â
}
|
114 |
-
|
115 |
Â
if ($status->DestinationLocationCode !== '') {
|
116 |
Â
$collection->addFieldToFilter('destination_location_code', array('eq' => $status->DestinationLocationCode));
|
117 |
Â
}
|
118 |
-
|
119 |
Â
if ($status->RouteCode !== '') {
|
120 |
Â
$collection->addFieldToFilter('route_code', array('eq' => $status->RouteCode));
|
121 |
Â
}
|
122 |
-
|
123 |
Â
if ($status->RouteName !== '') {
|
124 |
Â
$collection->addFieldToFilter('route_name', array('eq' => $status->RouteName));
|
125 |
Â
}
|
126 |
-
|
127 |
Â
if ($collection->getSize() < 1) {
|
128 |
Â
return true;
|
129 |
Â
}
|
130 |
-
|
131 |
Â
return false;
|
132 |
Â
}
|
133 |
Â
}
|
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 |
+
* Class TIG_PostNL_Model_Core_Shipment_Status_History
|
40 |
+
*
|
41 |
+
* @method string getTimestamp()
|
42 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setTimestamp(string $value)
|
43 |
+
* @method string getRouteName()
|
44 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setRouteName(string $value)
|
45 |
+
* @method string getDescription()
|
46 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setDescription(string $value)
|
47 |
+
* @method string getLocationCode()
|
48 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setLocationCode(string $value)
|
49 |
+
* @method int getStatusId()
|
50 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setStatusId(int $value)
|
51 |
+
* @method string getCode()
|
52 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setCode(string $value)
|
53 |
+
* @method string getDestinationLocationCode()
|
54 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setDestinationLocationCode(string $value)
|
55 |
+
* @method string getRouteCode()
|
56 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setRouteCode(string $value)
|
57 |
+
* @method int getParentId()
|
58 |
+
* @method TIG_PostNL_Model_Core_Shipment_Status_History setParentId(int $value)
|
59 |
Â
*/
|
60 |
Â
class TIG_PostNL_Model_Core_Shipment_Status_History extends Mage_Core_Model_Abstract
|
61 |
Â
{
|
65 |
Â
* @var string
|
66 |
Â
*/
|
67 |
Â
protected $_eventPrefix = 'postnl_shipment_status_history';
|
68 |
+
|
69 |
Â
public function _construct()
|
70 |
Â
{
|
71 |
Â
$this->_init('postnl_core/shipment_status_history');
|
72 |
Â
}
|
73 |
+
|
74 |
Â
/**
|
75 |
Â
* Set the 'phase' attribute. The phase must be formatted as a 2 digit number (i.e. 01, 04, 12, 99 etc.)
|
76 |
+
*
|
77 |
Â
* @param string | int $phase
|
78 |
+
*
|
79 |
Â
* @return TIG_PostNL_Model_Core_Shipment_Status_History
|
80 |
Â
*/
|
81 |
Â
public function setPhase($phase)
|
83 |
Â
if (strlen($phase) < 2) {
|
84 |
Â
$phase = '0' . $phase;
|
85 |
Â
}
|
86 |
+
|
87 |
Â
$this->setData('phase', $phase);
|
88 |
Â
return $this;
|
89 |
Â
}
|
90 |
+
|
91 |
Â
/**
|
92 |
Â
* Load a history item based on a postnl shipment id and a status code.
|
93 |
+
*
|
94 |
Â
* @param int $shipmentId
|
95 |
Â
* @param string $code
|
96 |
+
*
|
97 |
Â
* @return TIG_PostNL_Model_Core_Shipment_Status_History
|
98 |
Â
*/
|
99 |
Â
public function loadByShipmentIdAndCode($shipmentId, $code)
|
100 |
Â
{
|
101 |
+
/**
|
102 |
+
* @var TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection $collection
|
103 |
+
*/
|
104 |
Â
$collection = $this->getCollection();
|
105 |
Â
$collection->addFieldToSelect('status_id')
|
106 |
Â
->addFieldToFilter('parent_id', array('eq' => $shipmentId))
|
107 |
Â
->addFieldToFilter('code', array('eq' => $code));
|
108 |
+
|
109 |
Â
$collection->getSelect()->limit(1); //we only want 1 item
|
110 |
+
|
111 |
Â
$id = $collection->getFirstItem()->getId();
|
112 |
+
|
113 |
Â
if ($id) {
|
114 |
Â
$this->load($id);
|
115 |
Â
}
|
116 |
+
|
117 |
Â
return $this;
|
118 |
Â
}
|
119 |
+
|
120 |
Â
/**
|
121 |
Â
* Check if a status history item exists for the given postnl shipment and status
|
122 |
+
*
|
123 |
Â
* @param int $shipmentId
|
124 |
+
* @param $status
|
125 |
+
*
|
126 |
Â
* @return boolean
|
127 |
Â
*/
|
128 |
Â
public function statusHistoryIsNew($shipmentId, $status)
|
129 |
Â
{
|
130 |
+
/**
|
131 |
+
* @var TIG_PostNL_Model_Core_Resource_Shipment_Status_History_Collection $collection
|
132 |
+
*/
|
133 |
Â
$collection = $this->getCollection();
|
134 |
Â
$collection->addFieldToSelect('status_id')
|
135 |
Â
->addFieldToFilter('parent_id', array('eq' => $shipmentId))
|
136 |
Â
->addFieldToFilter('code', array('eq' => $status->Code));
|
137 |
+
|
138 |
Â
if ($status->LocationCode !== '') {
|
139 |
Â
$collection->addFieldToFilter('location_code', array('eq' => $status->LocationCode));
|
140 |
Â
}
|
141 |
+
|
142 |
Â
if ($status->DestinationLocationCode !== '') {
|
143 |
Â
$collection->addFieldToFilter('destination_location_code', array('eq' => $status->DestinationLocationCode));
|
144 |
Â
}
|
145 |
+
|
146 |
Â
if ($status->RouteCode !== '') {
|
147 |
Â
$collection->addFieldToFilter('route_code', array('eq' => $status->RouteCode));
|
148 |
Â
}
|
149 |
+
|
150 |
Â
if ($status->RouteName !== '') {
|
151 |
Â
$collection->addFieldToFilter('route_name', array('eq' => $status->RouteName));
|
152 |
Â
}
|
153 |
+
|
154 |
Â
if ($collection->getSize() < 1) {
|
155 |
Â
return true;
|
156 |
Â
}
|
157 |
+
|
158 |
Â
return false;
|
159 |
Â
}
|
160 |
Â
}
|
@@ -0,0 +1,152 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
+
* | | / _ \\ __\\__ \ | |
|
6 |
+
* | | | |_| || | / __ \_| |__
|
7 |
+
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
+
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
+
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
+
*
|
22 |
+
* NOTICE OF LICENSE
|
23 |
+
*
|
24 |
+
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
+
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
+
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
+
* to servicedesk@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 |
+
* @method boolean hasIsIncludingTax()
|
40 |
+
* @method TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee setIsIncludingTax(boolean $value)
|
41 |
+
* @method boolean hasMockShippingAddress()
|
42 |
+
* @method TIG_PostNL_Model_DeliveryOptions_System_Config_Backend_ValidateFee setMockShippingAddress(Mage_Customer_Model_Address $value)
|
43 |
+
*/
|
44 |
+
class TIG_PostNL_Model_Core_System_Config_Backend_ValidateDefaultOption extends Mage_Core_Model_Config_Data
|
45 |
+
{
|
46 |
+
/**
|
47 |
+
* Xpath to supported options configuration setting
|
48 |
+
*/
|
49 |
+
const XPATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Validate that a chosen default option is actually available.
|
53 |
+
*
|
54 |
+
* @param $value
|
55 |
+
*
|
56 |
+
* @return bool
|
57 |
+
*
|
58 |
+
* @throws TIG_PostNL_Exception
|
59 |
+
*/
|
60 |
+
public function validateDefaultOption($value)
|
61 |
+
{
|
62 |
+
/**
|
63 |
+
* Get a list of supported options.
|
64 |
+
*/
|
65 |
+
$postData = Mage::app()->getRequest()->getPost();
|
66 |
+
if (isset($postData['groups']['cif_product_options']['fields']['supported_product_options']['value'])) {
|
67 |
+
$options = $postData['groups']['cif_product_options']['fields']['supported_product_options']['value'];
|
68 |
+
} else {
|
69 |
+
$options = Mage::getStoreConfig(self::XPATH_SUPPORTED_PRODUCT_OPTIONS, Mage_Core_Model_App::ADMIN_STORE_ID);
|
70 |
+
$options = explode(',', $options);
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Check if the current field's value is among them.
|
75 |
+
*/
|
76 |
+
if (in_array($value, $options)) {
|
77 |
+
return true;
|
78 |
+
}
|
79 |
+
|
80 |
+
$helper = Mage::helper('postnl');
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Get the system.xml configuration.
|
84 |
+
*/
|
85 |
+
$configFields = Mage::getSingleton('adminhtml/config');
|
86 |
+
$sections = $configFields->getSections('postnl');
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Get the path of the current field split into parts.
|
90 |
+
*/
|
91 |
+
$path = $this->getPath();
|
92 |
+
$pathParts = explode('/', $path);
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Search for the label of the current field and translate it.
|
96 |
+
*/
|
97 |
+
$label = $sections->$pathParts[0]->groups->$pathParts[1]->fields->$pathParts[2]->label;
|
98 |
+
$label = $helper->__($label);
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Get the translated label of the supported options field.
|
102 |
+
*/
|
103 |
+
$supportedOptionsLabel =(string) $sections->postnl
|
104 |
+
->groups
|
105 |
+
->cif_product_options
|
106 |
+
->fields
|
107 |
+
->supported_product_options
|
108 |
+
->label;
|
109 |
+
$supportedOptionsLabel = $helper->__($supportedOptionsLabel);
|
110 |
+
|
111 |
+
/**
|
112 |
+
* Format the warning message.
|
113 |
+
*/
|
114 |
+
$message = $helper->__(
|
115 |
+
"You have chosen a value for the '%s' field that is not supported. Please select a option that you have " .
|
116 |
+
"selected in the '%s' field, otherwise you may not be able to send shipments of this type.",
|
117 |
+
$label,
|
118 |
+
$supportedOptionsLabel
|
119 |
+
);
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Add the warning.
|
123 |
+
*/
|
124 |
+
$helper->addSessionMessage(
|
125 |
+
'adminhtml',
|
126 |
+
'POSTNL-0159',
|
127 |
+
'warning',
|
128 |
+
$message
|
129 |
+
);
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Set this field's value to null, as it's selected option is invalid.
|
133 |
+
*/
|
134 |
+
$this->setValue(null);
|
135 |
+
|
136 |
+
return true;
|
137 |
+
}
|
138 |
+
|
139 |
+
/**
|
140 |
+
* @return Mage_Core_Model_Abstract
|
141 |
+
*/
|
142 |
+
protected function _beforeSave()
|
143 |
+
{
|
144 |
+
$value = $this->getValue();
|
145 |
+
|
146 |
+
if ($value) {
|
147 |
+
$this->validateDefaultOption($value);
|
148 |
+
}
|
149 |
+
|
150 |
+
return parent::_beforeSave();
|
151 |
+
}
|
152 |
+
}
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
@@ -46,11 +46,13 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
Â
*
|
Â
|
|
Â
|
|
49 |
Â
* @return array
|
50 |
Â
*
|
51 |
Â
* @todo implement COD
|
52 |
Â
*/
|
53 |
-
public function toOptionArray()
|
54 |
Â
{
|
55 |
Â
$helper = Mage::helper('postnl');
|
56 |
Â
$availableOptions = array(
|
@@ -67,58 +69,71 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
67 |
Â
* @todo implement these options
|
68 |
Â
*/
|
69 |
Â
/*'3086' => array(
|
70 |
-
'value'
|
71 |
-
'label'
|
Â
|
|
72 |
Â
),
|
73 |
Â
'3091' => array(
|
74 |
-
'value'
|
75 |
-
'label'
|
Â
|
|
76 |
Â
),
|
77 |
Â
'3093' => array(
|
78 |
-
'value'
|
79 |
-
'label'
|
Â
|
|
80 |
Â
),
|
81 |
Â
'3097' => array(
|
82 |
-
'value'
|
83 |
-
'label'
|
Â
|
|
84 |
Â
),*/
|
85 |
Â
'3087' => array(
|
86 |
Â
'value' => '3087',
|
87 |
Â
'label' => $helper->__('Extra Cover'),
|
88 |
Â
'isExtraCover' => true,
|
Â
|
|
89 |
Â
),
|
90 |
Â
'3094' => array(
|
91 |
Â
'value' => '3094',
|
92 |
Â
'label' => $helper->__('Extra cover + Return when not home'),
|
93 |
Â
'isExtraCover' => true,
|
Â
|
|
94 |
Â
),
|
95 |
Â
'3189' => array(
|
96 |
Â
'value' => '3189',
|
97 |
Â
'label' => $helper->__('Signature on delivery'),
|
98 |
Â
),
|
99 |
Â
'3089' => array(
|
100 |
-
'value'
|
101 |
-
'label'
|
Â
|
|
102 |
Â
),
|
103 |
Â
'3389' => array(
|
104 |
Â
'value' => '3389',
|
105 |
Â
'label' => $helper->__('Signature on delivery + Return when not home'),
|
106 |
Â
),
|
107 |
Â
'3096' => array(
|
108 |
-
'value'
|
109 |
-
'label'
|
Â
|
|
Â
|
|
Â
|
|
110 |
Â
),
|
111 |
Â
'3090' => array(
|
112 |
-
'value'
|
113 |
-
'label'
|
Â
|
|
114 |
Â
),
|
115 |
Â
'3385' => array(
|
116 |
-
'value'
|
117 |
-
'label'
|
Â
|
|
118 |
Â
),
|
119 |
Â
'3390' => array(
|
120 |
-
'value'
|
121 |
-
'label'
|
Â
|
|
122 |
Â
),
|
123 |
Â
),
|
124 |
Â
),
|
@@ -132,19 +147,22 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
132 |
Â
*/
|
133 |
Â
/*'3535' => array(
|
134 |
Â
'value' => '3535',
|
135 |
-
'label' => $helper->__('Post Office + COD')
|
136 |
Â
),
|
137 |
Â
'3545' => array(
|
138 |
Â
'value' => '3545',
|
139 |
-
'label' => $helper->__('Post Office + COD + Notification')
|
Â
|
|
140 |
Â
),
|
141 |
Â
'3536' => array(
|
142 |
Â
'value' => '3536',
|
143 |
-
'label' => $helper->__('Post Office + COD + Extra Cover')
|
Â
|
|
144 |
Â
),
|
145 |
Â
'3546' => array(
|
146 |
Â
'value' => '3546',
|
147 |
-
'label' => $helper->__('Post Office + COD + Extra Cover + Notification')
|
Â
|
|
148 |
Â
),*/
|
149 |
Â
'3534' => array(
|
150 |
Â
'value' => '3534',
|
@@ -155,14 +173,16 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
155 |
Â
'value' => '3544',
|
156 |
Â
'label' => $helper->__('Post Office + Extra Cover + Notification'),
|
157 |
Â
'isExtraCover' => true,
|
Â
|
|
158 |
Â
),
|
159 |
Â
'3533' => array(
|
160 |
Â
'value' => '3533',
|
161 |
-
'label' => $helper->__('Post Office + Signature on Delivery')
|
162 |
Â
),
|
163 |
Â
'3543' => array(
|
164 |
Â
'value' => '3543',
|
165 |
-
'label' => $helper->__('Post Office + Signature on Delivery + Notification')
|
Â
|
|
166 |
Â
),
|
167 |
Â
),
|
168 |
Â
),
|
@@ -178,8 +198,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
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,
|
@@ -206,6 +225,16 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
206 |
Â
'value' => '4945',
|
207 |
Â
'label' => $helper->__('GlobalPack'),
|
208 |
Â
'isExtraCover' => true,
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
209 |
Â
),
|
210 |
Â
),
|
211 |
Â
),
|
@@ -219,23 +248,32 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
219 |
Â
);
|
220 |
Â
}
|
221 |
Â
|
222 |
-
$this->_markDefault($availableOptions);
|
223 |
-
|
224 |
Â
return $availableOptions;
|
225 |
Â
}
|
226 |
Â
|
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
|
231 |
Â
* @param bool $withExtraCover
|
232 |
Â
* @param boolean|int $storeId
|
233 |
-
* @param boolean $codesOnly
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
234 |
Â
*
|
235 |
Â
* @return array
|
236 |
Â
*/
|
237 |
-
public function getAvailableOptions($withDefault = false,
|
238 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
239 |
Â
if ($storeId === false) {
|
240 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
241 |
Â
}
|
@@ -243,7 +281,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
243 |
Â
$helper = Mage::helper('postnl');
|
244 |
Â
$canUseEpsBEOnly = $helper->canUseEpsBEOnlyOption();
|
245 |
Â
|
246 |
-
$options = $this->toOptionArray();
|
247 |
Â
|
248 |
Â
/**
|
249 |
Â
* Get a list of all possible options
|
@@ -269,10 +307,19 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
269 |
Â
$supportedOptionsArray[] = '4955';
|
270 |
Â
}
|
271 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
272 |
Â
/**
|
273 |
Â
* Check each standard option to see if it's supprted
|
274 |
Â
*/
|
275 |
-
$availableStandardOptions = array();
|
276 |
Â
foreach ($options['standard_options']['value'] as $option) {
|
277 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
278 |
Â
continue;
|
@@ -287,13 +334,21 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
287 |
Â
continue;
|
288 |
Â
}
|
289 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
290 |
Â
$availableStandardOptions[] = $option;
|
291 |
Â
}
|
292 |
Â
|
293 |
Â
/**
|
294 |
Â
* Check each pakje gemak option to see if it's supprted
|
295 |
Â
*/
|
296 |
-
$availablePakjeGemakOptions = array();
|
297 |
Â
foreach ($options['pakjegemak_options']['value'] as $option) {
|
298 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
299 |
Â
continue;
|
@@ -308,13 +363,21 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
308 |
Â
continue;
|
309 |
Â
}
|
310 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
311 |
Â
$availablePakjeGemakOptions[] = $option;
|
312 |
Â
}
|
313 |
Â
|
314 |
Â
/**
|
315 |
Â
* Check each eu option to see if it's supprted
|
316 |
Â
*/
|
317 |
-
$availableEuOptions = array();
|
318 |
Â
foreach ($options['eu_options']['value'] as $option) {
|
319 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
320 |
Â
continue;
|
@@ -329,13 +392,17 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
329 |
Â
continue;
|
330 |
Â
}
|
331 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
332 |
Â
$availableEuOptions[] = $option;
|
333 |
Â
}
|
334 |
Â
|
335 |
Â
/**
|
336 |
-
* Check each
|
337 |
Â
*/
|
338 |
-
$availableGlobalOptions = array();
|
339 |
Â
if ($helper->isGlobalAllowed()) {
|
340 |
Â
foreach ($options['global_options']['value'] as $option) {
|
341 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
@@ -351,15 +418,48 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
351 |
Â
continue;
|
352 |
Â
}
|
353 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
354 |
Â
$availableGlobalOptions[] = $option;
|
355 |
Â
}
|
356 |
Â
}
|
357 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
358 |
Â
/**
|
359 |
Â
* If we only need the codes, we can return the $availableOptions array. Otherwise, we need to order and merge the
|
360 |
Â
* other arrays
|
361 |
Â
*/
|
362 |
-
if ($codesOnly === true) {
|
363 |
Â
return $availableOptions;
|
364 |
Â
}
|
365 |
Â
|
@@ -394,12 +494,33 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
394 |
Â
);
|
395 |
Â
}
|
396 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
397 |
Â
return $availableOptions;
|
398 |
Â
}
|
399 |
Â
|
400 |
Â
/**
|
401 |
Â
* Get the list of available product options that have extra cover
|
402 |
Â
*
|
Â
|
|
Â
|
|
403 |
Â
* @return array
|
404 |
Â
*/
|
405 |
Â
public function getExtraCoverOptions($valuesOnly = false)
|
@@ -465,32 +586,25 @@ class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
|
465 |
Â
/**
|
466 |
Â
* Mark each default option as default if it is present in the available options array
|
467 |
Â
*/
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
Â
|
|
Â
|
|
473 |
Â
}
|
474 |
Â
|
475 |
-
if (isset($options['
|
476 |
-
|
477 |
-
&& isset($options['pakjegemak_options']['value'][$defaultOptions['eu']])
|
478 |
-
) {
|
479 |
-
$options['pakjegemak_options']['value'][$defaultOptions['pakjegemak']]['label'] .= ' ' . $helper->__('(default)');
|
480 |
Â
}
|
481 |
Â
|
482 |
-
if (isset($options['
|
483 |
-
|
484 |
-
&& isset($options['eu_options']['value'][$defaultOptions['eu']])
|
485 |
-
) {
|
486 |
-
$options['eu_options']['value'][$defaultOptions['eu']]['label'] .= ' ' . $helper->__('(default)');
|
487 |
Â
}
|
488 |
Â
|
489 |
-
if (isset($options['
|
490 |
-
|
491 |
-
&& isset($options['global_options']['value'][$defaultOptions['global']])
|
492 |
-
) {
|
493 |
-
$options['global_options']['value'][$defaultOptions['global']]['label'] .= ' ' . $helper->__('(default)');
|
494 |
Â
}
|
495 |
Â
|
496 |
Â
return $options;
|
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 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_AllProductOptions
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
Â
*
|
49 |
+
* @param boolean $markDefault Flag that determines whether default options will be marked as such.
|
50 |
+
*
|
51 |
Â
* @return array
|
52 |
Â
*
|
53 |
Â
* @todo implement COD
|
54 |
Â
*/
|
55 |
+
public function toOptionArray($markDefault = true)
|
56 |
Â
{
|
57 |
Â
$helper = Mage::helper('postnl');
|
58 |
Â
$availableOptions = array(
|
69 |
Â
* @todo implement these options
|
70 |
Â
*/
|
71 |
Â
/*'3086' => array(
|
72 |
+
'value' => '3086',
|
73 |
+
'label' => $helper->__('COD'),
|
74 |
+
'isAvond' => true,
|
75 |
Â
),
|
76 |
Â
'3091' => array(
|
77 |
+
'value' => '3091',
|
78 |
+
'label' => $helper->__('COD + Extra cover'),
|
79 |
+
'isAvond' => true,
|
80 |
Â
),
|
81 |
Â
'3093' => array(
|
82 |
+
'value' => '3093',
|
83 |
+
'label' => $helper->__('COD + Return when not home'),
|
84 |
+
'isAvond' => true,
|
85 |
Â
),
|
86 |
Â
'3097' => array(
|
87 |
+
'value' => '3097',
|
88 |
+
'label' => $helper->__('COD + Extra cover + Return when not home'),
|
89 |
+
'isAvond' => true,
|
90 |
Â
),*/
|
91 |
Â
'3087' => array(
|
92 |
Â
'value' => '3087',
|
93 |
Â
'label' => $helper->__('Extra Cover'),
|
94 |
Â
'isExtraCover' => true,
|
95 |
+
'isAvond' => true,
|
96 |
Â
),
|
97 |
Â
'3094' => array(
|
98 |
Â
'value' => '3094',
|
99 |
Â
'label' => $helper->__('Extra cover + Return when not home'),
|
100 |
Â
'isExtraCover' => true,
|
101 |
+
'isAvond' => true,
|
102 |
Â
),
|
103 |
Â
'3189' => array(
|
104 |
Â
'value' => '3189',
|
105 |
Â
'label' => $helper->__('Signature on delivery'),
|
106 |
Â
),
|
107 |
Â
'3089' => array(
|
108 |
+
'value' => '3089',
|
109 |
+
'label' => $helper->__('Signature on delivery + Delivery to stated address only'),
|
110 |
+
'isAvond' => true,
|
111 |
Â
),
|
112 |
Â
'3389' => array(
|
113 |
Â
'value' => '3389',
|
114 |
Â
'label' => $helper->__('Signature on delivery + Return when not home'),
|
115 |
Â
),
|
116 |
Â
'3096' => array(
|
117 |
+
'value' => '3096',
|
118 |
+
'label' => $helper->__(
|
119 |
+
'Signature on delivery + Deliver to stated address only + Return when not home'
|
120 |
+
),
|
121 |
+
'isAvond' => true,
|
122 |
Â
),
|
123 |
Â
'3090' => array(
|
124 |
+
'value' => '3090',
|
125 |
+
'label' => $helper->__('Delivery to neighbour + Return when not home'),
|
126 |
+
'isAvond' => true,
|
127 |
Â
),
|
128 |
Â
'3385' => array(
|
129 |
+
'value' => '3385',
|
130 |
+
'label' => $helper->__('Deliver to stated address only'),
|
131 |
+
'isAvond' => true,
|
132 |
Â
),
|
133 |
Â
'3390' => array(
|
134 |
+
'value' => '3390',
|
135 |
+
'label' => $helper->__('Deliver to stated address only + Return when not home'),
|
136 |
+
'isAvond' => true,
|
137 |
Â
),
|
138 |
Â
),
|
139 |
Â
),
|
147 |
Â
*/
|
148 |
Â
/*'3535' => array(
|
149 |
Â
'value' => '3535',
|
150 |
+
'label' => $helper->__('Post Office + COD'),
|
151 |
Â
),
|
152 |
Â
'3545' => array(
|
153 |
Â
'value' => '3545',
|
154 |
+
'label' => $helper->__('Post Office + COD + Notification'),
|
155 |
+
'isPge' => true,
|
156 |
Â
),
|
157 |
Â
'3536' => array(
|
158 |
Â
'value' => '3536',
|
159 |
+
'label' => $helper->__('Post Office + COD + Extra Cover'),
|
160 |
+
'isPge' => true,
|
161 |
Â
),
|
162 |
Â
'3546' => array(
|
163 |
Â
'value' => '3546',
|
164 |
+
'label' => $helper->__('Post Office + COD + Extra Cover + Notification'),
|
165 |
+
'isPge' => true,
|
166 |
Â
),*/
|
167 |
Â
'3534' => array(
|
168 |
Â
'value' => '3534',
|
173 |
Â
'value' => '3544',
|
174 |
Â
'label' => $helper->__('Post Office + Extra Cover + Notification'),
|
175 |
Â
'isExtraCover' => true,
|
176 |
+
'isPge' => true,
|
177 |
Â
),
|
178 |
Â
'3533' => array(
|
179 |
Â
'value' => '3533',
|
180 |
+
'label' => $helper->__('Post Office + Signature on Delivery'),
|
181 |
Â
),
|
182 |
Â
'3543' => array(
|
183 |
Â
'value' => '3543',
|
184 |
+
'label' => $helper->__('Post Office + Signature on Delivery + Notification'),
|
185 |
+
'isPge' => true,
|
186 |
Â
),
|
187 |
Â
),
|
188 |
Â
),
|
198 |
Â
*
|
199 |
Â
* @deprecated v1.1.2
|
200 |
Â
*/
|
201 |
+
/*'4955' => array(
|
Â
|
|
202 |
Â
'value' => '4955',
|
203 |
Â
'label' => $helper->__('EU Pack Standard (Belgium only, no signature)'),
|
204 |
Â
'isBelgiumOnly' => true,
|
225 |
Â
'value' => '4945',
|
226 |
Â
'label' => $helper->__('GlobalPack'),
|
227 |
Â
'isExtraCover' => true,
|
228 |
+
'extraCover' => 200,
|
229 |
+
),
|
230 |
+
),
|
231 |
+
),
|
232 |
+
'pakketautomaat' => array(
|
233 |
+
'label' => $helper->__('Parcel Dispenser options'),
|
234 |
+
'value' => array(
|
235 |
+
'3553' => array(
|
236 |
+
'value' => '3553',
|
237 |
+
'label' => $helper->__('Parcel Dispenser'),
|
238 |
Â
),
|
239 |
Â
),
|
240 |
Â
),
|
248 |
Â
);
|
249 |
Â
}
|
250 |
Â
|
Â
|
|
Â
|
|
251 |
Â
return $availableOptions;
|
252 |
Â
}
|
253 |
Â
|
254 |
Â
/**
|
255 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
256 |
Â
*
|
257 |
+
* @param boolean $withDefault Determines whether or not a 'default' option is prepended to the array
|
258 |
Â
* @param bool $withExtraCover
|
259 |
Â
* @param boolean|int $storeId
|
260 |
+
* @param boolean $codesOnly Flag that dtermines whether to only return the product codes and not the
|
261 |
+
* labels
|
262 |
+
* @param boolean $flat FLag that dtermines whether to return a flat 'code => label' array
|
263 |
+
* @param boolean $markDefault Flag that determines whether default options will be marked as such.
|
264 |
+
* @param boolean $addDeliveryOptions If set to true, additional options will be added for evening delivery and
|
265 |
+
* early pickup shipment types.
|
266 |
Â
*
|
267 |
Â
* @return array
|
268 |
Â
*/
|
269 |
+
public function getAvailableOptions($withDefault = false,
|
270 |
+
$withExtraCover = true,
|
271 |
+
$storeId = false,
|
272 |
+
$codesOnly = false,
|
273 |
+
$flat = false,
|
274 |
+
$markDefault = true,
|
275 |
+
$addDeliveryOptions = false
|
276 |
+
) {
|
277 |
Â
if ($storeId === false) {
|
278 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
279 |
Â
}
|
281 |
Â
$helper = Mage::helper('postnl');
|
282 |
Â
$canUseEpsBEOnly = $helper->canUseEpsBEOnlyOption();
|
283 |
Â
|
284 |
+
$options = $this->toOptionArray($markDefault);
|
285 |
Â
|
286 |
Â
/**
|
287 |
Â
* Get a list of all possible options
|
307 |
Â
$supportedOptionsArray[] = '4955';
|
308 |
Â
}
|
309 |
Â
|
310 |
+
/**
|
311 |
+
* Initialize empty arrays for each supported shipment type. These will be filled with available options.
|
312 |
+
*/
|
313 |
+
$availableStandardOptions = array();
|
314 |
+
$availableAvondOptions = array();
|
315 |
+
$availablePakjeGemakOptions = array();
|
316 |
+
$availablePgeOptions = array();
|
317 |
+
$availableEuOptions = array();
|
318 |
+
$availableGlobalOptions = array();
|
319 |
+
|
320 |
Â
/**
|
321 |
Â
* Check each standard option to see if it's supprted
|
322 |
Â
*/
|
Â
|
|
323 |
Â
foreach ($options['standard_options']['value'] as $option) {
|
324 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
325 |
Â
continue;
|
334 |
Â
continue;
|
335 |
Â
}
|
336 |
Â
|
337 |
+
if ($flat === true) {
|
338 |
+
$availableOptions[$option['value']] = $option['label'];
|
339 |
+
continue;
|
340 |
+
}
|
341 |
+
|
342 |
+
if (isset($option['isAvond']) && $option['isAvond']) {
|
343 |
+
$availableAvondOptions[] = $option;
|
344 |
+
}
|
345 |
+
|
346 |
Â
$availableStandardOptions[] = $option;
|
347 |
Â
}
|
348 |
Â
|
349 |
Â
/**
|
350 |
Â
* Check each pakje gemak option to see if it's supprted
|
351 |
Â
*/
|
Â
|
|
352 |
Â
foreach ($options['pakjegemak_options']['value'] as $option) {
|
353 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
354 |
Â
continue;
|
363 |
Â
continue;
|
364 |
Â
}
|
365 |
Â
|
366 |
+
if ($flat === true) {
|
367 |
+
$availableOptions[$option['value']] = $option['label'];
|
368 |
+
continue;
|
369 |
+
}
|
370 |
+
|
371 |
+
if (isset($option['isPge']) && $option['isPge']) {
|
372 |
+
$availablePgeOptions[] = $option;
|
373 |
+
}
|
374 |
+
|
375 |
Â
$availablePakjeGemakOptions[] = $option;
|
376 |
Â
}
|
377 |
Â
|
378 |
Â
/**
|
379 |
Â
* Check each eu option to see if it's supprted
|
380 |
Â
*/
|
Â
|
|
381 |
Â
foreach ($options['eu_options']['value'] as $option) {
|
382 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
383 |
Â
continue;
|
392 |
Â
continue;
|
393 |
Â
}
|
394 |
Â
|
395 |
+
if ($flat === true) {
|
396 |
+
$availableOptions[$option['value']] = $option['label'];
|
397 |
+
continue;
|
398 |
+
}
|
399 |
+
|
400 |
Â
$availableEuOptions[] = $option;
|
401 |
Â
}
|
402 |
Â
|
403 |
Â
/**
|
404 |
+
* Check each global option to see if it's supprted
|
405 |
Â
*/
|
Â
|
|
406 |
Â
if ($helper->isGlobalAllowed()) {
|
407 |
Â
foreach ($options['global_options']['value'] as $option) {
|
408 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
418 |
Â
continue;
|
419 |
Â
}
|
420 |
Â
|
421 |
+
if ($flat === true) {
|
422 |
+
$availableOptions[$option['value']] = $option['label'];
|
423 |
+
continue;
|
424 |
+
}
|
425 |
+
|
426 |
Â
$availableGlobalOptions[] = $option;
|
427 |
Â
}
|
428 |
Â
}
|
429 |
Â
|
430 |
+
/**
|
431 |
+
* Check each pakketautomaat option to see if it's supprted
|
432 |
+
*/
|
433 |
+
$availablePakketautomaatOptions = array();
|
434 |
+
if ($helper->isGlobalAllowed()) {
|
435 |
+
foreach ($options['pakketautomaat']['value'] as $option) {
|
436 |
+
if (!in_array($option['value'], $supportedOptionsArray)) {
|
437 |
+
continue;
|
438 |
+
}
|
439 |
+
|
440 |
+
if (isset($option['isExtraCover']) && $withExtraCover !== true) {
|
441 |
+
continue;
|
442 |
+
}
|
443 |
+
|
444 |
+
if ($codesOnly === true) {
|
445 |
+
$availableOptions[] = $option['value'];
|
446 |
+
continue;
|
447 |
+
}
|
448 |
+
|
449 |
+
if ($flat === true) {
|
450 |
+
$availableOptions[$option['value']] = $option['label'];
|
451 |
+
continue;
|
452 |
+
}
|
453 |
+
|
454 |
+
$availablePakketautomaatOptions[] = $option;
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
Â
/**
|
459 |
Â
* If we only need the codes, we can return the $availableOptions array. Otherwise, we need to order and merge the
|
460 |
Â
* other arrays
|
461 |
Â
*/
|
462 |
+
if ($codesOnly === true || $flat === true) {
|
463 |
Â
return $availableOptions;
|
464 |
Â
}
|
465 |
Â
|
494 |
Â
);
|
495 |
Â
}
|
496 |
Â
|
497 |
+
if (!empty($availablePakketautomaatOptions)) {
|
498 |
+
$availableOptions['pakketautomaat_option'] = array(
|
499 |
+
'label' => $helper->__('Parcel Dispenser options'),
|
500 |
+
'value' => $availablePakketautomaatOptions,
|
501 |
+
);
|
502 |
+
}
|
503 |
+
|
504 |
+
if ($addDeliveryOptions) {
|
505 |
+
$availableOptions['avond_options'] = array(
|
506 |
+
'label' => $helper->__('Evening Delivery options'),
|
507 |
+
'value' => $availableAvondOptions,
|
508 |
+
);
|
509 |
+
|
510 |
+
$availableOptions['pge_options'] = array(
|
511 |
+
'label' => $helper->__('Early Pickup options'),
|
512 |
+
'value' => $availablePgeOptions,
|
513 |
+
);
|
514 |
+
}
|
515 |
+
|
516 |
Â
return $availableOptions;
|
517 |
Â
}
|
518 |
Â
|
519 |
Â
/**
|
520 |
Â
* Get the list of available product options that have extra cover
|
521 |
Â
*
|
522 |
+
* @param bool $valuesOnly
|
523 |
+
*
|
524 |
Â
* @return array
|
525 |
Â
*/
|
526 |
Â
public function getExtraCoverOptions($valuesOnly = false)
|
586 |
Â
/**
|
587 |
Â
* Mark each default option as default if it is present in the available options array
|
588 |
Â
*/
|
589 |
+
$defaultText = ' ' . $helper->__('(default)');
|
590 |
+
if (isset($options['standard_options']['value'][$defaultOptions['dutch']])) {
|
591 |
+
$options['standard_options']['value'][$defaultOptions['dutch']]['label'] .= $defaultText;
|
592 |
+
}
|
593 |
+
|
594 |
+
if (isset($options['pakjegemak_options']['value'][$defaultOptions['eu']])) {
|
595 |
+
$options['pakjegemak_options']['value'][$defaultOptions['pakjegemak']]['label'] .= $defaultText;
|
596 |
Â
}
|
597 |
Â
|
598 |
+
if (isset($options['eu_options']['value'][$defaultOptions['eu']])) {
|
599 |
+
$options['eu_options']['value'][$defaultOptions['eu']]['label'] .= $defaultText;
|
Â
|
|
Â
|
|
Â
|
|
600 |
Â
}
|
601 |
Â
|
602 |
+
if (isset($options['global_options']['value'][$defaultOptions['global']])) {
|
603 |
+
$options['global_options']['value'][$defaultOptions['global']]['label'] .= $defaultText;
|
Â
|
|
Â
|
|
Â
|
|
604 |
Â
}
|
605 |
Â
|
606 |
+
if (isset($options['pakketautomaat_options']['value'][$defaultOptions['pakketautomaat']])) {
|
607 |
+
$options['pakketautomaat_options']['value'][$defaultOptions['pakketautomaat']]['label'] .= $defaultText;
|
Â
|
|
Â
|
|
Â
|
|
608 |
Â
}
|
609 |
Â
|
610 |
Â
return $options;
|
@@ -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.
|
@@ -33,35 +33,39 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_Attributes
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Get an option array of all product attributes available
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
47 |
Â
{
|
48 |
Â
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
49 |
Â
->addFieldToFilter('frontend_label', array('notnull' => true));
|
50 |
-
|
51 |
Â
$attributes->getSelect()->order('frontend_label ASC');
|
52 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
53 |
Â
foreach ($attributes as $attribute) {
|
54 |
Â
$label = $attribute->getFrontendLabel();
|
55 |
Â
if (empty($label)) {
|
56 |
Â
continue;
|
57 |
Â
}
|
58 |
-
|
59 |
Â
$options[] = array(
|
60 |
Â
'label' => $label,
|
61 |
Â
'value' => $attribute->getAttributeCode()
|
62 |
Â
);
|
63 |
Â
}
|
64 |
-
|
65 |
Â
return $options;
|
66 |
Â
}
|
67 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_Attributes
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Get an option array of all product attributes available
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
47 |
Â
{
|
48 |
Â
$attributes = Mage::getResourceModel('catalog/product_attribute_collection')
|
49 |
Â
->addFieldToFilter('frontend_label', array('notnull' => true));
|
50 |
+
|
51 |
Â
$attributes->getSelect()->order('frontend_label ASC');
|
52 |
+
|
53 |
+
$options = array();
|
54 |
+
/**
|
55 |
+
* @var Mage_Catalog_Model_Entity_Attribute $attribute
|
56 |
+
*/
|
57 |
Â
foreach ($attributes as $attribute) {
|
58 |
Â
$label = $attribute->getFrontendLabel();
|
59 |
Â
if (empty($label)) {
|
60 |
Â
continue;
|
61 |
Â
}
|
62 |
+
|
63 |
Â
$options[] = array(
|
64 |
Â
'label' => $label,
|
65 |
Â
'value' => $attribute->getAttributeCode()
|
66 |
Â
);
|
67 |
Â
}
|
68 |
+
|
69 |
Â
return $options;
|
70 |
Â
}
|
71 |
Â
}
|
@@ -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,7 +40,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_DebugMode
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for debug mode options
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -60,7 +60,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_DebugMode
|
|
60 |
Â
'label' => $helper->__('Full'),
|
61 |
Â
),
|
62 |
Â
);
|
63 |
-
|
64 |
Â
return $options;
|
65 |
Â
}
|
66 |
Â
}
|
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 |
Â
* Returns an option array for debug mode options
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
60 |
Â
'label' => $helper->__('Full'),
|
61 |
Â
),
|
62 |
Â
);
|
63 |
+
|
64 |
Â
return $options;
|
65 |
Â
}
|
66 |
Â
}
|
@@ -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,7 +40,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_Direction
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for sorting direction options
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -56,7 +56,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_Direction
|
|
56 |
Â
'label' => $helper->__('Descending'),
|
57 |
Â
),
|
58 |
Â
);
|
59 |
-
|
60 |
Â
return $options;
|
61 |
Â
}
|
62 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for sorting direction options
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
56 |
Â
'label' => $helper->__('Descending'),
|
57 |
Â
),
|
58 |
Â
);
|
59 |
+
|
60 |
Â
return $options;
|
61 |
Â
}
|
62 |
Â
}
|
@@ -132,6 +132,10 @@ class TIG_PostNL_Model_Core_System_Config_Source_EuProductOptions
|
|
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;
|
137 |
Â
}
|
132 |
Â
* Check each standard option to see if it's supprted
|
133 |
Â
*/
|
134 |
Â
foreach ($options as $option) {
|
135 |
+
if (!array_key_exists('value', $option)) {
|
136 |
+
continue;
|
137 |
+
}
|
138 |
+
|
139 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
140 |
Â
continue;
|
141 |
Â
}
|
@@ -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.
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
@@ -42,10 +42,10 @@ class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
|
42 |
Â
* XML path to supported options configuration setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
-
*
|
49 |
Â
* @return array
|
50 |
Â
*/
|
51 |
Â
public function toOptionArray()
|
@@ -58,16 +58,16 @@ class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
|
58 |
Â
'isExtraCover' => true,
|
59 |
Â
),
|
60 |
Â
);
|
61 |
-
|
62 |
Â
return $availableOptions;
|
63 |
Â
}
|
64 |
-
|
65 |
Â
/**
|
66 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
67 |
-
*
|
68 |
Â
* @param boolean|int $storeId
|
69 |
Â
* @param boolean $codesOnly
|
70 |
-
*
|
71 |
Â
* @return array
|
72 |
Â
*/
|
73 |
Â
public function getAvailableOptions($storeId = false, $codesOnly = false)
|
@@ -75,38 +75,40 @@ class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
|
75 |
Â
if ($storeId === false) {
|
76 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
77 |
Â
}
|
78 |
-
|
79 |
-
$helper = Mage::helper('postnl');
|
80 |
Â
$options = $this->toOptionArray();
|
81 |
-
|
82 |
Â
/**
|
83 |
Â
* Get a list of all possible options
|
84 |
Â
*/
|
85 |
Â
$availableOptions = array();
|
86 |
-
|
87 |
Â
/**
|
88 |
Â
* Get the list of supported product options from the shop's configuration
|
89 |
Â
*/
|
90 |
Â
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
91 |
Â
$supportedOptionsArray = explode(',', $supportedOptions);
|
92 |
-
|
93 |
Â
/**
|
94 |
Â
* Check each standard option to see if it's supprted
|
95 |
Â
*/
|
96 |
-
$availableStandardOptions = array();
|
97 |
Â
foreach ($options as $option) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
98 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
99 |
Â
continue;
|
100 |
Â
}
|
101 |
-
|
102 |
Â
if ($codesOnly === true) {
|
103 |
Â
$availableOptions[] = $option['value'];
|
104 |
Â
continue;
|
105 |
Â
}
|
106 |
-
|
107 |
Â
$availableOptions[] = $option;
|
108 |
Â
}
|
109 |
-
|
110 |
Â
return $availableOptions;
|
111 |
Â
}
|
112 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_GlobalProductOptions
|
42 |
Â
* XML path to supported options configuration setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
+
*
|
49 |
Â
* @return array
|
50 |
Â
*/
|
51 |
Â
public function toOptionArray()
|
58 |
Â
'isExtraCover' => true,
|
59 |
Â
),
|
60 |
Â
);
|
61 |
+
|
62 |
Â
return $availableOptions;
|
63 |
Â
}
|
64 |
+
|
65 |
Â
/**
|
66 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
67 |
+
*
|
68 |
Â
* @param boolean|int $storeId
|
69 |
Â
* @param boolean $codesOnly
|
70 |
+
*
|
71 |
Â
* @return array
|
72 |
Â
*/
|
73 |
Â
public function getAvailableOptions($storeId = false, $codesOnly = false)
|
75 |
Â
if ($storeId === false) {
|
76 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
77 |
Â
}
|
78 |
+
|
Â
|
|
79 |
Â
$options = $this->toOptionArray();
|
80 |
+
|
81 |
Â
/**
|
82 |
Â
* Get a list of all possible options
|
83 |
Â
*/
|
84 |
Â
$availableOptions = array();
|
85 |
+
|
86 |
Â
/**
|
87 |
Â
* Get the list of supported product options from the shop's configuration
|
88 |
Â
*/
|
89 |
Â
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
90 |
Â
$supportedOptionsArray = explode(',', $supportedOptions);
|
91 |
+
|
92 |
Â
/**
|
93 |
Â
* Check each standard option to see if it's supprted
|
94 |
Â
*/
|
Â
|
|
95 |
Â
foreach ($options as $option) {
|
96 |
+
if (!array_key_exists('value', $option)) {
|
97 |
+
continue;
|
98 |
+
}
|
99 |
+
|
100 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
101 |
Â
continue;
|
102 |
Â
}
|
103 |
+
|
104 |
Â
if ($codesOnly === true) {
|
105 |
Â
$availableOptions[] = $option['value'];
|
106 |
Â
continue;
|
107 |
Â
}
|
108 |
+
|
109 |
Â
$availableOptions[] = $option;
|
110 |
Â
}
|
111 |
+
|
112 |
Â
return $availableOptions;
|
113 |
Â
}
|
114 |
Â
}
|
@@ -0,0 +1,74 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Model_Core_System_Config_Source_GlobalpackShipmentType
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* Returns an option array for possible GlobalPack shipment types.
|
43 |
+
*
|
44 |
+
* @return array
|
45 |
+
*/
|
46 |
+
public function toOptionArray()
|
47 |
+
{
|
48 |
+
$helper = Mage::helper('postnl');
|
49 |
+
$options = array(
|
50 |
+
array(
|
51 |
+
'value' => 'Gift',
|
52 |
+
'label' => $helper->__('Gift'),
|
53 |
+
),
|
54 |
+
array(
|
55 |
+
'value' => 'Documents',
|
56 |
+
'label' => $helper->__('Documents'),
|
57 |
+
),
|
58 |
+
array(
|
59 |
+
'value' => 'Commercial Goods',
|
60 |
+
'label' => $helper->__('Commercial Goods'),
|
61 |
+
),
|
62 |
+
array(
|
63 |
+
'value' => 'Commercial Sample',
|
64 |
+
'label' => $helper->__('Commercial Sample'),
|
65 |
+
),
|
66 |
+
array(
|
67 |
+
'value' => 'Returned Goods',
|
68 |
+
'label' => $helper->__('Returned Goods'),
|
69 |
+
),
|
70 |
+
);
|
71 |
+
|
72 |
+
return $options;
|
73 |
+
}
|
74 |
+
}
|
@@ -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,7 +40,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_LabelSize
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for all supported label sizes
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -56,7 +56,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_LabelSize
|
|
56 |
Â
'label' => $helper->__('A6')
|
57 |
Â
),
|
58 |
Â
);
|
59 |
-
|
60 |
Â
return $labelSizes;
|
61 |
Â
}
|
62 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for all supported label sizes
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
56 |
Â
'label' => $helper->__('A6')
|
57 |
Â
),
|
58 |
Â
);
|
59 |
+
|
60 |
Â
return $labelSizes;
|
61 |
Â
}
|
62 |
Â
}
|
@@ -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.
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
@@ -42,12 +42,12 @@ class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
|
42 |
Â
* XML path to supported options configuration setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
-
*
|
49 |
Â
* @return array
|
50 |
-
*
|
51 |
Â
* @todo implement COD
|
52 |
Â
*/
|
53 |
Â
public function toOptionArray()
|
@@ -56,24 +56,26 @@ class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
|
56 |
Â
$availableOptions = array(
|
57 |
Â
/**
|
58 |
Â
* These are not currently implemented
|
59 |
-
*
|
60 |
-
*
|
61 |
Â
*/
|
62 |
Â
/*array(
|
63 |
Â
'value' => '3535',
|
64 |
-
'label' => $helper->__('Post Office + COD')
|
65 |
Â
),
|
66 |
Â
array(
|
67 |
Â
'value' => '3545',
|
68 |
-
'label' => $helper->__('Post Office + COD + Notification')
|
Â
|
|
69 |
Â
),
|
70 |
Â
array(
|
71 |
Â
'value' => '3536',
|
72 |
-
'label' => $helper->__('Post Office + COD + Extra Cover')
|
73 |
Â
),
|
74 |
Â
array(
|
75 |
Â
'value' => '3546',
|
76 |
-
'label' => $helper->__('Post Office + COD + Extra Cover + Notification')
|
Â
|
|
77 |
Â
),*/
|
78 |
Â
array(
|
79 |
Â
'value' => '3534',
|
@@ -84,6 +86,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
|
84 |
Â
'value' => '3544',
|
85 |
Â
'label' => $helper->__('Post Office + Extra Cover + Notification'),
|
86 |
Â
'isExtraCover' => true,
|
Â
|
|
87 |
Â
),
|
88 |
Â
array(
|
89 |
Â
'value' => '3533',
|
@@ -91,58 +94,106 @@ class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
|
91 |
Â
),
|
92 |
Â
array(
|
93 |
Â
'value' => '3543',
|
94 |
-
'label' => $helper->__('Post Office + Signature on Delivery + Notification')
|
Â
|
|
95 |
Â
),
|
96 |
Â
);
|
97 |
-
|
98 |
Â
return $availableOptions;
|
99 |
Â
}
|
100 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
101 |
Â
/**
|
102 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
103 |
-
*
|
104 |
Â
* @param boolean|int $storeId
|
105 |
-
* @param boolean
|
106 |
-
*
|
Â
|
|
107 |
Â
* @return array
|
108 |
Â
*/
|
109 |
-
public function getAvailableOptions($storeId = false, $codesOnly = false)
|
110 |
Â
{
|
111 |
Â
if ($storeId === false) {
|
112 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
113 |
Â
}
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
Â
|
|
Â
|
|
Â
|
|
118 |
Â
/**
|
119 |
Â
* Get a list of all possible options
|
120 |
Â
*/
|
121 |
Â
$availableOptions = array();
|
122 |
-
|
123 |
Â
/**
|
124 |
Â
* Get the list of supported product options from the shop's configuration
|
125 |
Â
*/
|
126 |
Â
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
127 |
Â
$supportedOptionsArray = explode(',', $supportedOptions);
|
128 |
-
|
129 |
Â
/**
|
130 |
Â
* Check each standard option to see if it's supprted
|
131 |
Â
*/
|
132 |
-
$availableStandardOptions = array();
|
133 |
Â
foreach ($options as $option) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
134 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
135 |
Â
continue;
|
136 |
Â
}
|
137 |
-
|
138 |
Â
if ($codesOnly === true) {
|
139 |
Â
$availableOptions[] = $option['value'];
|
140 |
Â
continue;
|
141 |
Â
}
|
142 |
-
|
143 |
Â
$availableOptions[] = $option;
|
144 |
Â
}
|
145 |
-
|
146 |
Â
return $availableOptions;
|
147 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
148 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_PakjeGemakProductOptions
|
42 |
Â
* XML path to supported options configuration setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
+
*
|
49 |
Â
* @return array
|
50 |
+
*
|
51 |
Â
* @todo implement COD
|
52 |
Â
*/
|
53 |
Â
public function toOptionArray()
|
56 |
Â
$availableOptions = array(
|
57 |
Â
/**
|
58 |
Â
* These are not currently implemented
|
59 |
+
*
|
60 |
+
* @todo implement these options
|
61 |
Â
*/
|
62 |
Â
/*array(
|
63 |
Â
'value' => '3535',
|
64 |
+
'label' => $helper->__('Post Office + COD'),
|
65 |
Â
),
|
66 |
Â
array(
|
67 |
Â
'value' => '3545',
|
68 |
+
'label' => $helper->__('Post Office + COD + Notification'),
|
69 |
+
'isPge' => true,
|
70 |
Â
),
|
71 |
Â
array(
|
72 |
Â
'value' => '3536',
|
73 |
+
'label' => $helper->__('Post Office + COD + Extra Cover'),
|
74 |
Â
),
|
75 |
Â
array(
|
76 |
Â
'value' => '3546',
|
77 |
+
'label' => $helper->__('Post Office + COD + Extra Cover + Notification'),
|
78 |
+
'isPge' => true,
|
79 |
Â
),*/
|
80 |
Â
array(
|
81 |
Â
'value' => '3534',
|
86 |
Â
'value' => '3544',
|
87 |
Â
'label' => $helper->__('Post Office + Extra Cover + Notification'),
|
88 |
Â
'isExtraCover' => true,
|
89 |
+
'isPge' => true,
|
90 |
Â
),
|
91 |
Â
array(
|
92 |
Â
'value' => '3533',
|
94 |
Â
),
|
95 |
Â
array(
|
96 |
Â
'value' => '3543',
|
97 |
+
'label' => $helper->__('Post Office + Signature on Delivery + Notification'),
|
98 |
+
'isPge' => true,
|
99 |
Â
),
|
100 |
Â
);
|
101 |
+
|
102 |
Â
return $availableOptions;
|
103 |
Â
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Gets an array of possible PGE product options.
|
107 |
+
*
|
108 |
+
* @param boolean $asFlatArray
|
109 |
+
*
|
110 |
+
* @return array
|
111 |
+
*/
|
112 |
+
public function getPgeOptions($asFlatArray = false)
|
113 |
+
{
|
114 |
+
$options = $this->toOptionArray();
|
115 |
+
|
116 |
+
$pgeOptions = array();
|
117 |
+
foreach ($options as $option) {
|
118 |
+
if (!isset($option['isPge']) || !$option['isPge']) {
|
119 |
+
continue;
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($asFlatArray) {
|
123 |
+
$pgeOptions[] = $option;
|
124 |
+
}
|
125 |
+
|
126 |
+
$pgeOptions[$option['value']] = $option['label'];
|
127 |
+
}
|
128 |
+
|
129 |
+
return $pgeOptions;
|
130 |
+
}
|
131 |
+
|
132 |
Â
/**
|
133 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
134 |
+
*
|
135 |
Â
* @param boolean|int $storeId
|
136 |
+
* @param boolean $codesOnly
|
137 |
+
* @param boolean $isPge
|
138 |
+
*
|
139 |
Â
* @return array
|
140 |
Â
*/
|
141 |
+
public function getAvailableOptions($storeId = false, $codesOnly = false, $isPge = false)
|
142 |
Â
{
|
143 |
Â
if ($storeId === false) {
|
144 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
145 |
Â
}
|
146 |
+
|
147 |
+
if (!$isPge) {
|
148 |
+
$options = $this->toOptionArray();
|
149 |
+
} else {
|
150 |
+
$options = $this->getPgeOptions(true);
|
151 |
+
}
|
152 |
+
|
153 |
Â
/**
|
154 |
Â
* Get a list of all possible options
|
155 |
Â
*/
|
156 |
Â
$availableOptions = array();
|
157 |
+
|
158 |
Â
/**
|
159 |
Â
* Get the list of supported product options from the shop's configuration
|
160 |
Â
*/
|
161 |
Â
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
162 |
Â
$supportedOptionsArray = explode(',', $supportedOptions);
|
163 |
+
|
164 |
Â
/**
|
165 |
Â
* Check each standard option to see if it's supprted
|
166 |
Â
*/
|
Â
|
|
167 |
Â
foreach ($options as $option) {
|
168 |
+
if (!is_array($option) || !array_key_exists('value', $option)) {
|
169 |
+
continue;
|
170 |
+
}
|
171 |
+
|
172 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
173 |
Â
continue;
|
174 |
Â
}
|
175 |
+
|
176 |
Â
if ($codesOnly === true) {
|
177 |
Â
$availableOptions[] = $option['value'];
|
178 |
Â
continue;
|
179 |
Â
}
|
180 |
+
|
181 |
Â
$availableOptions[] = $option;
|
182 |
Â
}
|
183 |
+
|
184 |
Â
return $availableOptions;
|
185 |
Â
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Alias for getAvailableOptions() with $isPge === true.
|
189 |
+
*
|
190 |
+
* @param bool $storeId
|
191 |
+
* @param bool $codesOnly
|
192 |
+
*
|
193 |
+
* @return array
|
194 |
+
*/
|
195 |
+
public function getAvailablePgeOptions($storeId = false, $codesOnly = false)
|
196 |
+
{
|
197 |
+
return $this->getAvailableOptions($storeId, $codesOnly, true);
|
198 |
+
}
|
199 |
Â
}
|
@@ -0,0 +1,113 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
class TIG_PostNL_Model_Core_System_Config_Source_PakketautomaatProductOptions
|
40 |
+
{
|
41 |
+
/**
|
42 |
+
* XML path to supported options configuration setting
|
43 |
+
*/
|
44 |
+
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Returns an option array for all possible PostNL product options
|
48 |
+
*
|
49 |
+
* @return array
|
50 |
+
*/
|
51 |
+
public function toOptionArray()
|
52 |
+
{
|
53 |
+
$helper = Mage::helper('postnl');
|
54 |
+
$availableOptions = array(
|
55 |
+
array(
|
56 |
+
'value' => '3553',
|
57 |
+
'label' => $helper->__('Parcel Dispenser'),
|
58 |
+
),
|
59 |
+
);
|
60 |
+
|
61 |
+
return $availableOptions;
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
66 |
+
*
|
67 |
+
* @param boolean|int $storeId
|
68 |
+
* @param boolean $codesOnly
|
69 |
+
*
|
70 |
+
* @return array
|
71 |
+
*/
|
72 |
+
public function getAvailableOptions($storeId = false, $codesOnly = false)
|
73 |
+
{
|
74 |
+
if ($storeId === false) {
|
75 |
+
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
76 |
+
}
|
77 |
+
|
78 |
+
$options = $this->toOptionArray();
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Get a list of all possible options
|
82 |
+
*/
|
83 |
+
$availableOptions = array();
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Get the list of supported product options from the shop's configuration
|
87 |
+
*/
|
88 |
+
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
89 |
+
$supportedOptionsArray = explode(',', $supportedOptions);
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Check each standard option to see if it's supprted
|
93 |
+
*/
|
94 |
+
foreach ($options as $option) {
|
95 |
+
if (!array_key_exists('value', $option)) {
|
96 |
+
continue;
|
97 |
+
}
|
98 |
+
|
99 |
+
if (!in_array($option['value'], $supportedOptionsArray)) {
|
100 |
+
continue;
|
101 |
+
}
|
102 |
+
|
103 |
+
if ($codesOnly === true) {
|
104 |
+
$availableOptions[] = $option['value'];
|
105 |
+
continue;
|
106 |
+
}
|
107 |
+
|
108 |
+
$availableOptions[] = $option;
|
109 |
+
}
|
110 |
+
|
111 |
+
return $availableOptions;
|
112 |
+
}
|
113 |
+
}
|
@@ -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,7 +40,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_ReferenceType
|
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for possible shipment references
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
@@ -64,7 +64,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_ReferenceType
|
|
64 |
Â
'label' => $helper->__('Use a custom value'),
|
65 |
Â
),
|
66 |
Â
);
|
67 |
-
|
68 |
Â
return $options;
|
69 |
Â
}
|
70 |
Â
}
|
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 |
Â
* Returns an option array for possible shipment references
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
Â
*/
|
46 |
Â
public function toOptionArray()
|
64 |
Â
'label' => $helper->__('Use a custom value'),
|
65 |
Â
),
|
66 |
Â
);
|
67 |
+
|
68 |
Â
return $options;
|
69 |
Â
}
|
70 |
Â
}
|
@@ -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.
|
@@ -33,7 +33,7 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
@@ -42,12 +42,12 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
42 |
Â
* XML path to supported options configuration setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
-
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
-
*
|
49 |
Â
* @return array
|
50 |
-
*
|
51 |
Â
* @todo implement COD
|
52 |
Â
*/
|
53 |
Â
public function toOptionArray()
|
@@ -60,113 +60,172 @@ class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
|
60 |
Â
),
|
61 |
Â
/**
|
62 |
Â
* These are not currently implemented
|
63 |
-
*
|
64 |
-
*
|
65 |
Â
*/
|
66 |
Â
/*array(
|
67 |
-
'value'
|
68 |
-
'label'
|
Â
|
|
69 |
Â
),
|
70 |
Â
array(
|
71 |
-
'value'
|
72 |
-
'label'
|
Â
|
|
73 |
Â
),
|
74 |
Â
array(
|
75 |
-
'value'
|
76 |
-
'label'
|
Â
|
|
77 |
Â
),
|
78 |
Â
array(
|
79 |
-
'value'
|
80 |
-
'label'
|
Â
|
|
81 |
Â
),*/
|
82 |
Â
array(
|
83 |
Â
'value' => '3087',
|
84 |
Â
'label' => $helper->__('Extra Cover'),
|
85 |
Â
'isExtraCover' => true,
|
Â
|
|
86 |
Â
),
|
87 |
Â
array(
|
88 |
Â
'value' => '3094',
|
89 |
Â
'label' => $helper->__('Extra cover + Return when not home'),
|
90 |
Â
'isExtraCover' => true,
|
Â
|
|
91 |
Â
),
|
92 |
Â
array(
|
93 |
Â
'value' => '3189',
|
94 |
Â
'label' => $helper->__('Signature on delivery'),
|
95 |
Â
),
|
96 |
Â
array(
|
97 |
-
'value'
|
98 |
-
'label'
|
Â
|
|
99 |
Â
),
|
100 |
Â
array(
|
101 |
Â
'value' => '3389',
|
102 |
Â
'label' => $helper->__('Signature on delivery + Return when not home'),
|
103 |
Â
),
|
104 |
Â
array(
|
105 |
-
'value'
|
106 |
-
'label'
|
Â
|
|
Â
|
|
Â
|
|
107 |
Â
),
|
108 |
Â
array(
|
109 |
Â
'value' => '3090',
|
110 |
Â
'label' => $helper->__('Delivery to neighbour + Return when not home'),
|
111 |
Â
),
|
112 |
Â
array(
|
113 |
-
'value'
|
114 |
-
'label'
|
Â
|
|
115 |
Â
),
|
116 |
Â
array(
|
117 |
-
'value'
|
118 |
-
'label'
|
Â
|
|
119 |
Â
),
|
120 |
Â
);
|
121 |
-
|
122 |
Â
return $availableOptions;
|
123 |
Â
}
|
124 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
125 |
Â
/**
|
126 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
127 |
-
*
|
128 |
Â
* @param boolean|int $storeId
|
129 |
-
* @param boolean
|
130 |
-
*
|
Â
|
|
131 |
Â
* @return array
|
132 |
Â
*/
|
133 |
-
public function getAvailableOptions($storeId = false, $codesOnly = false)
|
134 |
Â
{
|
135 |
Â
if ($storeId === false) {
|
136 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
137 |
Â
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
Â
|
|
Â
|
|
Â
|
|
142 |
Â
/**
|
143 |
Â
* Get a list of all possible options
|
144 |
Â
*/
|
145 |
Â
$availableOptions = array();
|
146 |
-
|
147 |
Â
/**
|
148 |
Â
* Get the list of supported product options from the shop's configuration
|
149 |
Â
*/
|
150 |
Â
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
151 |
Â
$supportedOptionsArray = explode(',', $supportedOptions);
|
152 |
-
|
153 |
Â
/**
|
154 |
Â
* Check each standard option to see if it's supprted
|
155 |
Â
*/
|
156 |
-
$availableStandardOptions = array();
|
157 |
Â
foreach ($options as $option) {
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
158 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
159 |
Â
continue;
|
160 |
Â
}
|
161 |
-
|
162 |
Â
if ($codesOnly === true) {
|
163 |
Â
$availableOptions[] = $option['value'];
|
164 |
Â
continue;
|
165 |
Â
}
|
166 |
-
|
167 |
Â
$availableOptions[] = $option;
|
168 |
Â
}
|
169 |
-
|
170 |
Â
return $availableOptions;
|
171 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
172 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
/**
|
3 |
+
* ___________ __ __
|
4 |
+
* \__ ___/____ _/ |_ _____ | |
|
5 |
Â
* | | / _ \\ __\\__ \ | |
|
6 |
Â
* | | | |_| || | / __ \_| |__
|
7 |
Â
* |____| \____/ |__| (____ /|____/
|
8 |
+
* \/
|
9 |
+
* ___ __ __
|
10 |
+
* | | ____ _/ |_ ____ _______ ____ ____ _/ |_
|
11 |
Â
* | | / \\ __\_/ __ \\_ __ \ / \ _/ __ \\ __\
|
12 |
+
* | || | \| | \ ___/ | | \/| | \\ ___/ | |
|
13 |
+
* |___||___| /|__| \_____>|__| |___| / \_____>|__|
|
14 |
+
* \/ \/
|
15 |
+
* ________
|
16 |
+
* / _____/_______ ____ __ __ ______
|
17 |
+
* / \ ___\_ __ \ / _ \ | | \\____ \
|
18 |
Â
* \ \_\ \| | \/| |_| || | /| |_| |
|
19 |
+
* \______ /|__| \____/ |____/ | __/
|
20 |
+
* \/ |__|
|
21 |
Â
*
|
22 |
Â
* NOTICE OF LICENSE
|
23 |
Â
*
|
24 |
Â
* This source file is subject to the Creative Commons License.
|
25 |
+
* It is available through the world-wide-web at this URL:
|
26 |
Â
* http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
27 |
Â
* If you are unable to obtain it through the world-wide-web, please send an email
|
28 |
Â
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
|
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 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_StandardProductOptions
|
42 |
Â
* XML path to supported options configuration setting
|
43 |
Â
*/
|
44 |
Â
const XML_PATH_SUPPORTED_PRODUCT_OPTIONS = 'postnl/cif_product_options/supported_product_options';
|
45 |
+
|
46 |
Â
/**
|
47 |
Â
* Returns an option array for all possible PostNL product options
|
48 |
+
*
|
49 |
Â
* @return array
|
50 |
+
*
|
51 |
Â
* @todo implement COD
|
52 |
Â
*/
|
53 |
Â
public function toOptionArray()
|
60 |
Â
),
|
61 |
Â
/**
|
62 |
Â
* These are not currently implemented
|
63 |
+
*
|
64 |
+
* @todo implement these options
|
65 |
Â
*/
|
66 |
Â
/*array(
|
67 |
+
'value' => '3086',
|
68 |
+
'label' => $helper->__('COD'),
|
69 |
+
'isAvond' => true,
|
70 |
Â
),
|
71 |
Â
array(
|
72 |
+
'value' => '3091',
|
73 |
+
'label' => $helper->__('COD + Extra cover'),
|
74 |
+
'isAvond' => true,
|
75 |
Â
),
|
76 |
Â
array(
|
77 |
+
'value' => '3093',
|
78 |
+
'label' => $helper->__('COD + Return when not home'),
|
79 |
+
'isAvond' => true,
|
80 |
Â
),
|
81 |
Â
array(
|
82 |
+
'value' => '3097',
|
83 |
+
'label' => $helper->__('COD + Extra cover + Return when not home'),
|
84 |
+
'isAvond' => true,
|
85 |
Â
),*/
|
86 |
Â
array(
|
87 |
Â
'value' => '3087',
|
88 |
Â
'label' => $helper->__('Extra Cover'),
|
89 |
Â
'isExtraCover' => true,
|
90 |
+
'isAvond' => true,
|
91 |
Â
),
|
92 |
Â
array(
|
93 |
Â
'value' => '3094',
|
94 |
Â
'label' => $helper->__('Extra cover + Return when not home'),
|
95 |
Â
'isExtraCover' => true,
|
96 |
+
'isAvond' => true,
|
97 |
Â
),
|
98 |
Â
array(
|
99 |
Â
'value' => '3189',
|
100 |
Â
'label' => $helper->__('Signature on delivery'),
|
101 |
Â
),
|
102 |
Â
array(
|
103 |
+
'value' => '3089',
|
104 |
+
'label' => $helper->__('Signature on delivery + Delivery to stated address only'),
|
105 |
+
'isAvond' => true,
|
106 |
Â
),
|
107 |
Â
array(
|
108 |
Â
'value' => '3389',
|
109 |
Â
'label' => $helper->__('Signature on delivery + Return when not home'),
|
110 |
Â
),
|
111 |
Â
array(
|
112 |
+
'value' => '3096',
|
113 |
+
'label' => $helper->__(
|
114 |
+
'Signature on delivery + Deliver to stated address only + Return when not home'
|
115 |
+
),
|
116 |
+
'isAvond' => true,
|
117 |
Â
),
|
118 |
Â
array(
|
119 |
Â
'value' => '3090',
|
120 |
Â
'label' => $helper->__('Delivery to neighbour + Return when not home'),
|
121 |
Â
),
|
122 |
Â
array(
|
123 |
+
'value' => '3385',
|
124 |
+
'label' => $helper->__('Deliver to stated address only'),
|
125 |
+
'isAvond' => true,
|
126 |
Â
),
|
127 |
Â
array(
|
128 |
+
'value' => '3390',
|
129 |
+
'label' => $helper->__('Deliver to stated address only + Return when not home'),
|
130 |
+
'isAvond' => true,
|
131 |
Â
),
|
132 |
Â
);
|
133 |
+
|
134 |
Â
return $availableOptions;
|
135 |
Â
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Gets an array of possible evening delivery product options.
|
139 |
+
*
|
140 |
+
* @param boolean $asFlatArray
|
141 |
+
*
|
142 |
+
* @return array
|
143 |
+
*/
|
144 |
+
public function getAvondOptions($asFlatArray = false)
|
145 |
+
{
|
146 |
+
$options = $this->toOptionArray();
|
147 |
+
|
148 |
+
$avondOptions = array();
|
149 |
+
foreach ($options as $option) {
|
150 |
+
if (!isset($option['isAvond']) || !$option['isAvond']) {
|
151 |
+
continue;
|
152 |
+
}
|
153 |
+
|
154 |
+
if ($asFlatArray) {
|
155 |
+
$avondOptions[] = $option;
|
156 |
+
}
|
157 |
+
|
158 |
+
$avondOptions[$option['value']] = $option['label'];
|
159 |
+
}
|
160 |
+
|
161 |
+
return $avondOptions;
|
162 |
+
}
|
163 |
+
|
164 |
Â
/**
|
165 |
Â
* Get a list of available options. This is a filtered/modified version of the array supplied by toOptionArray();
|
166 |
+
*
|
167 |
Â
* @param boolean|int $storeId
|
168 |
+
* @param boolean $codesOnly
|
169 |
+
* @param boolean $isAvond
|
170 |
+
*
|
171 |
Â
* @return array
|
172 |
Â
*/
|
173 |
+
public function getAvailableOptions($storeId = false, $codesOnly = false, $isAvond = false)
|
174 |
Â
{
|
175 |
Â
if ($storeId === false) {
|
176 |
Â
$storeId = Mage_Core_Model_App::ADMIN_STORE_ID;
|
177 |
Â
}
|
178 |
+
|
179 |
+
if (!$isAvond) {
|
180 |
+
$options = $this->toOptionArray();
|
181 |
+
} else {
|
182 |
+
$options = $this->getAvondOptions(true);
|
183 |
+
}
|
184 |
+
|
185 |
Â
/**
|
186 |
Â
* Get a list of all possible options
|
187 |
Â
*/
|
188 |
Â
$availableOptions = array();
|
189 |
+
|
190 |
Â
/**
|
191 |
Â
* Get the list of supported product options from the shop's configuration
|
192 |
Â
*/
|
193 |
Â
$supportedOptions = Mage::getStoreConfig(self::XML_PATH_SUPPORTED_PRODUCT_OPTIONS, $storeId);
|
194 |
Â
$supportedOptionsArray = explode(',', $supportedOptions);
|
195 |
+
|
196 |
Â
/**
|
197 |
Â
* Check each standard option to see if it's supprted
|
198 |
Â
*/
|
Â
|
|
199 |
Â
foreach ($options as $option) {
|
200 |
+
if (!is_array($option) || !array_key_exists('value', $option)) {
|
201 |
+
continue;
|
202 |
+
}
|
203 |
+
|
204 |
Â
if (!in_array($option['value'], $supportedOptionsArray)) {
|
205 |
Â
continue;
|
206 |
Â
}
|
207 |
+
|
208 |
Â
if ($codesOnly === true) {
|
209 |
Â
$availableOptions[] = $option['value'];
|
210 |
Â
continue;
|
211 |
Â
}
|
212 |
+
|
213 |
Â
$availableOptions[] = $option;
|
214 |
Â
}
|
215 |
+
|
216 |
Â
return $availableOptions;
|
217 |
Â
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Alias for getAvailableOptions() with $isAvond === true.
|
221 |
+
*
|
222 |
+
* @param bool $storeId
|
223 |
+
* @param bool $codesOnly
|
224 |
+
*
|
225 |
+
* @return array
|
226 |
+
*/
|
227 |
+
public function getAvailableAvondOptions($storeId = false, $codesOnly = false)
|
228 |
+
{
|
229 |
+
return $this->getAvailableOptions($storeId, $codesOnly, true);
|
230 |
+
}
|
231 |
Â
}
|
@@ -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,15 +43,15 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
43 |
Â
* XML path to community edition address lines configuration option
|
44 |
Â
*/
|
45 |
Â
const XML_PATH_COMMUNITY_STREET_LINES = 'customer/address/street_lines';
|
46 |
-
|
47 |
Â
/**
|
48 |
Â
* @var null|array The resulting product option array
|
49 |
Â
*/
|
50 |
Â
protected $_options = null;
|
51 |
-
|
52 |
Â
/**
|
53 |
Â
* Source model for street line settings
|
54 |
-
*
|
55 |
Â
* @return array
|
56 |
Â
*/
|
57 |
Â
public function toOptionArray()
|
@@ -59,30 +59,30 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
59 |
Â
if ($this->_options !== null) {
|
60 |
Â
return $this->_options;
|
61 |
Â
}
|
62 |
-
|
63 |
Â
if (Mage::helper('postnl')->isEnterprise()) {
|
64 |
Â
$array = $this->_getEnterpriseOptions();
|
65 |
-
|
66 |
Â
$this->_options = $array;
|
67 |
Â
return $array;
|
68 |
Â
}
|
69 |
-
|
70 |
Â
$array = $this->_getCommunityOptions();
|
71 |
-
|
72 |
Â
$this->_options = $array;
|
73 |
Â
return $array;
|
74 |
Â
}
|
75 |
-
|
76 |
Â
/**
|
77 |
Â
* Gets options for community edition shops
|
78 |
-
*
|
79 |
Â
* @return array
|
80 |
Â
*/
|
81 |
Â
protected function _getCommunityOptions()
|
82 |
Â
{
|
83 |
Â
$request = Mage::app()->getRequest();
|
84 |
Â
$helper = Mage::helper('postnl');
|
85 |
-
|
86 |
Â
/**
|
87 |
Â
* Get the allowed number of address lines based on the current scope
|
88 |
Â
*/
|
@@ -94,7 +94,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
94 |
Â
} else {
|
95 |
Â
$lineCount = Mage::getStoreConfig(self::XML_PATH_COMMUNITY_STREET_LINES, Mage_Core_Model_App::ADMIN_STORE_ID);
|
96 |
Â
}
|
97 |
-
|
98 |
Â
/**
|
99 |
Â
* Build the option array
|
100 |
Â
*/
|
@@ -105,20 +105,20 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
105 |
Â
'label' => $helper->__('Street line #%s', $n),
|
106 |
Â
);
|
107 |
Â
}
|
108 |
-
|
109 |
Â
return $array;
|
110 |
Â
}
|
111 |
-
|
112 |
Â
/**
|
113 |
Â
* Gets options for enterprise edition shops
|
114 |
-
*
|
115 |
Â
* @return array
|
116 |
Â
*/
|
117 |
Â
protected function _getEnterpriseOptions()
|
118 |
Â
{
|
119 |
Â
$helper = Mage::helper('postnl');
|
120 |
Â
$lineCount = Mage::helper('customer/address')->getStreetLines();
|
121 |
-
|
122 |
Â
/**
|
123 |
Â
* Build the option array
|
124 |
Â
*/
|
@@ -129,7 +129,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetField
|
|
129 |
Â
'label' => $helper->__('Street line #%s', $n),
|
130 |
Â
);
|
131 |
Â
}
|
132 |
-
|
133 |
Â
return $array;
|
134 |
Â
}
|
135 |
Â
}
|
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 |
Â
* XML path to community edition address lines configuration option
|
44 |
Â
*/
|
45 |
Â
const XML_PATH_COMMUNITY_STREET_LINES = 'customer/address/street_lines';
|
46 |
+
|
47 |
Â
/**
|
48 |
Â
* @var null|array The resulting product option array
|
49 |
Â
*/
|
50 |
Â
protected $_options = null;
|
51 |
+
|
52 |
Â
/**
|
53 |
Â
* Source model for street line settings
|
54 |
+
*
|
55 |
Â
* @return array
|
56 |
Â
*/
|
57 |
Â
public function toOptionArray()
|
59 |
Â
if ($this->_options !== null) {
|
60 |
Â
return $this->_options;
|
61 |
Â
}
|
62 |
+
|
63 |
Â
if (Mage::helper('postnl')->isEnterprise()) {
|
64 |
Â
$array = $this->_getEnterpriseOptions();
|
65 |
+
|
66 |
Â
$this->_options = $array;
|
67 |
Â
return $array;
|
68 |
Â
}
|
69 |
+
|
70 |
Â
$array = $this->_getCommunityOptions();
|
71 |
+
|
72 |
Â
$this->_options = $array;
|
73 |
Â
return $array;
|
74 |
Â
}
|
75 |
+
|
76 |
Â
/**
|
77 |
Â
* Gets options for community edition shops
|
78 |
+
*
|
79 |
Â
* @return array
|
80 |
Â
*/
|
81 |
Â
protected function _getCommunityOptions()
|
82 |
Â
{
|
83 |
Â
$request = Mage::app()->getRequest();
|
84 |
Â
$helper = Mage::helper('postnl');
|
85 |
+
|
86 |
Â
/**
|
87 |
Â
* Get the allowed number of address lines based on the current scope
|
88 |
Â
*/
|
94 |
Â
} else {
|
95 |
Â
$lineCount = Mage::getStoreConfig(self::XML_PATH_COMMUNITY_STREET_LINES, Mage_Core_Model_App::ADMIN_STORE_ID);
|
96 |
Â
}
|
97 |
+
|
98 |
Â
/**
|
99 |
Â
* Build the option array
|
100 |
Â
*/
|
105 |
Â
'label' => $helper->__('Street line #%s', $n),
|
106 |
Â
);
|
107 |
Â
}
|
108 |
+
|
109 |
Â
return $array;
|
110 |
Â
}
|
111 |
+
|
112 |
Â
/**
|
113 |
Â
* Gets options for enterprise edition shops
|
114 |
+
*
|
115 |
Â
* @return array
|
116 |
Â
*/
|
117 |
Â
protected function _getEnterpriseOptions()
|
118 |
Â
{
|
119 |
Â
$helper = Mage::helper('postnl');
|
120 |
Â
$lineCount = Mage::helper('customer/address')->getStreetLines();
|
121 |
+
|
122 |
Â
/**
|
123 |
Â
* Build the option array
|
124 |
Â
*/
|
129 |
Â
'label' => $helper->__('Street line #%s', $n),
|
130 |
Â
);
|
131 |
Â
}
|
132 |
+
|
133 |
Â
return $array;
|
134 |
Â
}
|
135 |
Â
}
|
@@ -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.
|
@@ -41,20 +41,20 @@ class TIG_PostNL_Model_Core_System_Config_Source_StreetFieldWithDefault extends
|
|
41 |
Â
{
|
42 |
Â
/**
|
43 |
Â
* Source model for street line settings
|
44 |
-
*
|
45 |
Â
* @return array
|
46 |
Â
*/
|
47 |
Â
public function toOptionArray()
|
48 |
Â
{
|
49 |
Â
$options = parent::toOptionArray();
|
50 |
-
|
51 |
Â
$defaultOption = array(
|
52 |
Â
'value' => '',
|
53 |
Â
'label' => Mage::helper('postnl')->__('Field not used.'),
|
54 |
Â
);
|
55 |
-
|
56 |
Â
array_unshift($options, $defaultOption);
|
57 |
-
|
58 |
Â
return $options;
|
59 |
Â
}
|
60 |
Â
}
|
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.
|
41 |
Â
{
|
42 |
Â
/**
|
43 |
Â
* Source model for street line settings
|
44 |
+
*
|
45 |
Â
* @return array
|
46 |
Â
*/
|
47 |
Â
public function toOptionArray()
|
48 |
Â
{
|
49 |
Â
$options = parent::toOptionArray();
|
50 |
+
|
51 |
Â
$defaultOption = array(
|
52 |
Â
'value' => '',
|
53 |
Â
'label' => Mage::helper('postnl')->__('Field not used.'),
|
54 |
Â
);
|
55 |
+
|
56 |
Â
array_unshift($options, $defaultOption);
|
57 |
+
|
58 |
Â
return $options;
|
59 |
Â
}
|
60 |
Â
}
|
@@ -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.
|
@@ -33,16 +33,16 @@
|
|
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)
|
37 |
Â
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
|
38 |
Â
*/
|
39 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_WeightUnit
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for all possible PostNL product options
|
43 |
-
*
|
44 |
Â
* @return array
|
45 |
-
*
|
46 |
Â
* @todo implement COD and extra cover
|
47 |
Â
*/
|
48 |
Â
public function toOptionArray()
|
@@ -149,7 +149,7 @@ class TIG_PostNL_Model_Core_System_Config_Source_WeightUnit
|
|
149 |
Â
),
|
150 |
Â
),
|
151 |
Â
);
|
152 |
-
|
153 |
Â
return $availableOptions;
|
154 |
Â
}
|
155 |
Â
}
|
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.
|
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 |
Â
class TIG_PostNL_Model_Core_System_Config_Source_WeightUnit
|
40 |
Â
{
|
41 |
Â
/**
|
42 |
Â
* Returns an option array for all possible PostNL product options
|
43 |
+
*
|
44 |
Â
* @return array
|
45 |
+
*
|
46 |
Â
* @todo implement COD and extra cover
|
47 |
Â
*/
|
48 |
Â
public function toOptionArray()
|
149 |
Â
),
|
150 |
Â
),
|
151 |
Â
);
|
152 |
+
|
153 |
Â
return $availableOptions;
|
154 |
Â
}
|
155 |
Â
}
|
@@ -0,0 +1,435 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
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 |
+
* @method TIG_PostNL_Model_DeliveryOptions_Cif setStoreId(int $value)
|
40 |
+
* @method int getStoreId()
|
41 |
+
*/
|
42 |
+
class TIG_PostNL_Model_DeliveryOptions_Cif extends TIG_PostNL_Model_Core_Cif
|
43 |
+
{
|
44 |
+
/**
|
45 |
+
* Delivery option codes.
|
46 |
+
*/
|
47 |
+
const PAKJEGEMAK_DELIVERY_OPTION = 'PG';
|
48 |
+
const PAKJEGEMAK_EXPRESS_DELIVERY_OPTION = 'PGE';
|
49 |
+
const PAKKETAUTOMAAT_DELIVERY_OPTION = 'PA';
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Config options used by the getDeliveryDate service.
|
53 |
+
*/
|
54 |
+
const XPATH_SHIPPING_DURATION = 'postnl/delivery_options/shipping_duration';
|
55 |
+
const XPATH_CUTOFF_TIME = 'postnl/delivery_options/cutoff_time';
|
56 |
+
const XPATH_ALLOW_SUNDAY_SORTING = 'postnl/delivery_options/allow_sunday_sorting';
|
57 |
+
const XPATH_SUNDAY_CUTOFF_TIME = 'postnl/delivery_options/sunday_cutoff_time';
|
58 |
+
const XPATH_DELIVERY_DAYS_NUMBER = 'postnl/delivery_options/delivery_days_number';
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Check if the module is set to test mode
|
62 |
+
*
|
63 |
+
* @param bool $storeId
|
64 |
+
*
|
65 |
+
* @return boolean
|
66 |
+
*
|
67 |
+
* @see TIG_PostNL_Helper_Checkout::isTestMode()
|
68 |
+
*/
|
69 |
+
public function isTestMode($storeId = false)
|
70 |
+
{
|
71 |
+
$testMode = Mage::helper('postnl/cif')->isTestMode($storeId);
|
72 |
+
|
73 |
+
return $testMode;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* Gets the delivery date based on the shop's cut-off time.
|
78 |
+
*
|
79 |
+
* @param string $postcode
|
80 |
+
* @param Mage_Sales_Model_Quote $quote
|
81 |
+
*
|
82 |
+
* @return string
|
83 |
+
*
|
84 |
+
* @throws TIG_PostNL_Exception
|
85 |
+
*/
|
86 |
+
public function getDeliveryDate($postcode, Mage_Sales_Model_Quote $quote)
|
87 |
+
{
|
88 |
+
if (empty($postcode)) {
|
89 |
+
throw new TIG_PostNL_Exception(
|
90 |
+
Mage::helper('postnl')->__('No data available for GetDeliveryDay request.'),
|
91 |
+
'POSTNL-0115'
|
92 |
+
);
|
93 |
+
}
|
94 |
+
|
95 |
+
$shippingDuration = Mage::helper('postnl/deliveryoptions')->getShippingDuration($quote);
|
96 |
+
|
97 |
+
$soapParams = array(
|
98 |
+
'GetDeliveryDate' => array(
|
99 |
+
'Postalcode' => $postcode,
|
100 |
+
'ShippingDate' => date('d-m-Y H:i:s', Mage::getModel('core/date')->timestamp()),
|
101 |
+
'ShippingDuration' => $shippingDuration,
|
102 |
+
'CutOffTime' => $this->_getCutOffTime(),
|
103 |
+
'AllowSundaySorting' => $this->_getSundaySortingAllowed(),
|
104 |
+
'CutOffTimeForSundaySorting' => $this->_getSundaySortingCutOffTime(),
|
105 |
+
),
|
106 |
+
'Message' => $this->_getMessage('')
|
107 |
+
);
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Send the SOAP request
|
111 |
+
*/
|
112 |
+
$response = $this->call(
|
113 |
+
'deliverydate',
|
114 |
+
'GetDeliveryDate',
|
115 |
+
$soapParams
|
116 |
+
);
|
117 |
+
|
118 |
+
if (!is_object($response)
|
119 |
+
|| !isset($response->DeliveryDate)
|
120 |
+
|| !is_string($response->DeliveryDate)
|
121 |
+
) {
|
122 |
+
throw new TIG_PostNL_Exception(
|
123 |
+
Mage::helper('postnl')->__('Invalid GetDeliveryDate response: %s', "\n" . var_export($response, true)),
|
124 |
+
'POSTNL-0116'
|
125 |
+
);
|
126 |
+
}
|
127 |
+
|
128 |
+
return $response->DeliveryDate;
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Get evening timeframes for the specified postcode and delivery window.
|
133 |
+
*
|
134 |
+
* @param array $data
|
135 |
+
*
|
136 |
+
* @return StdClass
|
137 |
+
*
|
138 |
+
* @throws TIG_PostNL_Exception
|
139 |
+
*/
|
140 |
+
public function getDeliveryTimeframes($data)
|
141 |
+
{
|
142 |
+
if (empty($data)) {
|
143 |
+
throw new TIG_PostNL_Exception(
|
144 |
+
Mage::helper('postnl')->__('No data available for request.'),
|
145 |
+
'POSTNL-0117'
|
146 |
+
);
|
147 |
+
}
|
148 |
+
|
149 |
+
$startDate = $data['deliveryDate'];
|
150 |
+
|
151 |
+
/**
|
152 |
+
* To calculate the end date we need to number of days we want to display minus 1.
|
153 |
+
*/
|
154 |
+
$storeId = Mage::app()->getStore()->getId();
|
155 |
+
$maximumNumberOfDeliveryDays = (int) Mage::getStoreConfig(self::XPATH_DELIVERY_DAYS_NUMBER, $storeId);
|
156 |
+
$maximumNumberOfDeliveryDays--;
|
157 |
+
|
158 |
+
$endDate = date('d-m-Y', strtotime("+{$maximumNumberOfDeliveryDays} days", strtotime($startDate)));
|
159 |
+
|
160 |
+
$soapParams = array(
|
161 |
+
'Timeframe' => array(
|
162 |
+
'PostalCode' => $data['postcode'],
|
163 |
+
'HouseNumber' => $data['housenumber'],
|
164 |
+
'StartDate' => $startDate,
|
165 |
+
'EndDate' => $endDate,
|
166 |
+
),
|
167 |
+
'Message' => $this->_getMessage('')
|
168 |
+
);
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Send the SOAP request
|
172 |
+
*/
|
173 |
+
$response = $this->call(
|
174 |
+
'timeframe',
|
175 |
+
'GetDeliveryTimeframes',
|
176 |
+
$soapParams
|
177 |
+
);
|
178 |
+
|
179 |
+
if (!isset($response->Timeframes)
|
180 |
+
|| !isset($response->Timeframes->Timeframe)
|
181 |
+
) {
|
182 |
+
throw new TIG_PostNL_Exception(
|
183 |
+
Mage::helper('postnl')->__('Invalid response for getDeliveryTimeframes request: %s', $response),
|
184 |
+
'POSTNL-0122'
|
185 |
+
);
|
186 |
+
}
|
187 |
+
|
188 |
+
return $response->Timeframes->Timeframe;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Gets nearby post office locations. This service can be based off of a postcode or a set of coordinates. Results may
|
193 |
+
* include PakjeGemak, PakjeGemak Express or pakket automaat locations based on the configuration of the extension.
|
194 |
+
*
|
195 |
+
* @param $data
|
196 |
+
*
|
197 |
+
* @return string
|
198 |
+
*
|
199 |
+
* @throws TIG_PostNL_Exception
|
200 |
+
*/
|
201 |
+
public function getNearestLocations($data)
|
202 |
+
{
|
203 |
+
if (empty($data)) {
|
204 |
+
throw new TIG_PostNL_Exception(
|
205 |
+
Mage::helper('postnl')->__('No data available for request.'),
|
206 |
+
'POSTNL-0117'
|
207 |
+
);
|
208 |
+
}
|
209 |
+
|
210 |
+
$location = $this->_getLocation($data);
|
211 |
+
$message = $this->_getMessage('');
|
212 |
+
|
213 |
+
$soapParams = array(
|
214 |
+
'Location' => $location,
|
215 |
+
'Message' => $message,
|
216 |
+
);
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Send the SOAP request
|
220 |
+
*/
|
221 |
+
$response = $this->call(
|
222 |
+
'location',
|
223 |
+
'GetNearestLocations',
|
224 |
+
$soapParams
|
225 |
+
);
|
226 |
+
|
227 |
+
if (!isset($response->GetLocationsResult)
|
228 |
+
|| !isset($response->GetLocationsResult->ResponseLocation)
|
229 |
+
) {
|
230 |
+
throw new TIG_PostNL_Exception(
|
231 |
+
Mage::helper('postnl')->__('Invalid response for GetNearestLocations request: %s', $response),
|
232 |
+
'POSTNL-0123'
|
233 |
+
);
|
234 |
+
}
|
235 |
+
|
236 |
+
return $response->GetLocationsResult->ResponseLocation;
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* gets post office locations within a specific area, marked by a set of coordinates.
|
241 |
+
*
|
242 |
+
* @param $data
|
243 |
+
*
|
244 |
+
* @return string
|
245 |
+
*
|
246 |
+
* @throws TIG_PostNL_Exception
|
247 |
+
*/
|
248 |
+
public function getLocationsInArea($data)
|
249 |
+
{
|
250 |
+
if (empty($data)) {
|
251 |
+
throw new TIG_PostNL_Exception(
|
252 |
+
Mage::helper('postnl')->__('No data available for request.'),
|
253 |
+
'POSTNL-0117'
|
254 |
+
);
|
255 |
+
}
|
256 |
+
|
257 |
+
$location = $this->_getLocation($data);
|
258 |
+
$message = $this->_getMessage('');
|
259 |
+
|
260 |
+
$soapParams = array(
|
261 |
+
'Location' => $location,
|
262 |
+
'Message' => $message,
|
263 |
+
);
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Send the SOAP request
|
267 |
+
*/
|
268 |
+
$response = $this->call(
|
269 |
+
'location',
|
270 |
+
'GetLocationsInArea',
|
271 |
+
$soapParams
|
272 |
+
);
|
273 |
+
|
274 |
+
if (!isset($response->GetLocationsResult)
|
275 |
+
|| !isset($response->GetLocationsResult)
|
276 |
+
) {
|
277 |
+
throw new TIG_PostNL_Exception(
|
278 |
+
Mage::helper('postnl')->__('Invalid response for getLocationsInArea request: %s', $response),
|
279 |
+
'POSTNL-0123'
|
280 |
+
);
|
281 |
+
}
|
282 |
+
|
283 |
+
return $response->GetLocationsResult->ResponseLocation;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Gets the regular cut-off time for this storeview.
|
288 |
+
*
|
289 |
+
* @return string
|
290 |
+
*/
|
291 |
+
protected function _getCutOffTime()
|
292 |
+
{
|
293 |
+
$storeId = $this->getStoreId();
|
294 |
+
|
295 |
+
$cutOffTime = Mage::getStoreConfig(self::XPATH_CUTOFF_TIME, $storeId);
|
296 |
+
if (!$cutOffTime) {
|
297 |
+
$cutOffTime = '23:59:59';
|
298 |
+
}
|
299 |
+
|
300 |
+
return $cutOffTime;
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* Checks whether sunday sorting is allowed for this storeview.
|
305 |
+
*
|
306 |
+
* @return string
|
307 |
+
*/
|
308 |
+
protected function _getSundaySortingAllowed()
|
309 |
+
{
|
310 |
+
$storeId = $this->getStoreId();
|
311 |
+
|
312 |
+
$allowSundaySorting = Mage::getStoreConfigFlag(self::XPATH_ALLOW_SUNDAY_SORTING, $storeId);
|
313 |
+
if ($allowSundaySorting === true) {
|
314 |
+
return 'true';
|
315 |
+
}
|
316 |
+
|
317 |
+
return 'false';
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Gets the regular cut-off time for this storeview.
|
322 |
+
*
|
323 |
+
* @return string
|
324 |
+
*/
|
325 |
+
protected function _getSundaySortingCutOffTime()
|
326 |
+
{
|
327 |
+
$storeId = $this->getStoreId();
|
328 |
+
|
329 |
+
$cutOffTime = Mage::getStoreConfig(self::XPATH_SUNDAY_CUTOFF_TIME, $storeId);
|
330 |
+
if (!$cutOffTime) {
|
331 |
+
$cutOffTime = '23:59:59';
|
332 |
+
}
|
333 |
+
|
334 |
+
return $cutOffTime;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Gets the location SOAP parameter array.
|
339 |
+
*
|
340 |
+
* @param array $data
|
341 |
+
*
|
342 |
+
* @return array
|
343 |
+
*/
|
344 |
+
protected function _getLocation($data)
|
345 |
+
{
|
346 |
+
/**
|
347 |
+
* Start building the location array by adding the available delivery options.
|
348 |
+
*/
|
349 |
+
$location = array(
|
350 |
+
'DeliveryOptions' => $this->_getDeliveryOptions(),
|
351 |
+
);
|
352 |
+
|
353 |
+
/**
|
354 |
+
* Next we add the desired delivery date. If none is specified, we set it to tomorrow.
|
355 |
+
*/
|
356 |
+
if (isset($data['deliveryDate'])) {
|
357 |
+
$location['DeliveryDate'] = $data['deliveryDate'];
|
358 |
+
} else {
|
359 |
+
$tomorrow = strtotime('tomorrow', Mage::getModel('core/date')->timestamp());
|
360 |
+
$location['DeliveryDate'] = date('d-m-Y', $tomorrow);
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* If an opening time was specified, add that as well.
|
365 |
+
*/
|
366 |
+
if (isset($data['openingTime'])) {
|
367 |
+
$location['OpeningTime'] = $data['openingTime'];
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Add the postcode if available.
|
372 |
+
*/
|
373 |
+
if (isset($data['postcode'])) {
|
374 |
+
$location['Postalcode'] = $data['postcode'];
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Add coordinates if both a latitude and longitude are available.
|
379 |
+
*/
|
380 |
+
if (isset($data['lat']) && isset($data['long'])) {
|
381 |
+
$location['Coordinates'] = array(
|
382 |
+
'Latitude' => $data['lat'],
|
383 |
+
'Longitude' => $data['long'],
|
384 |
+
);
|
385 |
+
}
|
386 |
+
|
387 |
+
/**
|
388 |
+
* Add coordinates for an area marked by two sets of coordinates.
|
389 |
+
*
|
390 |
+
* Please note that PostNL uses NW and SE, while google maps uses NE and SW.
|
391 |
+
*/
|
392 |
+
if (isset($data['northEast']['lat'])
|
393 |
+
&& isset($data['northEast']['long'])
|
394 |
+
&& isset($data['southWest']['lat']
|