Official_GLS_Dispatch - Version 1.0.0

Version Notes

Official GLS Dispatch Extension

Download this release

Release Info

Developer synergetic PHP Webdevelopment
Extension Official_GLS_Dispatch
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (117) hide show
  1. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment.php +39 -0
  2. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Edit.php +69 -0
  3. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Edit/Form.php +90 -0
  4. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Edit/Form/Packages.php +59 -0
  5. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid.php +126 -0
  6. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Order.php +37 -0
  7. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Pdf.php +46 -0
  8. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Shipment.php +37 -0
  9. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Address/Form/Attr/Parcelshopid.php +13 -0
  10. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls.php +373 -0
  11. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls/Packages.php +108 -0
  12. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Tracking.php +47 -0
  13. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/View/Gls.php +66 -0
  14. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/View/Tracking.php +42 -0
  15. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Template/Grid/Renderer/Order.php +33 -0
  16. app/code/community/SynergeticAgency/Gls/Block/Adminhtml/System/Config/Note.php +54 -0
  17. app/code/community/SynergeticAgency/Gls/Block/Checkout/Onepage/Parcelshop.php +76 -0
  18. app/code/community/SynergeticAgency/Gls/Block/Checkout/Onepage/Parcelshop/Map.php +39 -0
  19. app/code/community/SynergeticAgency/Gls/Block/Form/Glscashondelivery.php +57 -0
  20. app/code/community/SynergeticAgency/Gls/Helper/Data.php +303 -0
  21. app/code/community/SynergeticAgency/Gls/Helper/Log.php +124 -0
  22. app/code/community/SynergeticAgency/Gls/Helper/Validate.php +184 -0
  23. app/code/community/SynergeticAgency/Gls/Model/Carrier.php +382 -0
  24. app/code/community/SynergeticAgency/Gls/Model/Combination.php +92 -0
  25. app/code/community/SynergeticAgency/Gls/Model/Country.php +61 -0
  26. app/code/community/SynergeticAgency/Gls/Model/Gls.php +543 -0
  27. app/code/community/SynergeticAgency/Gls/Model/Glscashondelivery.php +265 -0
  28. app/code/community/SynergeticAgency/Gls/Model/Jsonimport.php +261 -0
  29. app/code/community/SynergeticAgency/Gls/Model/Observer.php +267 -0
  30. app/code/community/SynergeticAgency/Gls/Model/Product.php +34 -0
  31. app/code/community/SynergeticAgency/Gls/Model/Resource/Combination.php +105 -0
  32. app/code/community/SynergeticAgency/Gls/Model/Resource/Combination/Collection.php +71 -0
  33. app/code/community/SynergeticAgency/Gls/Model/Resource/Country.php +106 -0
  34. app/code/community/SynergeticAgency/Gls/Model/Resource/Country/Collection.php +72 -0
  35. app/code/community/SynergeticAgency/Gls/Model/Resource/Product.php +105 -0
  36. app/code/community/SynergeticAgency/Gls/Model/Resource/Product/Collection.php +69 -0
  37. app/code/community/SynergeticAgency/Gls/Model/Resource/Service.php +104 -0
  38. app/code/community/SynergeticAgency/Gls/Model/Resource/Service/Collection.php +104 -0
  39. app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment.php +42 -0
  40. app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Address.php +63 -0
  41. app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Address/Collection.php +42 -0
  42. app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Collection.php +42 -0
  43. app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Parcel.php +42 -0
  44. app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Parcel/Collection.php +42 -0
  45. app/code/community/SynergeticAgency/Gls/Model/Service.php +34 -0
  46. app/code/community/SynergeticAgency/Gls/Model/Shipment.php +120 -0
  47. app/code/community/SynergeticAgency/Gls/Model/Shipment/Address.php +54 -0
  48. app/code/community/SynergeticAgency/Gls/Model/Shipment/Parcel.php +42 -0
  49. app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Country.php +76 -0
  50. app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Labelsize.php +69 -0
  51. app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Payment/Shippingmethods.php +41 -0
  52. app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Product.php +72 -0
  53. app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Service.php +76 -0
  54. app/code/community/SynergeticAgency/Gls/config/combinations.php +63 -0
  55. app/code/community/SynergeticAgency/Gls/config/countries.php +141 -0
  56. app/code/community/SynergeticAgency/Gls/config/products.php +35 -0
  57. app/code/community/SynergeticAgency/Gls/config/services.php +68 -0
  58. app/code/community/SynergeticAgency/Gls/controllers/Adminhtml/Gls/ShipmentController.php +750 -0
  59. app/code/community/SynergeticAgency/Gls/controllers/FrontendController.php +52 -0
  60. app/code/community/SynergeticAgency/Gls/data/synergeticagency_gls_setup/data-install-0.1.0.php +34 -0
  61. app/code/community/SynergeticAgency/Gls/data/synergeticagency_gls_setup/data-upgrade-0.1.0-0.1.1.php +300 -0
  62. app/code/community/SynergeticAgency/Gls/etc/adminhtml.xml +40 -0
  63. app/code/community/SynergeticAgency/Gls/etc/config.xml +287 -0
  64. app/code/community/SynergeticAgency/Gls/etc/system.xml +700 -0
  65. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/install-0.1.0.php +35 -0
  66. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.0-0.1.1.php +210 -0
  67. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.1-0.1.2.php +129 -0
  68. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.2-0.1.3.php +48 -0
  69. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.3-0.1.4.php +39 -0
  70. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.4-0.1.5.php +38 -0
  71. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.5-0.1.6.php +37 -0
  72. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.6-0.1.7.php +51 -0
  73. app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.2.0-0.2.1.php +36 -0
  74. app/design/adminhtml/base/default/layout/synergeticagency/gls.xml +22 -0
  75. app/design/adminhtml/base/default/template/gls/sales/order/address/form/attr/parcelshopid.phtml +7 -0
  76. app/design/adminhtml/base/default/template/gls/sales/order/shipment/create/gls.phtml +193 -0
  77. app/design/adminhtml/base/default/template/gls/sales/order/shipment/create/gls/packages.phtml +539 -0
  78. app/design/adminhtml/base/default/template/gls/sales/order/shipment/view/gls.phtml +89 -0
  79. app/design/adminhtml/base/default/template/gls/shipment/edit.phtml +23 -0
  80. app/design/adminhtml/base/default/template/gls/system/config/note.phtml +34 -0
  81. app/design/adminhtml/base/default/template/gls/system/shipping/gls_applicable_country.phtml +17 -0
  82. app/design/frontend/base/default/layout/synergeticagency/gls.xml +33 -0
  83. app/design/frontend/base/default/template/gls/checkout/onepage/billing_form_additional_parcelshop.phtml +5 -0
  84. app/design/frontend/base/default/template/gls/checkout/onepage/parcelshop/map.phtml +46 -0
  85. app/design/frontend/base/default/template/gls/checkout/onepage/shipping.phtml +3 -0
  86. app/design/frontend/base/default/template/gls/checkout/onepage/shipping_parcelshop.phtml +45 -0
  87. app/design/frontend/base/default/template/gls/form/glscashondelivery.phtml +15 -0
  88. app/design/frontend/base/default/template/gls/logoJs.phtml +34 -0
  89. app/etc/modules/SynergeticAgency_Gls.xml +9 -0
  90. app/locale/de_DE/SynergeticAgency_Gls.csv +183 -0
  91. js/gls/admin.js +0 -0
  92. js/gls/frontend.js +671 -0
  93. lib/SynergeticAgency/GlsConnector/Connector.php +1103 -0
  94. lib/SynergeticAgency/GlsConnector/Log.php +289 -0
  95. lib/SynergeticAgency/GlsConnector/Log/README.TXT +0 -0
  96. lib/SynergeticAgency/GlsConnector/Model/Address.php +562 -0
  97. lib/SynergeticAgency/GlsConnector/Model/Error.php +144 -0
  98. lib/SynergeticAgency/GlsConnector/Model/Info.php +147 -0
  99. lib/SynergeticAgency/GlsConnector/Model/JsonConfig.php +101 -0
  100. lib/SynergeticAgency/GlsConnector/Model/Parcel.php +348 -0
  101. lib/SynergeticAgency/GlsConnector/Model/Service.php +176 -0
  102. lib/SynergeticAgency/GlsConnector/Model/Services.php +111 -0
  103. lib/SynergeticAgency/GlsConnector/Model/Shipment.php +557 -0
  104. package.xml +45 -0
  105. skin/adminhtml/base/default/gls.css +9 -0
  106. skin/adminhtml/base/default/images/gls/gls-logo.png +0 -0
  107. skin/adminhtml/base/default/images/gls/logo_thumb.png +0 -0
  108. skin/frontend/base/default/css/gls/frontend.css +32 -0
  109. skin/frontend/base/default/images/gls/logo/de/express.png +0 -0
  110. skin/frontend/base/default/images/gls/logo/de/foreigncountries.png +0 -0
  111. skin/frontend/base/default/images/gls/logo/de/standard.png +0 -0
  112. skin/frontend/base/default/images/gls/logo/de/thinkgreen.png +0 -0
  113. skin/frontend/base/default/images/gls/logo/default/express.png +0 -0
  114. skin/frontend/base/default/images/gls/logo/default/foreigncountries.png +0 -0
  115. skin/frontend/base/default/images/gls/logo/default/standard.png +0 -0
  116. skin/frontend/base/default/images/gls/logo/default/thinkgreen.png +0 -0
  117. var/import/gls/json/glsconfig.json.sample +89 -0
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment extends Mage_Adminhtml_Block_Widget_Grid_Container {
26
+
27
+ /**
28
+ * The Constructor initiates the blockGroup, the controller and the headerText of the used Mage_Adminhtml_Block_Widget_Grid_Container
29
+ * The Connector also removes the button "add" from the used Mage_Adminhtml_Block_Widget_Grid_Container
30
+ */
31
+ public function __construct()
32
+ {
33
+ $this->_blockGroup = 'synergeticagency_gls';
34
+ $this->_controller = 'adminhtml_sales_gls_shipment';
35
+ $this->_headerText = Mage::helper('synergeticagency_gls')->__('GLS Shipments List');
36
+ parent::__construct();
37
+ $this->_removeButton('add');
38
+ }
39
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Edit.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Edit
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Edit extends Mage_Adminhtml_Block_Template {
26
+
27
+ /**
28
+ * The Constructor initiates the template for the used Mage_Adminhtml_Block_Template
29
+ */
30
+ public function _construct() {
31
+ $this->setTemplate('gls/shipment/edit.phtml');
32
+ parent::_construct();
33
+ }
34
+
35
+ /**
36
+ * return the translated version for the header text
37
+ * @return mixed
38
+ */
39
+ public function getHeaderText()
40
+ {
41
+ return Mage::helper('synergeticagency_gls')->__('Edit GLS Shipment');
42
+ }
43
+
44
+ /**
45
+ * Return the HTML for the buttons used in the "edit shipment" template
46
+ * @return string
47
+ */
48
+ public function getButtonsHtml()
49
+ {
50
+ $addSaveButtonData = array(
51
+ 'id' => 'save',
52
+ 'label' => Mage::helper('adminhtml')->__('Save'),
53
+ 'onclick' => 'editForm.submit();',
54
+ 'class' => 'save',
55
+ );
56
+ $addBackButtonData = array(
57
+ 'id' => 'back',
58
+ 'label' => Mage::helper('adminhtml')->__('Back'),
59
+ 'onclick' => 'setLocation(\'' . $this->getUrl('adminhtml/sales_shipment/view', array(
60
+ 'shipment_id'=>Mage::registry('current_shipment')->getId())) . '\')',
61
+ 'class' => 'back',
62
+ );
63
+
64
+ $html = $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addBackButtonData)->toHtml();
65
+ $html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addSaveButtonData)->toHtml();
66
+
67
+ return $html;
68
+ }
69
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Edit/Form.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Edit
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Edit_Form
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Edit_Form extends SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls {
26
+
27
+ /**
28
+ * The Constructor here call the parent constructor of SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls
29
+ */
30
+ public function _construct() {
31
+ parent::_construct();
32
+ }
33
+
34
+ /**
35
+ * Returns true, if current GLS shipment label should be delivered with return label
36
+ * Returns false, if current GLS shipment label should be delivered without return label
37
+ *
38
+ * @return bool
39
+ */
40
+ public function getReturnLabel() {
41
+ return $this->_getGlsShipment()->getReturnLabel() === '1';
42
+ }
43
+
44
+
45
+ /**
46
+ * Returns true, if current GLS shipment combination id equals to the given parameter
47
+ * Returns true, if current GLS shipment combination id not equals to the given parameter
48
+ *
49
+ * @param int $combinationId
50
+ * @return bool
51
+ */
52
+ public function isCombinationSelected($combinationId) {
53
+ return $combinationId == $this->_getGlsShipment()->getCombinationId();
54
+ }
55
+
56
+ /**
57
+ * Retrurns true, if given GLS service id is part of the current GLS shipment
58
+ * Retrurns false, if given GLS service id is not part of the current GLS shipment
59
+ *
60
+ * @param int $serviceId
61
+ * @return bool
62
+ */
63
+ public function isServiceSelected($serviceId) {
64
+ $services = $this->_getGlsShipment()->getGlsServices();
65
+ if(empty($services)) {
66
+ return false;
67
+ }
68
+ $services = explode(',',$services);
69
+ return in_array($serviceId,$services);
70
+ }
71
+
72
+ /**
73
+ * Returns the "d.m.Y" formatted date string representation of the current GLS shipping date
74
+ *
75
+ * @return bool|string
76
+ */
77
+ public function getShippingDate() {
78
+ return date('d.m.Y', strtotime($this->_getGlsShipment()->getShippingDate()));
79
+ }
80
+
81
+ /**
82
+ * Returns the SynergeticAgency_Gls_Model_Shipment object
83
+ *
84
+ * @return SynergeticAgency_Gls_Model_Shipment
85
+ */
86
+ private function _getGlsShipment() {
87
+ return Mage::registry('gls_shipment');
88
+ }
89
+
90
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Edit/Form/Packages.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Edit\Form
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Edit_Form_Packages
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Edit_Form_Packages extends SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls_Packages {
26
+
27
+ /**
28
+ * Verify if shipment has already existing parcels
29
+ * @return bool
30
+ */
31
+ public function hasParcels() {
32
+
33
+ $hasParcels = false;
34
+
35
+ if(count($this->getParcels()) > 0 ) {
36
+ $hasParcels = true;
37
+ }
38
+
39
+ return $hasParcels;
40
+ }
41
+
42
+ /**
43
+ * Returns existing parcels of the current shipment. Otherwise the return value is NULL
44
+ *
45
+ * @return mixed
46
+ */
47
+ public function getParcels() {
48
+ return $this->_getGlsShipment()->getShipmentParcels();
49
+ }
50
+
51
+ /**
52
+ * Returns SynergeticAgency_Gls_Model_Shipment object
53
+ *
54
+ * @return SynergeticAgency_Gls_Model_Shipment
55
+ */
56
+ private function _getGlsShipment() {
57
+ return Mage::registry('gls_shipment');
58
+ }
59
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid extends Mage_Adminhtml_Block_Widget_Grid {
26
+
27
+ /**
28
+ * The Constructor initiates the id, the defaultSort and the defaultDir of the used Mage_Adminhtml_Block_Widget_Grid
29
+ */
30
+ public function __construct()
31
+ {
32
+ parent::__construct();
33
+ $this->setId('synergeticagency_gls_shipment_grid');
34
+ $this->setDefaultSort('gls_shipment_id');
35
+ $this->setDefaultDir('DESC');
36
+ }
37
+
38
+ /**
39
+ * Prepare grid collection object
40
+ *
41
+ * @return SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid
42
+ */
43
+ protected function _prepareCollection()
44
+ {
45
+ $collection = Mage::getResourceModel('synergeticagency_gls/shipment_collection');
46
+ $collection->getSelect()->joinLeft(
47
+ array(
48
+ 'shipment' => $collection->getTable('sales/shipment_grid')
49
+ ),
50
+ 'main_table.shipment_id=shipment.entity_id',
51
+ array(
52
+ 'shipment_increment_id' => 'increment_id',
53
+ 'created_at' => 'created_at'
54
+ )
55
+ )->joinLeft(
56
+ array(
57
+ 'order' => $collection->getTable('sales/order_grid')
58
+ ),
59
+ 'shipment.order_id=order.entity_id',
60
+ array(
61
+ 'order_id' => 'entity_id',
62
+ 'order_increment_id' => 'increment_id',
63
+ 'shipping_name' => 'shipping_name',
64
+ 'order_date' => 'created_at'
65
+ )
66
+ );
67
+
68
+ $this->setCollection($collection);
69
+ parent::_prepareCollection();
70
+ return $this;
71
+ }
72
+
73
+ /**
74
+ * Prepare grid columns
75
+ *
76
+ * @return Mage_Adminhtml_Block_Widget_Grid
77
+ */
78
+ protected function _prepareColumns()
79
+ {
80
+ $helper = Mage::helper('synergeticagency_gls');
81
+
82
+ $this->addColumn('gls_shipment_id', array(
83
+ 'header' => $helper->__('GLS Shipment ID'),
84
+ 'index' => 'gls_shipment_id'
85
+ ));
86
+
87
+ $this->addColumn('consignment_id', array(
88
+ 'header' => $helper->__('GLS Consignment ID'),
89
+ 'index' => 'consignment_id'
90
+ ));
91
+
92
+ $this->addColumn('order', array(
93
+ 'header' => Mage::helper('sales')->__('Order'),
94
+ 'align' => 'left',
95
+ 'index' => 'order.increment_id',
96
+ 'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_order'
97
+ ));
98
+
99
+ $this->addColumn('shipping_name', array(
100
+ 'header' => Mage::helper('sales')->__('Ship to Name'),
101
+ 'index' => 'shipping_name',
102
+ ));
103
+
104
+ $this->addColumn('shipment', array(
105
+ 'header' => Mage::helper('sales')->__('Shipments'),
106
+ 'align' => 'left',
107
+ 'index' => 'shipment.increment_id',
108
+ 'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_shipment',
109
+ ));
110
+ $this->addColumn('created_at', array(
111
+ 'header' => Mage::helper('sales')->__('Date Shipped'),
112
+ 'index' => 'created_at',
113
+ 'type' => 'datetime',
114
+ ));
115
+
116
+ $this->addColumn('pdf', array(
117
+ 'header' => Mage::helper('sales')->__('Action'),
118
+ 'align' => 'left',
119
+ 'renderer' => 'synergeticagency_gls/adminhtml_sales_gls_shipment_grid_renderer_pdf',
120
+ 'filter' => false,
121
+ 'sortable' => false,
122
+ ));
123
+
124
+ return parent::_prepareColumns();
125
+ }
126
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Order.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Grid\Renderer
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Order
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Order extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
26
+
27
+ /**
28
+ * Renders the GLS shipment grid HTML for the given GLS order row
29
+ *
30
+ * @param Varien_Object $row
31
+ * @return string
32
+ */
33
+ public function render(Varien_Object $row)
34
+ {
35
+ return sprintf('<a href="%s">%s</a>', Mage::helper('adminhtml')->getUrl('adminhtml/sales_order/view', array('order_id' => $row->getOrderId())), $row->getOrderIncrementId());
36
+ }
37
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Pdf.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Grid\Renderer
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Pdf
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Pdf extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
26
+
27
+ /**
28
+ * Renders the GLS shipment grid HTML for the given GLS shipment PDF row
29
+ *
30
+ * @param Varien_Object $row
31
+ * @return string
32
+ */
33
+ public function render(Varien_Object $row)
34
+ {
35
+ if($row->getPrinted()) {
36
+ $html = '<span>'.$this->__('Printed').'</span>';
37
+
38
+ $html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'" disabled="" class=" disabled">%s</button>', $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('Printed'));
39
+
40
+
41
+ } else {
42
+ $html = sprintf('<button onclick="setLocation(\'%s\');this.disabled=true;this.className += \' disabled\'">%s</button>', $this->getUrl('*/gls_shipment/print', array('id' => $row->getId())), $this->__('Download PDF'));
43
+ }
44
+ return $html;
45
+ }
46
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Gls/Shipment/Grid/Renderer/Shipment.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Gls\Shipment\Grid\Renderer
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Shipment
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Gls_Shipment_Grid_Renderer_Shipment extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
26
+
27
+ /**
28
+ * Renders the GLS shipment grid HTML for the given GLS shipment row
29
+ *
30
+ * @param Varien_Object $row
31
+ * @return string
32
+ */
33
+ public function render(Varien_Object $row)
34
+ {
35
+ return sprintf('<a href="%s">%s</a>', Mage::helper('adminhtml')->getUrl('adminhtml/sales_shipment/view', array('shipment_id' => $row->getShipmentId())), $row->getShipmentIncrementId());
36
+ }
37
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Address/Form/Attr/Parcelshopid.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Address_Form_Attr_Parcelshopid
3
+ extends Mage_Adminhtml_Block_Widget
4
+ implements Varien_Data_Form_Element_Renderer_Interface {
5
+ public function __construct()
6
+ {
7
+ $this->setTemplate('gls/sales/order/address/form/attr/parcelshopid.phtml'); //set a template
8
+ }
9
+ public function render(Varien_Data_Form_Element_Abstract $element) {
10
+ $this->setElement($element);
11
+ return $this->toHtml();
12
+ }
13
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls.php ADDED
@@ -0,0 +1,373 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Order\Shipment\Create
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls extends Mage_Adminhtml_Block_Template {
26
+
27
+ /**
28
+ * The Constructor initiates the template for the used Mage_Adminhtml_Block_Template
29
+ */
30
+ public function _construct()
31
+ {
32
+ $this->setTemplate('gls/sales/order/shipment/create/gls.phtml');
33
+ parent::_construct();
34
+ }
35
+
36
+ /**
37
+ * Returns true, if GLS basis configuration "gls/shipment/return_label_enabled" is set to '1'
38
+ * Returns false, if GLS basis configuration "gls/shipment/return_label_enabled" is not set to '1'
39
+ *
40
+ * @return bool
41
+ */
42
+ public function getReturnLabel() {
43
+ return Mage::getStoreConfig('gls/shipment/return_label_enabled',$this->getStore()) === '1';
44
+ }
45
+
46
+ /**
47
+ * Returns GLS shipping configuration "gls/shipment/labelsize"
48
+ *
49
+ * @return string
50
+ */
51
+ public function getLabelsize() {
52
+ return Mage::getStoreConfig('gls/shipment/labelsize',$this->getStore());
53
+ }
54
+
55
+ /**
56
+ * Returns true, if destination of current shipment is allowed by current Magento store configuration and GLS basis configuration.
57
+ * Returns false, if destination of current shipment is not allowed by current Magento store configuration and GLS basis configuration.
58
+ *
59
+ * @return bool
60
+ */
61
+ public function isCountryAvailable() {
62
+ $glsModel = Mage::getModel('synergeticagency_gls/gls');
63
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
64
+ $destCountry = $this->_getCurrentShipment()->getShippingAddress()->getCountryId();
65
+ return ($glsModel->isCountryOriginIdAvailable($storeCountry)
66
+ && ($this->isDomestic() || $glsModel->isDestinationCountryAvailable($storeCountry,$destCountry)));
67
+ }
68
+
69
+ /**
70
+ * Returns options array of current GLS product and GLS service combination
71
+ *
72
+ * @return array
73
+ */
74
+ public function getCombinations() {
75
+ $options = Mage::getModel('synergeticagency_gls/gls')->productServiceCombinationsToOptionArray();
76
+ array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
77
+ return $options;
78
+ }
79
+
80
+ /**
81
+ * Returns the "d.m.Y" formatted date string representation of "today"
82
+ *
83
+ * @return bool|string
84
+ */
85
+ public function getShippingDate() {
86
+ return date('d.m.Y', strtotime('today'));
87
+ }
88
+
89
+ /**
90
+ * Returns true, if the given combinationId is allowed by given values such as "isDomestic", "isStandardShipping", etc
91
+ * and if the given combinationId is defined as constant of SynergeticAgency_Gls_Model_Gls
92
+ * Otherwise, this function returns false
93
+ *
94
+ * @param $combinationId
95
+ * @return bool
96
+ */
97
+ public function isCombinationSelected($combinationId) {
98
+ $return = false;
99
+ switch ($combinationId) {
100
+ case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL:
101
+ if($this->isDomestic() && ($this->isStandardShipping()) && !$this->isParcelshopDelivery() && !$this->isCashService()) {
102
+ $return = true;
103
+ }
104
+ break;
105
+ case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_GUARANTEED:
106
+ if($this->isDomestic() && $this->isExpressShipping()) {
107
+ $return = true;
108
+ }
109
+ break;
110
+ case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY:
111
+ if($this->isDomestic() && $this->isParcelshopDelivery()) {
112
+ $return = true;
113
+ }
114
+ break;
115
+ case SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE:
116
+ if($this->isDomestic() && $this->isCashService()) {
117
+ $return = true;
118
+ }
119
+ break;
120
+ case SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL:
121
+ if((!$this->isDomestic() || $this->matchCountry('FI')) && !$this->isParcelshopDelivery() && $this->isForeignShipping()) {
122
+ $return = true;
123
+ }
124
+ break;
125
+ case SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY:
126
+ if(!$this->isDomestic() && $this->isParcelshopDelivery()) {
127
+ $return = true;
128
+ }
129
+ break;
130
+ }
131
+ return $return;
132
+ }
133
+
134
+ /**
135
+ * Returns true, if the given serviceId is allowed by given values
136
+ * and if the given serviceId is defined as constant of SynergeticAgency_Gls_Model_Gls
137
+ * Otherwise, this function returns false
138
+ *
139
+ * @param $serviceId
140
+ * @return bool
141
+ */
142
+ public function isServiceSelected($serviceId) {
143
+ $return = false;
144
+ switch($serviceId) {
145
+
146
+ }
147
+ return $return;
148
+ }
149
+
150
+ /**
151
+ * Returns true, if current shipping method is a GLS "Standard" shipping
152
+ * Otherwise, this function returns false
153
+ *
154
+ * @return bool
155
+ */
156
+ public function isStandardShipping() {
157
+ return $this->_getCurrentShipment()->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_STANDARD;
158
+ }
159
+
160
+ /**
161
+ * Returns true, if current shipping method is a GLS "Express" shipping
162
+ * Otherwise, this function returns false
163
+ *
164
+ * @return bool
165
+ */
166
+ public function isExpressShipping() {
167
+ return $this->_getCurrentShipment()->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_EXPRESS;
168
+ }
169
+
170
+ /**
171
+ * Returns true, if current shipping method is a GLS "Foreign" shipping
172
+ * Otherwise, this function returns false
173
+ *
174
+ * @return bool
175
+ */
176
+ public function isForeignShipping() {
177
+ return $this->_getCurrentShipment()->getOrder()->getShippingMethod() == SynergeticAgency_Gls_Model_Carrier::CODE.'_'.SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_FOREIGNCOUNTRIES;
178
+ }
179
+
180
+ /**
181
+ * Returns true, if given country code(ISO-3166 Alpha 2) matches to the configured country of current store
182
+ * Returns false, if given country code(ISO-3166 Alpha 2) does nit match to the configured country of current store
183
+ *
184
+ * @param $countryCode
185
+ * @return bool
186
+ */
187
+ public function matchCountry( $countryCode ) {
188
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
189
+ return strtoupper( $storeCountry ) === strtoupper( $countryCode );
190
+ }
191
+
192
+ /**
193
+ * Determine "Shipment to parcelshop"
194
+ * Returns true, if parcelshopId is set in shipment address of current shipment
195
+ * Returns false, if parcelshopId is not set or NULL in shipment address of current shipment
196
+ *
197
+ * @return bool
198
+ */
199
+ public function isParcelshopDelivery() {
200
+ $parcelShopId = $this->_getCurrentShipment()->getShippingAddress()->getParcelshopId();
201
+ return !empty($parcelShopId);
202
+ }
203
+
204
+ /**
205
+ * Returns true, if payment method of current shipping is an instance of SynergeticAgency_Gls_Model_Glscashondelivery
206
+ * Returns false, if payment method of current shipping is not an instance of SynergeticAgency_Gls_Model_Glscashondelivery
207
+ *
208
+ * @return bool
209
+ */
210
+ public function isCashService() {
211
+ $shipment = $this->_getCurrentShipment();
212
+ if($shipment) {
213
+ if($shipment->getOrder()->getPayment()->getMethodInstance() instanceof SynergeticAgency_Gls_Model_Glscashondelivery) {
214
+ return true;
215
+ }
216
+ }
217
+ return false;
218
+ }
219
+
220
+ /**
221
+ * Returns the configured "gls/shipment/default_combination" code as integer value.
222
+ * Otherwise, this function returns integer value 0
223
+ *
224
+ * @return int
225
+ */
226
+ public function getDefaultCombination() {
227
+ $defaultCombination = (int)Mage::getStoreConfig('gls/shipment/default_combination', $this->getStore());
228
+ return $defaultCombination ? $defaultCombination : 0;
229
+ }
230
+
231
+ /**
232
+ * Returns the configured "gls/shipment/default_services" representation as a JSON formatted string
233
+ *
234
+ * @return string
235
+ */
236
+ public function getDefaultServices() {
237
+ $jsonReturn = '[]';
238
+ $defaultServices = Mage::getStoreConfig('gls/shipment/default_services', $this->getStore());
239
+ if(!empty($defaultServices)) {
240
+ $defaultServices = explode(',',$defaultServices);
241
+ foreach ($defaultServices as &$defaultService) {
242
+ $defaultService = intval($defaultService);
243
+ }
244
+ $jsonReturn = Mage::helper('core')->jsonEncode($defaultServices);
245
+ }
246
+ return $jsonReturn;
247
+ }
248
+
249
+ /**
250
+ * Returns SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY or even SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY
251
+ * in respect to the return value of the function $this->isDomestic()
252
+ *
253
+ * @return int
254
+ */
255
+ public function getParcelShopCombinationId() {
256
+ return $this->isDomestic() ? SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY : SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY;
257
+ }
258
+
259
+ /**
260
+ * Returns an array containing the GLS addon services
261
+ * @return array
262
+ */
263
+ public function getAddonServices() {
264
+ return Mage::getModel('synergeticagency_gls/gls')->addonServicesToOptionArray(false,true);
265
+ }
266
+
267
+ /**
268
+ * Returns the maximun weight float value under several circumstances such as
269
+ * "isDomestic" and/or "isParcelshopDelivery", etc.
270
+ *
271
+ * @return float
272
+ */
273
+ public function getMaxWeight() {
274
+ $jsonModel = Mage::getModel('synergeticagency_gls/jsonimport');
275
+ $fieldName = 'maxweight';
276
+ $originCountryId = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
277
+ $shipToCountryId = $this->_getCurrentShipment()->getShippingAddress()->getCountryId();
278
+ if($this->isParcelshopDelivery()) {
279
+ $fieldName = 'parcelshopweight';
280
+ }
281
+ if($this->isDomestic()) {
282
+ $maxWeight = $jsonModel->getDomesticValueByOriginCountryId($originCountryId,$fieldName);
283
+ } else {
284
+ $maxWeight = $jsonModel->getForeignValueByOriginAndForeignCountryId($originCountryId,$shipToCountryId,$fieldName);
285
+ }
286
+ return $maxWeight;
287
+ }
288
+
289
+ /**
290
+ * Returns the configured store country config representation as a JSON formatted string if there is a GLS country id available
291
+ *
292
+ * @return string
293
+ */
294
+ public function getCountriesJson() {
295
+ $shipment = $this->_getCurrentShipment();
296
+ $jsonData = '{}';
297
+ if($shipment) {
298
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
299
+ $glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
300
+ if($glsCountry->getId()) {
301
+ $jsonData = Mage::helper('core')->jsonEncode($glsCountry->getData());
302
+ }
303
+ }
304
+ return $jsonData;
305
+ }
306
+
307
+ /**
308
+ * Gets Json Config for specific origin country supplied by GLS
309
+ * Returns an specific origin country supplied by GLS representation as a JSON formatted string
310
+ *
311
+ * @return string
312
+ */
313
+ public function getJsonConfig() {
314
+ $shipment = $this->_getCurrentShipment();
315
+ $jsonData = '{}';
316
+ if($shipment) {
317
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
318
+ $this->getStore());
319
+ /** @var Zend_Config_Json $jsonConfig */
320
+ $jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
321
+ if($jsonConfig) {
322
+ $writer = new Zend_Config_Writer_Json();
323
+ $writer->setConfig($jsonConfig);
324
+ $jsonData = $writer->render();
325
+ }
326
+ }
327
+ return $jsonData;
328
+ }
329
+
330
+ /**
331
+ * Returns the delivery country of the current shipment
332
+ *
333
+ * @return string
334
+ */
335
+ public function getTargetCountry() {
336
+ return $this->_getCurrentShipment()->getShippingAddress()->getCountryId();;
337
+ }
338
+
339
+ /**
340
+ * Returns true, if the country of current shipment equals to the country defined for the current store
341
+ *
342
+ * @return bool|null
343
+ */
344
+ public function isDomestic() {
345
+ $shipment = $this->_getCurrentShipment();
346
+ $return = null;
347
+ if($shipment) {
348
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
349
+ $destCountry = $shipment->getShippingAddress()->getCountryId();
350
+ $return = $storeCountry == $destCountry;
351
+ }
352
+ return $return;
353
+ }
354
+
355
+ /**
356
+ * Returns the Mage_Core_Model_Store object of the current shipment
357
+ *
358
+ * @return Mage_Core_Model_Store
359
+ */
360
+ private function getStore() {
361
+ return $this->_getCurrentShipment()->getStore();
362
+ }
363
+
364
+ /**
365
+ * Returns a Mage_Sales_Model_Order_Shipment object
366
+ *
367
+ * @return Mage_Sales_Model_Order_Shipment
368
+ */
369
+ private function _getCurrentShipment() {
370
+
371
+ return Mage::registry('current_shipment');
372
+ }
373
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Gls/Packages.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Order\Shipment\Create\Gls
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls_Packages
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Gls_Packages extends Mage_Adminhtml_Block_Widget {
26
+ /**
27
+ * Construtor
28
+ */
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+ $this->setTemplate('gls/sales/order/shipment/create/gls/packages.phtml');
33
+ }
34
+
35
+ /**
36
+ * Get final order amount
37
+ * @return string
38
+ */
39
+ public function getCashAmount() {
40
+ return $this->getStore()->roundPrice($this->_getCurrentShipment()->getOrder()->getGrandTotal());
41
+ }
42
+
43
+ /**
44
+ * Get order currency
45
+ * @return string
46
+ */
47
+ public function getCurrency() {
48
+ return $this->_getCurrentShipment()->getOrder()->getBaseCurrency()->getCurrencyCode();
49
+ }
50
+
51
+ /**
52
+ * Get default weight.
53
+ * @return float
54
+ */
55
+ public function getWeight()
56
+ {
57
+ $weight = 0;
58
+ $items = $this->_getCurrentShipment()->getAllItems();
59
+ if(count($items)) {
60
+ foreach($items as $item) {
61
+ $weight += $item->getWeight() * $item->getQty();
62
+ }
63
+ }
64
+ if(empty($weight)) {
65
+ $weight = $this->getDefaultWeight();
66
+ }
67
+ return $weight;
68
+ }
69
+
70
+ /**
71
+ * Get default weight.
72
+ * @return float
73
+ */
74
+ public function getDefaultWeight()
75
+ {
76
+ return Mage::getStoreConfig('gls/shipment/weight', $this->getStore());
77
+ }
78
+
79
+ /**
80
+ * Verify if payment is gls cash on delivery
81
+ * @return bool
82
+ */
83
+ public function isCashService() {
84
+ $shipment = $this->_getCurrentShipment();
85
+ if($shipment) {
86
+ if($shipment->getOrder()->getPayment()->getMethodInstance() instanceof SynergeticAgency_Gls_Model_Glscashondelivery) {
87
+ return true;
88
+ }
89
+ }
90
+ return false;
91
+ }
92
+
93
+ /**
94
+ * Get shipments store
95
+ * @return Mage_Core_Model_Store
96
+ */
97
+ public function getStore() {
98
+ return $this->_getCurrentShipment()->getStore();
99
+ }
100
+
101
+ /**
102
+ * Getting the current watched shipment from mage registry
103
+ * @return Mage_Sales_Model_Order_Shipment
104
+ */
105
+ private function _getCurrentShipment() {
106
+ return Mage::registry('current_shipment');
107
+ }
108
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/Create/Tracking.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Order\Shipment\Create
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Tracking
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Tracking extends Mage_Adminhtml_Block_Sales_Order_Shipment_Create_Tracking {
26
+
27
+ /**
28
+ * Extend tracking block to attach gls form.
29
+ *
30
+ * @return string
31
+ */
32
+ public function _toHtml()
33
+ {
34
+ $store = $this->getShipment()->getStore();
35
+ if (!Mage::getStoreConfig('gls/general/active' , $store)) {
36
+ return parent::_toHtml();
37
+ }
38
+
39
+ /** @var Mage_Core_Block_Abstract $block */
40
+ $block = $this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_order_shipment_create_gls','gls_parcel_form');
41
+ $block->setChild('packages', $this->getLayout()->createBlock(
42
+ 'synergeticagency_gls/adminhtml_sales_order_shipment_create_gls_packages',
43
+ 'packages_form'));
44
+ return parent::_toHtml() . $block->_toHtml();
45
+ }
46
+
47
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/View/Gls.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Order\Shipment\View
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_View_Gls
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_View_Gls extends Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form {
26
+
27
+
28
+ /**
29
+ * The Constructor initiates the template for the used Mage_Adminhtml_Block_Sales_Order_Shipment_View_Form
30
+ */
31
+ public function _construct()
32
+ {
33
+ $this->setTemplate('gls/sales/order/shipment/view/gls.phtml');
34
+ parent::_construct();
35
+ }
36
+
37
+
38
+ /**
39
+ * Returns the shipment model by the current shipment id
40
+ *
41
+ * @return SynergeticAgency_Gls_Model_Shipment
42
+ */
43
+ public function getGlsShipment()
44
+ {
45
+ return Mage::getModel('synergeticagency_gls/shipment')->load( $this->getShipment()->getId(), 'shipment_id');
46
+ }
47
+
48
+ /**
49
+ * Returns the orders currency code of the current shipment
50
+ *
51
+ * @return string
52
+ */
53
+ public function getCurrency() {
54
+ return $this->getShipment()->getOrder()->getBaseCurrency()->getCurrencyCode();
55
+ }
56
+
57
+ /**
58
+ * Returns a formatted price of the current shipment in respect of the orders store configuration
59
+ *
60
+ * @param $price
61
+ * @return mixed
62
+ */
63
+ public function formatPrice($price) {
64
+ return $this->getShipment()->getStore()->formatPrice($this->getShipment()->getStore()->roundPrice($price));
65
+ }
66
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Shipment/View/Tracking.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Adminhtml\Sales\Order\Shipment\View
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_View_Tracking
24
+ */
25
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_View_Tracking extends Mage_Adminhtml_Block_Sales_Order_Shipment_View_Tracking {
26
+ /**
27
+ * Extend tracking block to attach gls form.
28
+ *
29
+ * @return string
30
+ */
31
+ public function _toHtml()
32
+ {
33
+ $store = $this->getShipment()->getStore();
34
+ if (!Mage::getStoreConfig('gls/general/active' , $store)) {
35
+ return parent::_toHtml();
36
+ }
37
+
38
+ /** @var Mage_Core_Block_Abstract $block */
39
+ $block = $this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_order_shipment_view_gls', 'packages_form');
40
+ return parent::_toHtml() . $block->_toHtml();
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/Sales/Order/Template/Grid/Renderer/Order.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Template_Grid_Renderer_Order extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
3
+ {
4
+ /**
5
+ * Assign custom value to Mage_Adminhtml_Block_Sales_Order_Grid real_order_id column
6
+ * @param Varien_Object $row
7
+ * @return string
8
+ */
9
+ public function render(Varien_Object $row)
10
+ {
11
+ return $this->_getValue($row);
12
+ }
13
+
14
+ /**
15
+ * Assemble custom value for Mage_Adminhtml_Block_Sales_Order_Grid real_order_id column
16
+ * @param Varien_Object $row
17
+ * @return string
18
+ */
19
+ protected function _getValue(Varien_Object $row)
20
+ {
21
+ $glsLogo = '';
22
+ $orderId = $row->getData($this->getColumn()->getIndex());
23
+ $logoWwwPath = Mage::getDesign()->getSkinUrl('images/gls/logo_thumb.png');
24
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
25
+ $glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($order->getId(),'order_id');
26
+
27
+ if(strstr($order->getShippingMethod(),'synergeticagency_gls') || $glsShipment->getId()){
28
+ $glsLogo = ' <img src="'.$logoWwwPath.'" alt="'.$this->__('GLS Shipment').'" title="'.$this->__('GLS Shipment').'" />';
29
+ }
30
+
31
+ return $orderId.$glsLogo;
32
+ }
33
+ }
app/code/community/SynergeticAgency/Gls/Block/Adminhtml/System/Config/Note.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Helper
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @category SynergeticAgency
29
+ * @package SynergeticAgency_Gls
30
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
31
+ */
32
+
33
+ class SynergeticAgency_Gls_Block_Adminhtml_System_Config_Note extends Mage_Adminhtml_Block_Abstract
34
+ implements Varien_Data_Form_Element_Renderer_Interface
35
+ {
36
+ /**
37
+ * Template
38
+ * @var string
39
+ */
40
+ protected $_template = 'gls/system/config/note.phtml';
41
+
42
+ /**
43
+ * Render html
44
+ *
45
+ * @param Varien_Data_Form_Element_Abstract $fieldset
46
+ * @return string
47
+ */
48
+ public function render(Varien_Data_Form_Element_Abstract $fieldset)
49
+ {
50
+ $this->addData($fieldset->getOriginalData());
51
+ $this->setData('agency_logo_url',Mage::getDesign()->getSkinUrl('images/gls/gls-logo.png'));
52
+ return $this->toHtml();
53
+ }
54
+ }
app/code/community/SynergeticAgency/Gls/Block/Checkout/Onepage/Parcelshop.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Checkout\Onepage
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Checkout_Onepage_Parcelshop
24
+ */
25
+ class SynergeticAgency_Gls_Block_Checkout_Onepage_Parcelshop
26
+ extends Mage_Core_Block_Template
27
+ {
28
+
29
+ /**
30
+ * Internal constructor, that is called from real constructor.
31
+ */
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+ }
36
+
37
+ /**
38
+ * determines, if GLS parcelshop option is active, see also store configuration "gls/parcel_shop/parcel_shop_enabled"
39
+ * @return mixed
40
+ */
41
+ public function isActive() {
42
+ return Mage::getStoreConfig('gls/parcel_shop/parcel_shop_enabled', Mage::app()->getStore());
43
+ }
44
+
45
+ /**
46
+ * get country config as json
47
+ * @return string
48
+ */
49
+ public function getCountriesJson() {
50
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, Mage::app()->getStore());
51
+ $glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
52
+ $jsonData = '{}';
53
+ if($glsCountry->getId()) {
54
+ $jsonData = Mage::helper('core')->jsonEncode($glsCountry->getData());
55
+ }
56
+ return $jsonData;
57
+ }
58
+
59
+ /**
60
+ * Gets Json Config for specific origin country supplied by gls
61
+ * @return string
62
+ */
63
+ public function getJsonConfig() {
64
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, Mage::app()->getStore());
65
+ /** @var Zend_Config_Json $jsonConfig */
66
+ $jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
67
+ $jsonData = '{}';
68
+ if($jsonConfig) {
69
+ $writer = new Zend_Config_Writer_Json();
70
+ $writer->setConfig($jsonConfig);
71
+ $jsonData = $writer->render();
72
+ }
73
+ return $jsonData;
74
+ }
75
+
76
+ }
app/code/community/SynergeticAgency/Gls/Block/Checkout/Onepage/Parcelshop/Map.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Checkout\Onepage\Parcelshop
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Checkout_Onepage_Parcelshop_Map
24
+ */
25
+ class SynergeticAgency_Gls_Block_Checkout_Onepage_Parcelshop_Map
26
+ extends Mage_Core_Block_Template
27
+ {
28
+
29
+ /**
30
+ * Internal constructor, that is called from real constructor.
31
+ *
32
+ *
33
+ */
34
+ protected function _construct()
35
+ {
36
+ parent::_construct();
37
+ }
38
+
39
+ }
app/code/community/SynergeticAgency/Gls/Block/Form/Glscashondelivery.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Block\Form
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Block_Form_Glscashondelivery
24
+ */
25
+ class SynergeticAgency_Gls_Block_Form_Glscashondelivery extends Mage_Payment_Block_Form {
26
+
27
+ /**
28
+ * Instructions text
29
+ *
30
+ * @var string
31
+ */
32
+ protected $_instructions;
33
+
34
+ /**
35
+ * Block construction. Set block template.
36
+ */
37
+ protected function _construct()
38
+ {
39
+
40
+ parent::_construct();
41
+ $this->setTemplate('gls/form/glscashondelivery.phtml');
42
+ }
43
+
44
+ /**
45
+ * Get instructions text from config
46
+ *
47
+ * @return string
48
+ */
49
+ public function getInstructions()
50
+ {
51
+ if (is_null($this->_instructions)) {
52
+ $this->_instructions = $this->getMethod()->getInstructions();
53
+ }
54
+ return $this->_instructions;
55
+ }
56
+
57
+ }
app/code/community/SynergeticAgency/Gls/Helper/Data.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Helper
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS helper data
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Helper_Data extends Mage_Core_Helper_Abstract {
35
+
36
+ /**
37
+ * Constant for the store config xml path name "carriers"
38
+ */
39
+ const XML_PATH_SHIPPING_METHODS = 'carriers';
40
+
41
+ /**
42
+ * Get underlineToCamelCase string
43
+ * @param $string
44
+ * @param bool $capitalizeFirstCharacter
45
+ * @return mixed
46
+ */
47
+ function underlineToCamelCase($string, $capitalizeFirstCharacter = false)
48
+ {
49
+ $str = str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
50
+
51
+ if (!$capitalizeFirstCharacter) {
52
+ $str[0] = strtolower($str[0]);
53
+ }
54
+
55
+ return $str;
56
+ }
57
+
58
+ /**
59
+ * Get available GLS shipping methods
60
+ * @return array
61
+ * @param bool $sorted
62
+ * @param bool $asLabelValue
63
+ * @param bool $store
64
+ */
65
+ public function getShippingMethodList($sorted = true, $asLabelValue = false, $store = null) {
66
+ $methods = array();
67
+
68
+ foreach ($this->getShippingMethods($store) as $code => $data) {
69
+ if ((isset($data['title']))) {
70
+ $methods[$code] = $data['title'];
71
+ } else {
72
+ if ($this->getMethodInstance($code)) {
73
+ $methods[$code] = $this->getMethodInstance($code)->getConfigData('title', $store);
74
+ }
75
+ }
76
+ }
77
+
78
+ if ($sorted) {
79
+ asort($methods);
80
+ }
81
+ if ($asLabelValue) {
82
+ $labelValues = array();
83
+ foreach ($methods as $code => $title) {
84
+ $labelValues[$code] = array();
85
+ }
86
+ foreach ($methods as $code => $title) {
87
+ $labelValues[$code] = array('value' => $code, 'label' => $title);
88
+ }
89
+ return $labelValues;
90
+ }
91
+
92
+ return $methods;
93
+ }
94
+
95
+ /**
96
+ * Get full magento configuration for shipping GLS method
97
+ * @param null $store
98
+ * @return mixed
99
+ */
100
+ public function getShippingMethods($store = null)
101
+ {
102
+ $shippingConfig = Mage::getStoreConfig(self::XML_PATH_SHIPPING_METHODS, $store);
103
+ unset($shippingConfig['synergeticagency_gls']);
104
+ return $shippingConfig;
105
+ }
106
+
107
+ /**
108
+ * Check all config settings (Basiskonfiguration) for validity including if extension is active
109
+ * @return mixed true if everything is valid.
110
+ * array containing the error list if at least one configuration is not valid
111
+ */
112
+ public function checkConfigSettings() {
113
+
114
+ $returnValue = true;
115
+ $errorList = array();
116
+ $generalGlsConfig = $this->getGeneralGlsConfig();
117
+
118
+ foreach( $generalGlsConfig AS $key => $value ){
119
+ switch ($key) {
120
+ case "active":
121
+ if( !preg_match("/^[0-1]$/", $value) ){
122
+ $returnValue = false;
123
+ $errorList["active"] = Mage::helper('synergeticagency_gls')->__('Value not allowed: ') . $value;
124
+ }
125
+ break;
126
+ case "sandbox":
127
+ if( !preg_match("/^[0-1]$/", $value) ){
128
+ $returnValue = false;
129
+ $errorList["sandbox"] = Mage::helper('synergeticagency_gls')->__('Value not allowed: ') . $value;
130
+ }
131
+ break;
132
+ case "logging_enabled":
133
+ if( !preg_match("/^[0-1]$/", $value) ){
134
+ $returnValue = false;
135
+ $errorList["logging_enabled"] = Mage::helper('synergeticagency_gls')->__('Value not allowed: ') . $value;
136
+ }
137
+ break;
138
+ case "debug_enabled":
139
+ if( !preg_match("/^[0-1]$/", $value) ){
140
+ $returnValue = false;
141
+ $errorList["debug_enabled"] = Mage::helper('synergeticagency_gls')->__('Value not allowed: ') . $value;
142
+ }
143
+ break;
144
+ case "connector_log_enabled":
145
+ if( !preg_match("/^[0-1]$/", $value) ){
146
+ $returnValue = false;
147
+ $errorList["connector_log_enabled"] = Mage::helper('synergeticagency_gls')->__('Value not allowed: ') . $value;
148
+ }
149
+ break;
150
+ case "api_url":
151
+ if( empty($value) ){
152
+ $returnValue = false;
153
+ $errorList["api_url"] = Mage::helper('synergeticagency_gls')->__('Not set or empty') . ":" . var_export($value, 1);
154
+ }
155
+ break;
156
+ case "json_url":
157
+ if(empty($value) ){
158
+ $returnValue = false;
159
+ $errorList["json_url"] = Mage::helper('synergeticagency_gls')->__('Not set or empty');
160
+ }
161
+ break;
162
+ case "tracking_url":
163
+ if( empty($value) ){
164
+ $returnValue = false;
165
+ $errorList["tracking_url"] = Mage::helper('synergeticagency_gls')->__('Not set or empty');
166
+ }
167
+ break;
168
+ case "username":
169
+ if( empty($value) ){
170
+ $returnValue = false;
171
+ $errorList["username"] = Mage::helper('synergeticagency_gls')->__('Not set or empty');
172
+ }
173
+ break;
174
+ case "password":
175
+ if( empty($value) ){
176
+ $returnValue = false;
177
+ $errorList["password"] = Mage::helper('synergeticagency_gls')->__('Not set or empty');
178
+ }
179
+ break;
180
+ case "customer_id":
181
+ if( empty($value) ){
182
+ $returnValue = false;
183
+ $errorList["customer_id"] = Mage::helper('synergeticagency_gls')->__('Not set or empty');
184
+ }
185
+ break;
186
+ case "contact_id":
187
+ if( empty($value) ){
188
+ $returnValue = false;
189
+ $errorList["contact_id"] = Mage::helper('synergeticagency_gls')->__('Not set or empty');
190
+ }
191
+ break;
192
+ }
193
+ }
194
+
195
+ if( $returnValue === false ){
196
+ $returnValue = $errorList;
197
+ }
198
+
199
+ return $returnValue;
200
+ }
201
+
202
+ /**
203
+ * Checks, if alternative shipper data is complete and valid
204
+ * @param Mage_Core_Model_Store $store
205
+ * @return bool
206
+ */
207
+ public function checkAlternativeShipper($store) {
208
+ $checkFields = array(
209
+ 'name1',
210
+ 'street1',
211
+ 'country',
212
+ 'zip_code',
213
+ 'city',
214
+ );
215
+ foreach($checkFields as $checkField) {
216
+ $fieldValue = Mage::getStoreConfig('gls/alternative_shipper/'.$checkField,$store);
217
+ $fieldValue = trim($fieldValue);
218
+ if(empty($fieldValue)) {
219
+ return false;
220
+ }
221
+ }
222
+ return true;
223
+ }
224
+
225
+
226
+ /**
227
+ * Checks, if return address data is complete and valid
228
+ * @param Mage_Core_Model_Store $store
229
+ * @return bool
230
+ */
231
+ public function checkReturnAddress($store) {
232
+ $checkFields = array(
233
+ 'name1',
234
+ 'street1',
235
+ 'country',
236
+ 'zip_code',
237
+ 'city',
238
+ );
239
+ foreach($checkFields as $checkField) {
240
+ $fieldValue = Mage::getStoreConfig('gls/return_address/'.$checkField,$store);
241
+ $fieldValue = trim($fieldValue);
242
+ if(empty($fieldValue)) {
243
+ return false;
244
+ }
245
+ }
246
+ return true;
247
+ }
248
+
249
+ /**
250
+
251
+ * @return mixed
252
+ */
253
+
254
+ /**
255
+ * Get magento GLS configuration defined by $key
256
+ * Get complete magento GLS configuration if $key is not set
257
+ *
258
+ * @param null $key
259
+ * @return mixed
260
+ */
261
+ public function getGeneralGlsConfig( $key = NULL )
262
+ {
263
+ $returnValue = Mage::getStoreConfig(
264
+ 'gls/general',
265
+ Mage::app()->getStore()
266
+ );
267
+
268
+ if( $key !== NULL && isset($returnValue[$key]) ){
269
+ $returnValue = $returnValue[$key];
270
+ }
271
+ return $returnValue;
272
+ }
273
+
274
+
275
+ /**
276
+ * Get magento GLS shipment configuration defined by $key
277
+ * Get complete magento GLS shipment configuration if $key is not set
278
+ *
279
+ * @param null $key
280
+ * @return mixed
281
+ */
282
+ public function getShipmentGlsConfig( $key = NULL )
283
+ {
284
+ $returnValue = Mage::getStoreConfig(
285
+ 'gls/shipment',
286
+ Mage::app()->getStore()
287
+ );
288
+
289
+ if( $key !== NULL && isset($returnValue[$key]) ){
290
+ $returnValue = $returnValue[$key];
291
+ }
292
+ return $returnValue;
293
+ }
294
+
295
+ /**
296
+ * returns current version number of gls extension
297
+ * @return string
298
+ */
299
+ public function getExtensionVersion()
300
+ {
301
+ return (string) Mage::getConfig()->getNode()->modules->SynergeticAgency_Gls->version;
302
+ }
303
+ }
app/code/community/SynergeticAgency/Gls/Helper/Log.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Helper
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS helper data
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Helper_Log extends Mage_Core_Helper_Abstract {
35
+
36
+ const GLS_LOG_FILE_NAME = "SynergeticAgency_Gls.log";
37
+ const GLS_API_LOG_FILE_NAME = "SynergeticAgency_GlsApi.log";
38
+
39
+ /**
40
+ * Container, if logging should be forced or not
41
+ *
42
+ * @var bool
43
+ */
44
+ var $forceLog = false;
45
+
46
+ /**
47
+ * If gls/general/debug_enabled is enabled or the given level not equals to Zend_Log::DEBUG,
48
+ * this function logs all messages into the $this::GLS_LOG_FILE_NAME file
49
+ *
50
+ * @param $method
51
+ * @param $line
52
+ * @param $message
53
+ * @param int $level
54
+ */
55
+ public function log( $method, $line, $message, $level = Zend_Log::DEBUG ){
56
+ if( Mage::getStoreConfig('gls/general/debug_enabled') || $level !== Zend_Log::DEBUG ){
57
+ $message = $method . " @ line " . $line . ": " . $message;
58
+ Mage::log( $message, $level, $this::GLS_LOG_FILE_NAME, $this->isForceLog() );
59
+ }
60
+ }
61
+
62
+ /**
63
+ * If the configuration "gls/general/debug_enabled" is set to '1' or the given level not equals to Zend_Log::DEBUG,
64
+ * this function logs all messages into the $this::GLS_API_LOG_FILE_NAME file
65
+ *
66
+ * @param $method
67
+ * @param $line
68
+ * @param $message
69
+ * @param int $level use corresponding Zend_Log levels such as DEBUG, ERR, ALERT, etc
70
+ */
71
+ public function logApi( $method, $line, $message, $level = Zend_Log::DEBUG ){
72
+ if( Mage::getStoreConfig('gls/general/debug_enabled') == '1' || $level !== Zend_Log::DEBUG ){
73
+ $message = $method . " @ line " . $line . ": " . $message;
74
+ Mage::log( $message, $level, $this::GLS_API_LOG_FILE_NAME, $this->isForceLog() );
75
+ }
76
+ }
77
+
78
+ /**
79
+ * If the configuration "gls/general/debug_enabled" is set to '1',
80
+ * this function logs all messages into the $this::GLS_API_LOG_FILE_NAME file
81
+ * and adds an Error into magentos session with several information about the exception
82
+ *
83
+ * @param Exception $e
84
+ * @param $method
85
+ * @param $line
86
+ * @param $level
87
+ * @param $message
88
+ * @param $code
89
+ */
90
+ public function logException( Exception $e, $method, $line, $level, $message, $code ){
91
+
92
+ $exceptionMessage = "";
93
+ if( Mage::getStoreConfig('gls/general/debug_enabled') ){
94
+ $exceptionMessage = sprintf(Mage::helper('synergeticagency_gls')->__('(Exception: %s)'), $e->getMessage()) . " ";
95
+ }
96
+ Mage::getSingleton('adminhtml/session')->addError(
97
+ Mage::helper('synergeticagency_gls')->__($message) . " " .
98
+ $exceptionMessage .
99
+ sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), $code)
100
+ );
101
+ $this->log( $method, $line, "Exception: " . $e->getMessage(), $level );
102
+ }
103
+
104
+
105
+
106
+ /**
107
+ * Getter function for the member var forceLog
108
+ * @return boolean
109
+ */
110
+ public function isForceLog() {
111
+ return $this->forceLog;
112
+ }
113
+
114
+ /**
115
+ * Setter function for the member var forceLog
116
+ *
117
+ * @param $forceLog
118
+ * @return $this
119
+ */
120
+ public function setForceLog($forceLog) {
121
+ $this->forceLog = (boolean)$forceLog;
122
+ return $this;
123
+ }
124
+ }
app/code/community/SynergeticAgency/Gls/Helper/Validate.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Helper
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * This class implements helper functions for the validation of several models, such as GLS shipment, etc.
29
+ * Class SynergeticAgency_Gls_Helper_Validate
30
+ */
31
+ class SynergeticAgency_Gls_Helper_Validate extends Mage_Core_Helper_Abstract {
32
+
33
+ /**
34
+ * Check if destination of current shipment is for other country than origin shipping country of current store
35
+ * @return bool|null
36
+ */
37
+ public function isDomestic() {
38
+ $shipment = SynergeticAgency_Gls_Helper_Validate::getCurrentShipment();
39
+ $return = null;
40
+ if($shipment) {
41
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
42
+ $destCountry = $shipment->getShippingAddress()->getCountryId();
43
+ $return = $storeCountry == $destCountry;
44
+ }
45
+ return $return;
46
+ }
47
+
48
+ /**
49
+ * Shipment to parcel shop? True if a parcel shop ID is given
50
+ * @return bool
51
+ */
52
+ public function isParcelshopDelivery() {
53
+ $parcelShopId = SynergeticAgency_Gls_Helper_Validate::getCurrentShipment()->getShippingAddress()->getParcelshopId();
54
+ return !empty($parcelShopId);
55
+ }
56
+
57
+ /**
58
+ * Gets Json Config for specific origin country supplied by gls
59
+ * @return string
60
+ */
61
+ public function getJsonConfig() {
62
+ $jsonData = '{}';
63
+ $jsonConfig = '{}';
64
+ if(SynergeticAgency_Gls_Helper_Validate::getCurrentShipment()) {
65
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
66
+ $this->getStore());
67
+
68
+ $jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
69
+ if($jsonConfig) {
70
+ $writer = new Zend_Config_Writer_Json();
71
+ $writer->setConfig($jsonConfig);
72
+ $jsonData = $writer->render();
73
+ }
74
+ }
75
+ return $jsonData;
76
+ }
77
+
78
+ /**
79
+ * Gets config for specific origin country supplied by gls
80
+ * @return string
81
+ */
82
+ public function getConfig() {
83
+ $jsonConfig = '';
84
+ if(SynergeticAgency_Gls_Helper_Validate::getCurrentShipment()) {
85
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
86
+ $this->getStore());
87
+
88
+ $jsonConfig = Mage::getModel('synergeticagency_gls/jsonimport')->getCountry($storeCountry);
89
+
90
+ }
91
+ return $jsonConfig;
92
+ }
93
+
94
+ /**
95
+ * get country config as json
96
+ * @return string
97
+ */
98
+ public function getCountriesJson() {
99
+ $shipment = SynergeticAgency_Gls_Helper_Validate::getCurrentShipment();
100
+ $jsonData = '{}';
101
+ if($shipment) {
102
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $this->getStore());
103
+ $glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
104
+ if($glsCountry->getId()) {
105
+ $jsonData = Mage::helper('core')->jsonEncode($glsCountry->getData());
106
+ }
107
+ }
108
+ return $jsonData;
109
+ }
110
+
111
+ /**
112
+ * get country config
113
+ * @return string
114
+ */
115
+ public function getCountriesConfig() {
116
+ $shipment = SynergeticAgency_Gls_Helper_Validate::getCurrentShipment();
117
+ if($shipment) {
118
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, SynergeticAgency_Gls_Helper_Validate::getStore());
119
+ $glsCountry = Mage::getModel('synergeticagency_gls/country')->load($storeCountry);
120
+ }
121
+ return $glsCountry;
122
+ }
123
+
124
+ /**
125
+ * get a (service) combination by id
126
+ * @param $countryConfigOptions
127
+ * @param $combinationId
128
+ * @return bool
129
+ */
130
+ public function getCombinationByCombinationId($countryConfigOptions, $combinationId){
131
+ $combination = false;
132
+ foreach($countryConfigOptions AS $countryConfigOption){
133
+ if($countryConfigOption['combination'] == $combinationId){
134
+ $combination = $countryConfigOption;
135
+ }
136
+ }
137
+ return $combination;
138
+ }
139
+
140
+
141
+ /**
142
+ * Get the current shipment method. Shipment methods are actually combinations of gls services
143
+ * @return int
144
+ */
145
+ public function getParcelShopCombinationId() {
146
+ return SynergeticAgency_Gls_Helper_Validate::isDomestic() ? SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY : SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY;
147
+ }
148
+
149
+ /**
150
+ * Gets current delivery country
151
+ * @return string
152
+ */
153
+ public function getTargetCountry() {
154
+ return SynergeticAgency_Gls_Helper_Validate::getCurrentShipment()->getShippingAddress()->getCountryId();
155
+ }
156
+
157
+ /**
158
+ * is target delivery country allowed from source country
159
+ * @return bool
160
+ */
161
+ public function isAllowedTargetCountry(){
162
+
163
+ $config = SynergeticAgency_Gls_Helper_Validate::getConfig();
164
+
165
+ $countryValidator = new Zend_Validate_InArray(array_keys($config->foreign->countries));
166
+ return $countryValidator->isValid(SynergeticAgency_Gls_Helper_Validate::getTargetCountry());
167
+ }
168
+
169
+ /**
170
+ * get current shipment
171
+ * @return Mage_Sales_Model_Order_Shipment
172
+ */
173
+ public function getCurrentShipment() {
174
+ return Mage::registry('current_shipment');
175
+ }
176
+
177
+ /**
178
+ * Get current store
179
+ * @return Mage_Core_Model_Store
180
+ */
181
+ public function getStore() {
182
+ return SynergeticAgency_Gls_Helper_Validate::getCurrentShipment()->getStore();
183
+ }
184
+ }
app/code/community/SynergeticAgency/Gls/Model/Carrier.php ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class SynergeticAgency_Gls_Model_Carrier
29
+ */
30
+ class SynergeticAgency_Gls_Model_Carrier
31
+ extends Mage_Shipping_Model_Carrier_Abstract
32
+ implements Mage_Shipping_Model_Carrier_Interface
33
+ {
34
+ /**
35
+ * Code of the carrier
36
+ *
37
+ * @var string
38
+ */
39
+ const CODE = 'synergeticagency_gls';
40
+
41
+ /**
42
+ * Carrier's code, as defined in parent class
43
+ *
44
+ * @var string
45
+ */
46
+ protected $_code = self::CODE;
47
+
48
+ /**
49
+ * Rate request data
50
+ *
51
+ * @var Mage_Shipping_Model_Rate_Request|null
52
+ */
53
+ protected $_request = null;
54
+
55
+ /**
56
+ * Raw rate request data
57
+ *
58
+ * @var Varien_Object|null
59
+ */
60
+ protected $_rawRequest = null;
61
+
62
+ /**
63
+ * Rate result data
64
+ *
65
+ * @var Mage_Shipping_Model_Rate_Result|null
66
+ */
67
+ protected $_result = null;
68
+
69
+ /**
70
+ * Errors placeholder
71
+ *
72
+ * @var array
73
+ */
74
+ protected $_errors = array();
75
+
76
+ /**
77
+ * Shipping Methods
78
+ *
79
+ * @var array
80
+ */
81
+ protected $_shippingConfigKeys = array();
82
+
83
+ /**
84
+ * Full config container for for module synergeticagency_gls
85
+ *
86
+ * @var array
87
+ */
88
+ protected $_glsConfig = array();
89
+
90
+
91
+ /**
92
+ * The name of the standard shipping rate which is a GLS service combination
93
+ */
94
+ const SHIPPING_RATE_STANDARD = 'standard';
95
+ /**
96
+ * The name of the express shipping rate which is a GLS service combination
97
+ */
98
+ const SHIPPING_RATE_EXPRESS = 'express';
99
+ /**
100
+ * The name of the foreigncountries shipping rate which is a GLS service combination
101
+ */
102
+ const SHIPPING_RATE_FOREIGNCOUNTRIES = 'foreigncountries';
103
+ /**
104
+ * @TODO: check if the current value is correct
105
+ */
106
+ const CARRIER_TITLE = 'General Logistics Systems';
107
+
108
+
109
+ /**
110
+ * Returns available shipping rates for GLS Shipping carrier
111
+ *
112
+ * @param Mage_Shipping_Model_Rate_Request $request
113
+ * @return Mage_Shipping_Model_Rate_Result
114
+ */
115
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
116
+ {
117
+ if (!$this->getConfigFlag('active')) {
118
+ return false;
119
+ }
120
+ $this->_request = $request;
121
+
122
+ $result = Mage::getModel('shipping/rate_result');
123
+ $store = Mage::app()->getStore();
124
+
125
+ //Getting full config for for module synergeticagency_gls */
126
+ $this->_glsConfig = Mage::getStoreConfig(
127
+ 'carriers/synergeticagency_gls',
128
+ $store
129
+ );
130
+
131
+ //$this->_shippingConfigKeys = preg_filter('/^name_(.*)/', '$1', array_keys($this->_glsConfig));
132
+
133
+ $this->_shippingConfigKeys = array('0'=>'foreigncountries','1'=>'express','2'=>'standard');
134
+
135
+ $hasResults = false;
136
+ foreach ($this->_shippingConfigKeys AS $deliveryConfigKey) {
137
+ //@todo check price and name here as well and if empty disable
138
+ if($this->_glsConfig['active_'.$deliveryConfigKey] == '1'){
139
+ /** @var _Shipping_Helper_Data $expressMaxProducts */
140
+ $methodName = '_get'.Mage::helper('synergeticagency_gls')->underlineToCamelCase($deliveryConfigKey, TRUE).'Rate';
141
+ if(method_exists($this, $methodName)) {
142
+ $methodResult = $this->{$methodName}();
143
+ if($methodResult !== false) {
144
+ $hasResults = true;
145
+ $result->append($methodResult);
146
+ }
147
+ }
148
+ }
149
+ }
150
+ if(!$hasResults) {
151
+ $result = false;
152
+ }
153
+ return $result;
154
+ }
155
+
156
+ /**
157
+ * Returns allowed shipping methods
158
+ * @return array
159
+ */
160
+ public function getAllowedMethods()
161
+ {
162
+ return array(
163
+ self::SHIPPING_RATE_STANDARD => $this->_glsConfig['name_'.self::SHIPPING_RATE_STANDARD],
164
+ self::SHIPPING_RATE_EXPRESS => $this->_glsConfig['name_'.self::SHIPPING_RATE_EXPRESS],
165
+ self::SHIPPING_RATE_FOREIGNCOUNTRIES => $this->_glsConfig['name_'.self::SHIPPING_RATE_FOREIGNCOUNTRIES],
166
+ );
167
+ }
168
+
169
+ /**
170
+ * Return all tracking for a shipment
171
+ * @param $tracking
172
+ * @return bool|false|Mage_Core_Model_Abstract
173
+ */
174
+ public function getTrackingInfo($tracking)
175
+ {
176
+ $result = $this->getTracking($tracking);
177
+
178
+ if ($result instanceof Mage_Shipping_Model_Tracking_Result) {
179
+ if ($trackings = $result->getAllTrackings()) {
180
+ return $trackings[0];
181
+ }
182
+ } elseif (is_string($result) && 0 < strlen($result)) {
183
+ return $result;
184
+ }
185
+
186
+ return false;
187
+ }
188
+
189
+ /**
190
+ * Get a trackings for shipment
191
+ * @param $trackings
192
+ * @return Mage_Shipping_Model_Tracking_Result
193
+ */
194
+ public function getTracking($trackings)
195
+ {
196
+ if (!is_array($trackings)) {
197
+ $trackings = array($trackings);
198
+ }
199
+
200
+ $result = Mage::getModel('shipping/tracking_result');
201
+ foreach ($trackings as $trackingNumber) {
202
+ $status = Mage::getModel('shipping/tracking_result_status');
203
+ $status->setCarrierTitle(self::CARRIER_TITLE);
204
+ $status->setCarrier(self::CODE);
205
+ $status->setTracking($trackingNumber);
206
+ $status->setPopup(true);
207
+ $status->setUrl(Mage::getStoreConfig('gls/general/tracking_url').$trackingNumber);
208
+ $result->append($status);
209
+ }
210
+
211
+ return $result;
212
+ }
213
+
214
+
215
+ /**
216
+ * Get Standard rate object
217
+ * @return Mage_Shipping_Model_Rate_Result_Method
218
+ * @internal param Mage_Shipping_Model_Rate_Request $request
219
+ */
220
+ protected function _getStandardRate()
221
+ {
222
+ /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
223
+ $rate = Mage::getModel('shipping/rate_result_method');
224
+
225
+ // shipping method is only available for domestic shipping
226
+ if(!$this->_isDomesticShipping($this->_request)) {
227
+ return false;
228
+ }
229
+
230
+ $rate->setCarrier($this->_code);
231
+ $rate->setCarrierTitle($this->getConfigData('title'));
232
+ $rate->setMethod(self::SHIPPING_RATE_STANDARD);
233
+ $rate->setMethodTitle($this->getConfigData('name_'.self::SHIPPING_RATE_STANDARD));
234
+ $rate->setPrice($this->getConfigData('price_per_order_'.self::SHIPPING_RATE_STANDARD));
235
+ $rate->setCost(0);
236
+
237
+ return $rate;
238
+ }
239
+
240
+ /**
241
+ * Get Express rate object
242
+ * @return Mage_Shipping_Model_Rate_Result_Method
243
+ * @internal param Mage_Shipping_Model_Rate_Request $request
244
+ */
245
+ protected function _getExpressRate()
246
+ {
247
+ /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
248
+ $rate = Mage::getModel('shipping/rate_result_method');
249
+
250
+ // shipping method is only available for specific countries, only domestic and not compatible with parcel shop delivery
251
+ if(!$this->_isDomesticShipping($this->_request) || !$this->_isAvailableCountryForExpress($this->_request) || $this->_isParcelShopDelivery($this->_request)) {
252
+ return false;
253
+ }
254
+
255
+ $rate->setCarrier($this->_code);
256
+ $rate->setCarrierTitle($this->getConfigData('title'));
257
+ $rate->setMethod(self::SHIPPING_RATE_EXPRESS);
258
+ $rate->setMethodTitle($this->getConfigData('name_'.self::SHIPPING_RATE_EXPRESS));
259
+ $rate->setPrice($this->getConfigData('price_per_order_'.self::SHIPPING_RATE_EXPRESS));
260
+ $rate->setCost(0);
261
+
262
+ return $rate;
263
+ }
264
+
265
+
266
+ /**
267
+ * Get Express rate object
268
+ * @return Mage_Shipping_Model_Rate_Result_Method
269
+ * @internal param Mage_Shipping_Model_Rate_Request $request
270
+ */
271
+ protected function _getForeigncountriesRate()
272
+ {
273
+ /** @var Mage_Shipping_Model_Rate_Result_Method $rate */
274
+ $rate = Mage::getModel('shipping/rate_result_method');
275
+
276
+ // shipping method is only available for specific countries and only domestic
277
+ if($this->_isDomesticShipping($this->_request) || !$this->_isAvailableCountryForForeign($this->_request)) {
278
+ return false;
279
+ }
280
+
281
+ $rate->setCarrier($this->_code);
282
+ $rate->setCarrierTitle($this->getConfigData('title'));
283
+ $rate->setMethod(self::SHIPPING_RATE_FOREIGNCOUNTRIES);
284
+ $rate->setMethodTitle($this->getConfigData('name_'.self::SHIPPING_RATE_FOREIGNCOUNTRIES));
285
+ $rate->setPrice($this->getConfigData('price_per_order_'.self::SHIPPING_RATE_FOREIGNCOUNTRIES));
286
+ $rate->setCost(0);
287
+
288
+ return $rate;
289
+ }
290
+
291
+ /**
292
+ * Verify if current checkout shipping address country is same as the shops origin shipping country
293
+ * @param Mage_Shipping_Model_Rate_Request $request
294
+ * @return bool
295
+ */
296
+ protected function _isDomesticShipping(Mage_Shipping_Model_Rate_Request $request) {
297
+ return $request->getDestCountryId() == Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId());
298
+ }
299
+
300
+ /**
301
+ * Verify if shipping address country is valid for SHIPPING_RATE_EXPRESS shipping rate
302
+ * @param Mage_Shipping_Model_Rate_Request $request
303
+ * @return bool
304
+ */
305
+ protected function _isAvailableCountryForExpress(Mage_Shipping_Model_Rate_Request $request) {
306
+ //TODO: get this information from a config
307
+ return $request->getDestCountryId() == 'DE';
308
+ }
309
+
310
+ /**
311
+ * Verify if shipping address country is allowed in by GLS
312
+ * @param Mage_Shipping_Model_Rate_Request $request
313
+ * @return bool
314
+ */
315
+ protected function _isAvailableCountryForForeign(Mage_Shipping_Model_Rate_Request $request) {
316
+ $gls = Mage::getModel('synergeticagency_gls/gls');
317
+ return($gls->isDestinationCountryAvailable(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()),$request->getDestCountryId()));
318
+ }
319
+
320
+ /**
321
+ * Verify if shipping address is a parcel shop
322
+ * Returning true if the request value parcelshop_id holds any value
323
+ * @param Mage_Shipping_Model_Rate_Request $request
324
+ * @return bool
325
+ */
326
+
327
+ protected function _isParcelShopDelivery(Mage_Shipping_Model_Rate_Request $request)
328
+ {
329
+ // TODO: extend Mage_Shipping_Model_Rate_Request with dest_parcelshopid
330
+ $getParams = Mage::app()->getRequest()->getParams();
331
+ $parcelShopId = '';
332
+ if (array_key_exists('shipping', $getParams) && array_key_exists('parcelshop_id', $getParams['shipping'])) {
333
+ $parcelShopId = $getParams['shipping']['parcelshop_id'];
334
+ }
335
+ return !empty($parcelShopId);
336
+ }
337
+
338
+ /**
339
+ * Verify if current stores shipping origin country is allowed by GLS and also by Magento shows the rate in dependency of result in checkout
340
+ * Overrides Mage_Shipping_Model_Carrier_Abstract checkAvailableShipCountries
341
+ * @param Mage_Shipping_Model_Rate_Request $request
342
+ * @return $this|bool
343
+ */
344
+ public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request)
345
+ {
346
+ // basic check if country origin is available for gls shipping
347
+ $gls = Mage::getModel('synergeticagency_gls/gls');
348
+ if(!$gls->isCountryOriginIdAvailable(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $request->getStoreId()))) {
349
+ return false;
350
+ }
351
+
352
+ $speCountriesAllow = $this->getConfigData('sallowspecific');
353
+ $showMethod = $this->getConfigData('showmethod');
354
+
355
+ //for specific countries, the flag will be 1
356
+ if ($speCountriesAllow && $speCountriesAllow == 1){
357
+ $availableCountries = array();
358
+ if($this->getConfigData('specificcountry')) {
359
+ $availableCountries = explode(',',$this->getConfigData('specificcountry'));
360
+ }
361
+
362
+ } else {
363
+ $availableCountries = explode(',', (string)Mage::getStoreConfig('general/country/allow'));
364
+ }
365
+
366
+ if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) {
367
+ return $this;
368
+ } elseif ($showMethod && (!$availableCountries || ($availableCountries
369
+ && !in_array($request->getDestCountryId(), $availableCountries)))
370
+ ){
371
+ $error = Mage::getModel('shipping/rate_result_error');
372
+ $error->setCarrier($this->_code);
373
+ $error->setCarrierTitle($this->getConfigData('title'));
374
+ $errorMsg = $this->getConfigData('specificerrmsg');
375
+ $error->setErrorMessage($errorMsg ? $errorMsg : Mage::helper('shipping')->__('The shipping module is not available for selected delivery country.'));
376
+ return $error;
377
+ } else {
378
+ //The admin set not to show the shipping module if the devliery country is not within specific countries
379
+ return false;
380
+ }
381
+ }
382
+ }
app/code/community/SynergeticAgency/Gls/Model/Combination.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Combination
24
+ */
25
+ class SynergeticAgency_Gls_Model_Combination extends Mage_Core_Model_Abstract {
26
+
27
+ /**
28
+ * Gls products i. e.: business parcel
29
+ * @var
30
+ */
31
+ private $_product;
32
+
33
+ /**
34
+ * Gls service i. e.: think green
35
+ * @var
36
+ */
37
+ private $_services;
38
+
39
+ /**
40
+ * Initialize resource model
41
+ *
42
+ */
43
+ protected function _construct() {
44
+ $this->_init('synergeticagency_gls/combination');
45
+ }
46
+
47
+ /**
48
+ * Loading products from GLS products configuration
49
+ * @return SynergeticAgency_Gls_Model_Product
50
+ */
51
+ public function getProduct() {
52
+ if(is_null($this->_product)) {
53
+ $this->_product = Mage::getModel('synergeticagency_gls/product')->load($this->getData('product'));
54
+ }
55
+ return $this->_product;
56
+ }
57
+
58
+ /**
59
+ * Loading services from GLS services configuration
60
+ * @return SynergeticAgency_Gls_Model_Resource_Service_Collection
61
+ */
62
+ public function getServices() {
63
+ $serviceIds = $this->getData('services');
64
+ if(is_null($this->_services) && !empty($serviceIds)) {
65
+ $this->_services = Mage::getModel('synergeticagency_gls/service')->getCollection()->setIdFilter($serviceIds)->load();
66
+ }
67
+ return $this->_services;
68
+ }
69
+
70
+ /**
71
+ * Get the name of a GLS service or product
72
+ * @return string
73
+ */
74
+ public function getName() {
75
+ $label = '';
76
+ $product = $this->getProduct();
77
+ $services = $this->getServices();
78
+ $servicesArray = array();
79
+ if(!empty($services)) {
80
+ foreach ($services as $service) {
81
+ $servicesArray[] = Mage::helper('synergeticagency_gls')->__($service->getName());
82
+ }
83
+ }
84
+ if($product && $product->getId()) {
85
+ $label = Mage::helper('synergeticagency_gls')->__($product->getName());
86
+ }
87
+ if(count($servicesArray)) {
88
+ $label .= ' + '.implode(' + ',$servicesArray);
89
+ }
90
+ return $label;
91
+ }
92
+ }
app/code/community/SynergeticAgency/Gls/Model/Country.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Country
24
+ */
25
+ class SynergeticAgency_Gls_Model_Country extends Mage_Core_Model_Abstract {
26
+
27
+ /**
28
+ * gls countries
29
+ * @var
30
+ */
31
+ private $_options;
32
+
33
+ /**
34
+ * Initialize resource model
35
+ *
36
+ */
37
+ protected function _construct() {
38
+ $this->_init('synergeticagency_gls/country');
39
+ }
40
+
41
+ /**
42
+ * get available combinations for country
43
+ * @return array
44
+ */
45
+ public function getOptions() {
46
+ $options = $this->getData('options');
47
+ if(is_null($this->_options) && !empty($options)) {
48
+ foreach($options as $option) {
49
+ if(empty($option['combination'])) continue;
50
+
51
+ $optionObject = new Varien_Object();
52
+ $optionObject->setCombination(Mage::getModel('synergeticagency_gls/combination')->load($option['combination']));
53
+ if(!empty($option['addon_services']) && is_array($option['addon_services'])) {
54
+ $optionObject->setAddonServices(Mage::getModel('synergeticagency_gls/service')->getCollection()->setIdFilter($option['addon_services'])->load());
55
+ }
56
+ $this->_options[] = $optionObject;
57
+ }
58
+ }
59
+ return $this->_options;
60
+ }
61
+ }
app/code/community/SynergeticAgency/Gls/Model/Gls.php ADDED
@@ -0,0 +1,543 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Gls
24
+ */
25
+ class SynergeticAgency_Gls_Model_Gls extends Mage_Core_Model_Abstract {
26
+
27
+ const COMB_BUSINESS_PARCEL = 1;
28
+ const COMB_BUSINESS_PARCEL_CASHSERVICE = 2;
29
+ const COMB_BUSINESS_PARCEL_GUARANTEED = 3;
30
+ const COMB_BUSINESS_PARCEL_SHOPDELIVERY = 4;
31
+ const COMB_EUROBUSINESS_PARCEL = 5;
32
+ const COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY = 6;
33
+
34
+ const PRODUCT_BUSINESS_PARCEL = 1;
35
+ const PRODUCT_EUROBUSINESS_PARCEL = 2;
36
+
37
+ const SERVICE_THINKGREEN = 1;
38
+ const SERVICE_FLEXDELIVERY = 2;
39
+ const SERVICE_EMAILNOTIFICATION = 3;
40
+ const SERVICE_PRIVATEDELIVERY = 4;
41
+ const SERVICE_CASHSERVICE = 5;
42
+ const SERVICE_GUARANTEED = 6;
43
+ const SERVICE_SHOPDELIVERY = 7;
44
+
45
+ /**
46
+ * Returns an array with available gls products available for inland shipping.
47
+ * A gls product in this module is a combination of gls services wrapped up to a product for better usability.
48
+ * In case $toKeyValue param is true the array keys are the combination id's from model (Zend configuration) instead of standard array index
49
+ * @param bool $toKeyValue
50
+ * @return array
51
+ */
52
+ public function nationalProductServiceCombinationsToOptionArray( $toKeyValue=false ) {
53
+ $options = array();
54
+ $combinations = Mage::getModel('synergeticagency_gls/combination')
55
+ ->getCollection()
56
+ ->addFilter('national',true)
57
+ ->load();
58
+
59
+ foreach($combinations as $combination) {
60
+ $label = $combination->getName();
61
+
62
+ if($toKeyValue) {
63
+ $options[$combination->getId()] = $label;
64
+ } else {
65
+ $options[] = array(
66
+ 'value' => $combination->getId(),
67
+ 'label' => $label
68
+ );
69
+ }
70
+ }
71
+
72
+ return $options;
73
+ }
74
+
75
+ /**
76
+ * Returns an array with available gls products available for inland shipping and foreign country shipping.
77
+ * A gls product in this module is a combination of gls services wrapped up to a product for better usability.
78
+ * In case $toKeyValue param is true the array keys are the combination id's from model (Zend configuration) instead of standard array index
79
+ * @param bool|false $toKeyValue
80
+ * @return array
81
+ */
82
+ public function productServiceCombinationsToOptionArray($toKeyValue=false) {
83
+ $options = array();
84
+ $combinations = Mage::getModel('synergeticagency_gls/combination')
85
+ ->getCollection()
86
+ ->load();
87
+
88
+ foreach($combinations as $combination) {
89
+ $label = $combination->getName();
90
+
91
+ if($toKeyValue) {
92
+ $options[$combination->getId()] = $label;
93
+ } else {
94
+ $options[] = array(
95
+ 'value' => $combination->getId(),
96
+ 'label' => $label
97
+ );
98
+ }
99
+ }
100
+
101
+ return $options;
102
+ }
103
+
104
+ /**
105
+ * Return an array with additional optional services available for gls products (combinations)
106
+ * In case $toKeyValue param is true the array keys are the combination id's from model (Zend configuration) instead of standard array index
107
+ * @param bool|false $toKeyValue
108
+ * @param bool|false $withNotice
109
+ * @return array
110
+ */
111
+ public function addonServicesToOptionArray($toKeyValue=false,$withNotice=false) {
112
+ $options = array();
113
+ $services = Mage::getModel('synergeticagency_gls/service')->getCollection()->addFilter('is_addon',true)->load();
114
+ foreach($services as $service) {
115
+ $value = $service->getId();
116
+ $label = Mage::helper('synergeticagency_gls')->__($service->getName());
117
+ $notice = Mage::helper('synergeticagency_gls')->__($service->getNotice());
118
+
119
+ if($toKeyValue) {
120
+ $options[$value] = $label;
121
+ } else {
122
+ if($withNotice) {
123
+ $options[] = array(
124
+ 'value' => $value,
125
+ 'label' => $label,
126
+ 'notice' => $notice
127
+ );
128
+ } else {
129
+ $options[] = array(
130
+ 'value' => $value,
131
+ 'label' => $label
132
+ );
133
+ }
134
+ }
135
+ }
136
+ return $options;
137
+ }
138
+
139
+ /**
140
+ * Return an array with countries allowed by GLS as an origin shipping country
141
+ * @return array
142
+ */
143
+ public function getAvialableOriginCountries() {
144
+ $countries = Mage::getModel('synergeticagency_gls/country')->getCollection()->load();
145
+ $countryArray = array();
146
+ foreach($countries as $country) {
147
+ $countryArray[] = $country->getId();
148
+ }
149
+ return $countryArray;
150
+ }
151
+
152
+ /**
153
+ * Verify if a given country is allowed as origin country by GLS
154
+ * @param string $countryId
155
+ * @return bool
156
+ */
157
+ public function isCountryOriginIdAvailable($countryId) {
158
+ $availableCountryIds = $this->getAvialableOriginCountries();
159
+ return in_array($countryId, $availableCountryIds);
160
+ }
161
+
162
+ /**
163
+ * Verify if a given country is allowed as destination country from origin country by GLS
164
+ * @param string $originCountryId
165
+ * @param string $foreignCountryId
166
+ * @return bool
167
+ */
168
+ public function isDestinationCountryAvailable($originCountryId,$foreignCountryId) {
169
+ $countries = Mage::getModel('synergeticagency_gls/jsonimport')->getForeignCountriesByOriginCountryId($originCountryId);
170
+ if($countries && count($countries)) {
171
+ foreach($countries as $key => $country) {
172
+ if($key == $foreignCountryId) return true;
173
+ }
174
+ }
175
+ return false;
176
+ }
177
+
178
+ /**
179
+ * Verify if GLS cash on delivery service is allowed for a given country
180
+ * @param string $originCountryId
181
+ * @return null|bool
182
+ */
183
+ public function isCashserviceAvailabelForOriginCountry($originCountryId) {
184
+ return Mage::getModel('synergeticagency_gls/jsonimport')->getDomesticValueByOriginCountryId($originCountryId,'cashservice');
185
+ }
186
+
187
+ /**
188
+ * Verify if shipment currency is allowed for country by GLS
189
+ * @param string $originCountryId
190
+ * @param string $currencyCode
191
+ * @return bool
192
+ */
193
+ public function isCurrencyAvailabelForOriginCountry($originCountryId,$currencyCode) {
194
+ return $currencyCode == Mage::getModel('synergeticagency_gls/jsonimport')->getDomesticValueByOriginCountryId($originCountryId,'cashcurrency');
195
+ }
196
+
197
+ /**
198
+ * Verify if total shipping amount is within GLS allowed limit
199
+ * @param string $originCountryId
200
+ * @param string $grandTotal
201
+ * @return bool
202
+ */
203
+ public function isGrandTotalInLimitForOriginCountry($originCountryId, $grandTotal) {
204
+ $cashMax = Mage::getModel('synergeticagency_gls/jsonimport')->getDomesticValueByOriginCountryId($originCountryId,'cashmax');
205
+ if(is_null($cashMax)) {
206
+ return false;
207
+ }
208
+ return $cashMax >= $grandTotal;
209
+ }
210
+
211
+ /**
212
+ * Saves a GLS shipment. Shipments are saved in modules DB Tables additionally to the Magento Tables
213
+ * @param array $data
214
+ * @param Mage_Sales_Model_Order_Shipment $shipment
215
+ * @param null|SynergeticAgency_Gls_Model_Shipment $glsShipment
216
+ * @throws Exception
217
+ */
218
+ public function saveGlsShipment($data, $shipment, $glsShipment = null) {
219
+ $data = $data['shipment'];
220
+ $glsData = $data['gls'];
221
+ $store = $shipment->getStore();
222
+ $editMode = true;
223
+ if(is_null($glsShipment)) {
224
+ $glsShipment = Mage::getModel('synergeticagency_gls/shipment');
225
+ $editMode = false;
226
+ }
227
+ $glsShipment->setShipmentId($shipment->getId());
228
+
229
+ $combination = $glsData['combination'];
230
+ $glsShipment->setCombinationId($combination);
231
+ $glsShipment->setSandbox(Mage::getStoreConfig('gls/general/sandbox',$store));
232
+
233
+ $serviceIds = array();
234
+ $combinationModel = Mage::getModel('synergeticagency_gls/combination')->load($combination);
235
+ $services = $combinationModel->getServices();
236
+ if(!empty($services) && count($services)) {
237
+ foreach($services as $service) {
238
+ $serviceIds[] = $service->getId();
239
+ }
240
+ }
241
+ if(!empty($glsData['service']) && count($glsData['service'])) {
242
+ foreach($glsData['service'] as $key => $addonService) {
243
+ if($addonService) {
244
+ $serviceIds[] = $key;
245
+ }
246
+ }
247
+ }
248
+ $glsShipment->setGlsProduct($combinationModel->getProduct()->getId());
249
+ $serviceIdsConcat = '';
250
+ if(count($serviceIds)) {
251
+ $serviceIdsConcat = implode(',',$serviceIds);
252
+ }
253
+ $glsShipment->setGlsServices($serviceIdsConcat);
254
+ $glsShipment->setOrderId($shipment->getOrderId());
255
+ $shippingDate = strtotime($glsData['shipping_date']);
256
+ $shippingDate = date('Y-m-d',$shippingDate);
257
+ $glsShipment->setShippingDate($shippingDate);
258
+ $returnLabel = 0;
259
+
260
+ if(array_key_exists('return_label', $glsData) && $glsData['return_label'] === '1') {
261
+ $returnLabel = 1;
262
+ }
263
+ $glsShipment->setReturnLabel($returnLabel);
264
+
265
+ $shippingAddress = $shipment->getShippingAddress();
266
+ $parcelShopId = $shippingAddress->getParcelshopId();
267
+ if(empty($parcelShopId)) {
268
+ $parcelShopId = '';
269
+ }
270
+ $glsShipment->setParcelshopId($parcelShopId);
271
+ $glsShipment->save();
272
+
273
+ if($editMode) {
274
+ // delete it first
275
+ $glsShipment->getShipmentAddress()->delete();
276
+ }
277
+ $parcelShopId = $shippingAddress->getParcelshopId();
278
+ if(!empty($parcelShopId)) {
279
+ // if parcelshop delivery is set, we have to use the billing address
280
+ $shippingAddress = $shipment->getBillingAddress();
281
+ }
282
+
283
+ /** @var SynergeticAgency_Gls_Model_Shipment_Address $shippingAddress */
284
+ $glsShipmentAddress = Mage::getModel('synergeticagency_gls/shipment_address');
285
+ $glsShipmentAddress->setGlsShipmentId($glsShipment->getId());
286
+
287
+ $glsShipmentAddress->setName1(
288
+ // Magento's function getName will concat several values in an "magento standard way".
289
+ // Sorry, but GLS need an other sorting:
290
+ $shippingAddress->getPrefix() . " " .
291
+ $shippingAddress->getLastname() . ", " .
292
+ $shippingAddress->getFirstname() . " " .
293
+ $shippingAddress->getMiddlename() . " " .
294
+ $shippingAddress->getSuffix()
295
+ );
296
+ // GLS uses the field name2 for the company
297
+ $glsShipmentAddress->setName2( $shippingAddress->getCompany() );
298
+
299
+ // currently, GLS doesn't use the field name3 in the shipment label
300
+ // $glsShipmentAddress->setName3('value for GLS field name3');
301
+
302
+ $street = $shippingAddress->getStreet();
303
+ if(is_array($street)) {
304
+ $street = implode(' ',$street);
305
+ }
306
+ $glsShipmentAddress->setStreet1($street);
307
+ $glsShipmentAddress->setCountry($shippingAddress->getCountryModel()->getIso2Code());
308
+ $glsShipmentAddress->setZipCode($shippingAddress->getPostcode());
309
+ $glsShipmentAddress->setCity($shippingAddress->getCity());
310
+ $glsShipmentAddress->setEmail($shippingAddress->getEmail());
311
+ $glsShipmentAddress->setPhone($shippingAddress->getTelephone());
312
+ $glsShipmentAddress->save();
313
+
314
+ if($editMode) {
315
+ // first delete all parcels and create new ones
316
+ /** @var SynergeticAgency_Gls_Model_Shipment_Parcel $delParcel */
317
+ foreach($glsShipment->getShipmentParcels() as $delParcel) {
318
+ $delParcel->delete();
319
+ }
320
+ }
321
+
322
+ foreach ($data['packages'] as $key => $package) {
323
+ $weight = (float)str_replace(',', '.', $package['weight']);
324
+ $cashService = null;
325
+ if(!empty($package['cashservice'])) {
326
+ $cashService = (float)str_replace(',', '.', $package['cashservice']);
327
+ }
328
+
329
+ $glsShipmentParcel = Mage::getModel('synergeticagency_gls/shipment_parcel');
330
+ $glsShipmentParcel->setGlsShipmentId($glsShipment->getId());
331
+ $glsShipmentParcel->setWeight($weight);
332
+ $glsShipmentParcel->setCashservice($cashService);
333
+ $glsShipmentParcel->save();
334
+ }
335
+ }
336
+
337
+ /**
338
+ * Returns true if $data is valid
339
+ * Returns HTML formatted error string containing information of invalid data
340
+ * @param array $data
341
+ * @return bool|string
342
+ *
343
+ */
344
+ public function validateGlsShipmentData($data) {
345
+
346
+ $validationResult = array();
347
+
348
+ $validationResult[] = $this->isValidWeight($data);
349
+ $validationResult[] = $this->isValidCashAmount($data);
350
+ $validationResult[] = $this->isValidShippingDate($data);
351
+ $validationResult[] = $this->isValidCashService($data);
352
+ $validationResult[] = $this->hasValidServices($data);
353
+ $validationResult[] = $this->isValidDestinationCountry($data);
354
+ $errorString = '';
355
+ foreach($validationResult AS $messages){
356
+ foreach($messages AS $message){
357
+ $errorString .= $message.'<br />';
358
+ }
359
+ }
360
+
361
+ if($errorString === '') {
362
+ return true;
363
+ }
364
+ else {
365
+ return $errorString;
366
+ }
367
+ }
368
+
369
+ /**
370
+ * Check if parcels weight(s) is(are)within allowed maximum weight in respect of given parcel data and the corresponding configuration
371
+ * In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
372
+ * @param $data
373
+ * @return array
374
+ * @throws Zend_Locale_Exception
375
+ * @throws Zend_Validate_Exception
376
+ */
377
+ public function isValidWeight($data){
378
+
379
+ $minWeight = 0.01;
380
+
381
+ $helper = Mage::helper('synergeticagency_gls/validate');
382
+ $config = $helper->getConfig();
383
+ $symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $helper->getStore()) , 'symbols');
384
+
385
+ switch($helper->isDomestic()){
386
+ case false:
387
+ switch($helper->isParcelshopDelivery()) {
388
+ case true:
389
+ $maxWeight = $config->foreign->countries->{$helper->getTargetCountry()}->parcelshopweight;
390
+ break;
391
+ default:
392
+ $maxWeight = $config->foreign->countries->{$helper->getTargetCountry()}->maxweight;
393
+ }
394
+ break;
395
+ default:
396
+ switch($helper->isParcelshopDelivery()) {
397
+ case true:
398
+ $maxWeight = $config->domestic->parcelshopweight;
399
+ break;
400
+ default:
401
+ $maxWeight = $config->domestic->maxweight;
402
+ }
403
+ }
404
+
405
+ $weightValidator = new Zend_Validate_Between(floatval($minWeight),floatval($maxWeight),1);
406
+ $weightValidator->setMessage(Mage::helper('synergeticagency_gls')->__("At least one parcel has a invalid weight"),'notBetween');
407
+
408
+ foreach($data['shipment']['packages'] AS $package){
409
+ if(false === $weightValidator->isValid(floatval(str_replace($symbols['decimal'], '.', $package['weight'])))){
410
+ break;
411
+ }
412
+ }
413
+
414
+ return $weightValidator->getMessages();
415
+ }
416
+
417
+ /**
418
+ * Check if parcels cash on delivery amount(s) is(are)within allowed amount in respect of given parcel data and the corresponding configuration.
419
+ * In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
420
+ * @param $data
421
+ * @return array
422
+ * @throws Zend_Locale_Exception
423
+ * @throws Zend_Validate_Exception
424
+ */
425
+ public function isValidCashAmount($data){
426
+
427
+ $minAmount = 0.00;
428
+
429
+ $helper = Mage::helper('synergeticagency_gls/validate');
430
+ $config = $helper->getConfig();
431
+ $symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $helper->getStore()) , 'symbols');
432
+
433
+ switch($helper->isDomestic()){
434
+ case false:
435
+ $maxAmount = $config->foreign->countries->{$helper->getTargetCountry()}->cashmax;
436
+ break;
437
+ default:
438
+ $maxAmount = $config->domestic->cashmax;
439
+ break;
440
+ }
441
+
442
+ $amountValidator = new Zend_Validate_Between(floatval($minAmount),floatval($maxAmount),1);
443
+ $amountValidator->setMessage(Mage::helper('synergeticagency_gls')->__("At least one parcel has a invalid cash on delivery amount"),'notBetween');
444
+
445
+ foreach($data['shipment']['packages'] AS $package){
446
+ if(array_key_exists('cashservice',$package)) {
447
+ if (false === $amountValidator->isValid(floatval(str_replace($symbols['decimal'], '.',$package['cashservice'])))) {
448
+ break;
449
+ }
450
+ }
451
+ }
452
+
453
+ return $amountValidator->getMessages();
454
+ }
455
+
456
+ /**
457
+ * Check if shipping date is not in the past - evaluated on daily base
458
+ * In case the check is negative an appropriate error message(s) are getting returned (Zend validation)
459
+ * @param $data
460
+ * @return array
461
+ * @throws Zend_Validate_Exception
462
+ */
463
+ public function isValidShippingDate($data){
464
+
465
+ $minDate = strtotime('yesterday midnight');
466
+ $date = strtotime($data['shipment']['gls']['shipping_date']);
467
+
468
+ $dateValidator = new Zend_Validate_GreaterThan($minDate);
469
+ $dateValidator->setMessage(Mage::helper('synergeticagency_gls')->__("The shipping date may not be in the past"),'notGreaterThan');
470
+
471
+ $dateValidator->isValid($date);
472
+ return $dateValidator->getMessages();
473
+ }
474
+
475
+ /**
476
+ * Check if submitted service combination is allowed
477
+ * In case the check is negative an appropriate error message(s) is getting returned (Zend validation)
478
+ * @param $data
479
+ * @return array
480
+ * @throws Zend_Validate_Exception
481
+ */
482
+ public function hasValidServices($data){
483
+
484
+ $helper = Mage::helper('synergeticagency_gls/validate');
485
+ $countryConfig = $helper->getCountriesConfig();
486
+ $selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
487
+
488
+ $serviceValidator = new Zend_Validate_InArray($selectedCombination['addon_services']);
489
+ $serviceValidator->setMessage(Mage::helper('synergeticagency_gls')->__("At least one additional service is not allowed for the current product"),'notInArray');
490
+ if(isset($data['shipment']['gls']['service'])) {
491
+ foreach ($data['shipment']['gls']['service'] AS $serviceId => $value) {
492
+ if ($value === '1') {
493
+ if (false === $serviceValidator->isValid($serviceId)) {
494
+ break;
495
+ }
496
+ }
497
+ }
498
+ }
499
+
500
+ return $serviceValidator->getMessages();
501
+ }
502
+
503
+ /**
504
+ * Verify if target country is allowed for product
505
+ * businessparcel vs. europarcel
506
+ * business parcel is just allowed for domestic shipment europarcel is just allowed for foreign country shipment
507
+ * @param $data
508
+ * @return array
509
+ */
510
+ public function isValidDestinationCountry($data)
511
+ {
512
+ $helper = Mage::helper('synergeticagency_gls/validate');
513
+ $countryConfig = $helper->getCountriesConfig();
514
+ $selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
515
+ $messages = array();
516
+ if((false === $selectedCombination['domestic'] && true === $helper->isDomestic()) || (false === $selectedCombination['foreign'] && false === $helper->isDomestic())){
517
+ $messages[0] = Mage::helper('synergeticagency_gls')->__("The selected product is not allowed for shipments target country");
518
+ }
519
+
520
+ return $messages;
521
+ }
522
+
523
+ /**
524
+ * Check if parcels cash on delivery is(are) allowed in respect of given package data and the corresponding configuration
525
+ * @param $data
526
+ * @return array
527
+ */
528
+ public function isValidCashService($data)
529
+ {
530
+ $helper = Mage::helper('synergeticagency_gls/validate');
531
+ $countryConfig = $helper->getCountriesConfig();
532
+ $selectedCombination = $helper->getCombinationByCombinationId($countryConfig->options, $data['shipment']['gls']['combination']);
533
+ $messages = array();
534
+ foreach($data['shipment']['packages'] AS $package){
535
+ if(array_key_exists('cashservice',$package) && false === $selectedCombination['cashservice']) {
536
+ $messages[0] = Mage::helper('synergeticagency_gls')->__("Cash on delivery isn't allowed for the selected product");
537
+ break;
538
+ }
539
+ }
540
+
541
+ return $messages;
542
+ }
543
+ }
app/code/community/SynergeticAgency/Gls/Model/Glscashondelivery.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class SynergeticAgency_Gls_Model_Glscashondelivery
29
+ */
30
+ class SynergeticAgency_Gls_Model_Glscashondelivery extends Mage_Payment_Model_Method_Abstract
31
+ {
32
+
33
+ /**
34
+ * Magento internal name for the payment method
35
+ * @var string
36
+ */
37
+ protected $_code = 'glscashondelivery';
38
+
39
+ /**
40
+ * GLS Cash On Delivery payment block paths
41
+ *
42
+ * @var string
43
+ */
44
+ protected $_formBlockType = 'synergeticagency_gls/form_glscashondelivery';
45
+
46
+ /**
47
+ * Inherited from Mage_Sales_Model_Order_Payment
48
+ * Set to true to set and validate custom config data
49
+ * @var bool
50
+ */
51
+ protected $_isInitializeNeeded = true;
52
+
53
+ /**
54
+ * Decides if the payment method can be used in the backend
55
+ * Not needed as method is just shown in the checkout by magento
56
+ * Handling is covered by GLS module itself
57
+ * @var bool
58
+ */
59
+ protected $_canUseInternal = false;
60
+
61
+ /**
62
+ * This module doesn't work for multishipping
63
+ * @var bool
64
+ */
65
+ protected $_canUseForMultishipping = false;
66
+
67
+ /**
68
+ * Holds all GLS shipping rates for which GLS cash on delivery is allowed
69
+ * @var array
70
+ */
71
+ protected $_allowedShippingRates = array();
72
+
73
+ const SHIPPING_RATE_STANDARD = 'standard';
74
+ const SHIPPING_RATE_EXPRESS = 'express';
75
+ const SHIPPING_RATE_FOREIGNCOUNTRIES = 'foreigncountries';
76
+
77
+ /**
78
+ * Holds full config for for payment module glscashondelivery
79
+ * @var array
80
+ */
81
+ protected $_glsConfig = array();
82
+
83
+ /**
84
+ * The constructor setting shipping rates for which cash on delivery is allowed
85
+ */
86
+ public function __construct()
87
+ {
88
+ $this->_allowedShippingRates = array(
89
+ SynergeticAgency_Gls_Model_Carrier::CODE . '_' . SynergeticAgency_Gls_Model_Carrier::SHIPPING_RATE_STANDARD,
90
+ );
91
+ parent::__construct();
92
+ }
93
+
94
+ /**
95
+ * Get instructions text from config
96
+ *
97
+ * @return string
98
+ */
99
+ public function getInstructions()
100
+ {
101
+ return trim($this->getConfigData('instructions'));
102
+ }
103
+
104
+ /**
105
+ * Check whether payment method is applicable to quote
106
+ * Purposed to allow use in controllers some logic that was implemented in blocks only before
107
+ *
108
+ * @param Mage_Sales_Model_Quote $quote
109
+ * @param int|null $checksBitMask
110
+ * @return bool
111
+ */
112
+ public function isApplicableToQuote($quote, $checksBitMask)
113
+ {
114
+
115
+ $parent = parent::isApplicableToQuote($quote, $checksBitMask);
116
+
117
+ if ($parent === true) {
118
+
119
+ /**
120
+ * @var object $store
121
+ * @desc Getting the Store
122
+ */
123
+ $store = $quote->getStore();
124
+
125
+ /**
126
+ * @desc Getting full payment config for for module synergeticagency_gls
127
+ */
128
+ $this->_glsConfig = Mage::getStoreConfig(
129
+ 'payment/glscashondelivery',
130
+ $store
131
+ );
132
+
133
+ /** Does store country equal shipping country? */
134
+ if ($this->_isDomesticShipping($quote) === false) {
135
+ return false;
136
+ }
137
+ /** Is store country allowed at all for payment method? */
138
+ if ($this->_isAllowedStoreCountry($quote) === false) {
139
+ return false;
140
+ }
141
+ /** Is grand total within country limit? */
142
+ if ($this->_isInCountryLimit($quote) === false) {
143
+ return false;
144
+ }
145
+ /** Is current store currency allowed for payment method in this country? */
146
+ if ($this->_isAllowedCountryCurrency($quote) === false) {
147
+ return false;
148
+ }
149
+ /** If delivery address is package shop disallow payment method*/
150
+ if ($this->_isParcelShopDelivery($quote) === true) {
151
+ return false;
152
+ }
153
+ /** Is payment method allowed for for current shipping method? */
154
+ if ($this->_isAllowedShippingRate($quote) === false) {
155
+ return false;
156
+ }
157
+ }
158
+
159
+ return $parent;
160
+
161
+
162
+ }
163
+
164
+ /**
165
+ * Does store country equal shipping country?
166
+ * @param $quote Mage_Sales_Model_Quote
167
+ * @return bool
168
+ */
169
+ protected function _isDomesticShipping($quote)
170
+ {
171
+ $shippingCountry = $quote->getShippingAddress()->getCountry();
172
+
173
+ $storeCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID,
174
+ $quote->getStore());
175
+
176
+ return $shippingCountry === $storeCountry;
177
+ }
178
+
179
+ /**
180
+ * Is store country allowed at all for payment method?
181
+ * @param $quote Mage_Sales_model_Quote
182
+ * @return bool
183
+ * TODO: Test - Get allowed store countries from config
184
+ */
185
+ protected function _isAllowedStoreCountry($quote)
186
+ {
187
+ return Mage::getModel('synergeticagency_gls/gls')->isCashserviceAvailabelForOriginCountry(Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $quote->getStore()));
188
+ }
189
+
190
+ /**
191
+ * Is currency allowed for this payment method
192
+ * @param $quote Mage_Sales_Model_Quote
193
+ * @return bool
194
+ * TODO: Test
195
+ */
196
+ protected function _isAllowedCountryCurrency($quote)
197
+ {
198
+ $originCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $quote->getStore());
199
+ $baseCurrency = $quote->getStore()->getBaseCurrencyCode();
200
+
201
+ return Mage::getModel('synergeticagency_gls/gls')->isCurrencyAvailabelForOriginCountry($originCountry,$baseCurrency);
202
+ }
203
+
204
+ /**
205
+ * Only show Payment Method if basket total payment amount is within GLS defined limit
206
+ * @param $quote Mage_Sales_Model_Quote
207
+ * @return bool
208
+ */
209
+ protected function _isInCountryLimit($quote)
210
+ {
211
+ $originCountry = Mage::getStoreConfig(Mage_Shipping_Model_Shipping::XML_PATH_STORE_COUNTRY_ID, $quote->getStore());
212
+ return Mage::getModel('synergeticagency_gls/gls')->isGrandTotalInLimitForOriginCountry($originCountry,$quote->getGrandTotal());
213
+ }
214
+
215
+ /**
216
+ * Check if it's a parcel shop delivery. Payment method is not allowed for parcel shop deliveries by GLS
217
+ * @param $quote Mage_Sales_Model_Quote
218
+ * @return bool
219
+ */
220
+ protected function _isParcelShopDelivery($quote)
221
+ {
222
+ $parcelShopId = $quote->getShippingAddress()->getParcelshopId();
223
+ return !empty($parcelShopId);
224
+ }
225
+
226
+ /**
227
+ * Check is payment is enabled in magento configuration
228
+ * @param $quote Mage_Sales_Model_Quote
229
+ * @return bool
230
+ */
231
+ protected function _isAllowedShippingRate($quote)
232
+ {
233
+ $disallowedShippingMethods = explode(',', $this->_glsConfig['disallowed_delivery_services']);
234
+
235
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod();
236
+
237
+ if(empty($shippingMethod)) {
238
+ return false;
239
+ }
240
+
241
+ $rates = $quote->getShippingAddress()->getShippingRatesCollection();
242
+ if(!count($rates)) {
243
+ return false;
244
+ }
245
+
246
+ foreach ($rates as $rate) {
247
+ if ($rate->getCode() == $shippingMethod) {
248
+ if ($rate->getCarrier() == "synergeticagency_gls") {
249
+ if (!in_array($shippingMethod, $this->_allowedShippingRates)) {
250
+ return false;
251
+ }
252
+ } else {
253
+ if ($this->_glsConfig['disallow_delivery_services'] === '1') {
254
+ if (in_array($rate->getCarrier(), $disallowedShippingMethods)) {
255
+ return false;
256
+ }
257
+ }
258
+ }
259
+ break;
260
+ }
261
+ }
262
+
263
+ return true;
264
+ }
265
+ }
app/code/community/SynergeticAgency/Gls/Model/Jsonimport.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class SynergeticAgency_Gls_Model_Jsonimport
29
+ */
30
+ class SynergeticAgency_Gls_Model_Jsonimport extends Mage_Core_Model_Abstract{
31
+
32
+ /**
33
+ * Path to file containing GLS configuration json data
34
+ * @var
35
+ */
36
+ private $jsonConfigFile;
37
+
38
+ /**
39
+ * GLS configuration json data
40
+ * @var
41
+ */
42
+ private $_jsonConfig;
43
+
44
+ /**
45
+ * Constructor - instantiate parent constructor and set path to config file
46
+ */
47
+ function __construct() {
48
+ parent::__construct();
49
+ $this->setJsonConfigFile( DS . trim( Mage::getBaseDir('var') . DS . "import" . DS . "gls" . DS . "json", DS) . DS . "glsconfig.json" );
50
+ }
51
+
52
+ /**
53
+ * cron function
54
+ * Refresh GLS configuration on a regular base
55
+ */
56
+ public function run(){
57
+
58
+ $json = $this->getJsonConfigFromConnector();
59
+
60
+ if ( $json && $this->saveJson( $json ) ){
61
+ // JSON Config saved successful
62
+ } else {
63
+ //ToDo: implement fallback
64
+ };
65
+ }
66
+
67
+ /**
68
+ * Get the GLS json configuration directly from GLS
69
+ * The Connector is a lib handling Magento unrelated GLS specific tasks
70
+ * @return bool|mixed
71
+ */
72
+ private function getJsonConfigFromConnector() {
73
+ /** @var $connector SynergeticAgency_GlsConnector_Connector */
74
+ $connector = new SynergeticAgency_GlsConnector_Connector();
75
+
76
+ if( Mage::getStoreConfig('gls/general/sandbox') !== '1' ){
77
+ //$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "gls/general/sandbox is set to '1'", Zend_Log::INFO );
78
+ $connector->setGlsApiSandbox( false );
79
+ }
80
+
81
+ $connector->setGlsApiUrl( Mage::getStoreConfig('gls/general/api_url') );
82
+
83
+ // set GLS-API-JSON-CONFIG-URI possibility 1 START
84
+ // do not use this possibility for the new GLS-API provided by GLS in the future,
85
+ // because in the new version, JSON-Config will be delivered from the GLS-API service(see setGlsApiUrl() and shipment)
86
+ $connector->setGlsApiJsonUrl( Mage::getStoreConfig('gls/general/json_url') );
87
+
88
+ $connector->loadJsonConfig();
89
+ $json = $connector->getJsonConfig();
90
+ if(!$connector->isJson($json)) {
91
+ $json = false;
92
+ }
93
+ return $json;
94
+ }
95
+
96
+ /**
97
+ * Save configuration data provided by GLS to a local cached json configuration file
98
+ * @param $json
99
+ * @return bool
100
+ */
101
+ public function saveJson( $json ){
102
+
103
+ $returnValue = true;
104
+
105
+ // ToDo: use Mage filehandler instead...
106
+ if (!$handle = fopen($this->getJsonConfigFile(), "w")) {
107
+ print "Cannot open " . $this->getJsonConfigFile();
108
+ $returnValue = false;
109
+ }
110
+
111
+ if ( $returnValue === true ) {
112
+ if (!fwrite($handle, $json)) {
113
+ print "Cannot write \$json into " . $this->getJsonConfigFile();
114
+ $returnValue = false;
115
+ }
116
+ } else {
117
+ fclose($handle);
118
+ }
119
+
120
+ return $returnValue;
121
+ }
122
+
123
+ /**
124
+ * Get the path to GLS configuration file
125
+ * @return mixed
126
+ */
127
+ private function getJsonConfigFile() {
128
+ return $this->jsonConfigFile;
129
+ }
130
+
131
+ /**
132
+ * Set the path to GLS configuration file
133
+ * @param $jsonConfigFile
134
+ * @return $this
135
+ */
136
+ private function setJsonConfigFile($jsonConfigFile) {
137
+ $this->jsonConfigFile = $jsonConfigFile;
138
+ return $this;
139
+ }
140
+
141
+ /**
142
+ * Reading full GLS configuration from (cached) file
143
+ * Cached in this case means the configuration file located on a GLS server is stored on the server where the magento is running for performance reasons
144
+ * @return bool|string
145
+ */
146
+ private function getJsonConfigFromFile() {
147
+ $json = false;
148
+ if(is_file($this->getJsonConfigFile())) {
149
+ $json = file_get_contents($this->getJsonConfigFile());
150
+ }
151
+ return $json;
152
+ }
153
+
154
+ /**
155
+ * Getting the full GLS configuration based on several fallback layers
156
+ * 1. From Magento cache
157
+ * 2. From local cache File
158
+ * 3. Directly from GLS
159
+ * @return null|Zend_Config
160
+ */
161
+ public function getJsonConfig() {
162
+ if(empty($this->_jsonConfig)) {
163
+ // try to get it from cache
164
+ $cacheKey = 'gls-jsonconfig';
165
+ $cache = Mage::app()->getCache();
166
+ //TODO: Check why this
167
+ //$jsonConfig = $cache->load($cacheKey);
168
+ $jsonConfig = false;
169
+ $fromCache = true;
170
+ if(!$jsonConfig) {
171
+ $fromCache = false;
172
+ // first try to get it from file
173
+ $jsonConfig = $this->getJsonConfigFromFile();
174
+ }
175
+ if(!$jsonConfig) {
176
+ // try to get it from connector
177
+ $jsonConfig = $this->getJsonConfigFromConnector();
178
+ if($jsonConfig) {
179
+ $this->saveJson($jsonConfig);
180
+ }
181
+ }
182
+ if($jsonConfig) {
183
+ if($fromCache) {
184
+ // unserialize data from cache - it's a zend config object already
185
+ $jsonConfig = unserialize($jsonConfig);
186
+ } else {
187
+ // save data in cache - first build zend config object then serialize for cache
188
+ $jsonConfig = new Zend_Config_Json($jsonConfig);
189
+ $cache->save(serialize($jsonConfig), $cacheKey, array('SYNERGETIC_GLS'), 86400);
190
+ }
191
+ $this->_jsonConfig = $jsonConfig;
192
+ }
193
+ }
194
+ return $this->_jsonConfig;
195
+ }
196
+
197
+ /**
198
+ * Get GLS configuration for a specific country
199
+ * @param string $countryId
200
+ * @return null|Zend_Config
201
+ */
202
+ public function getCountry($countryId) {
203
+ $jsonConfig = $this->getJsonConfig();
204
+ $country = null;
205
+ if($jsonConfig && $jsonConfig->get('config',null)) {
206
+ $country = $jsonConfig->get('config')->get($countryId, null);
207
+ }
208
+ return $country;
209
+ }
210
+
211
+ /**
212
+ * Get configuration for all available shipping destination countries based on origin shipping country
213
+ * which are allowed for shipping origin country by GLS
214
+ * @param string $countryId
215
+ * @return null|Zend_Config The configuration or null if destination shipping country not available for origin country
216
+ */
217
+ public function getForeignCountriesByOriginCountryId($countryId) {
218
+ $country = $this->getCountry($countryId);
219
+ $foreignCountries = null;
220
+ if($country) {
221
+ if($country->get('foreign',null)) {
222
+ $foreignCountries = $country->get('foreign',null)->get('countries');
223
+ }
224
+ }
225
+ return $foreignCountries;
226
+ }
227
+
228
+ /**
229
+ * Get an configuration value for inland shipping
230
+ * @param string $countryId
231
+ * @param string $fieldName
232
+ * @return null|string The config value or null if country not allowed by GLS
233
+ */
234
+ public function getDomesticValueByOriginCountryId($countryId,$fieldName) {
235
+ $country = $this->getCountry($countryId);
236
+ $returnValue = null;
237
+ if($country) {
238
+ $returnValue = $country->get('domestic')->get($fieldName,null);
239
+ }
240
+ return $returnValue;
241
+ }
242
+
243
+ /**
244
+ * Get an configuration value for a destination shipping country based on origin country
245
+ * @param $originCountryId
246
+ * @param $foreignCountryId
247
+ * @param $fieldName
248
+ * @return null|string The config value or null if destination shipping country not available for origin country
249
+ */
250
+ public function getForeignValueByOriginAndForeignCountryId($originCountryId,$foreignCountryId,$fieldName) {
251
+ $country = $this->getCountry($originCountryId);
252
+ $returnValue = null;
253
+ if($country) {
254
+ $foreignCountry = $country->get('foreign')->get('countries')->get($foreignCountryId,null);
255
+ if($foreignCountry) {
256
+ $returnValue = $foreignCountry->get($fieldName,null);
257
+ }
258
+ }
259
+ return $returnValue;
260
+ }
261
+ }
app/code/community/SynergeticAgency/Gls/Model/Observer.php ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Observer
24
+ */
25
+ class SynergeticAgency_Gls_Model_Observer {
26
+
27
+
28
+ /**
29
+ * Adding some javascript to add GLS Logos for shipment methods if it's enabled in magento config
30
+ * @param Varien_Event_Observer $observer
31
+ */
32
+
33
+ public function setGlsShippingLogos(Varien_Event_Observer $observer) {
34
+
35
+ if($observer->getBlock() instanceof Mage_Checkout_Block_Onepage){
36
+ $block = $observer->getBlock();
37
+ $transport = $observer->getTransport();
38
+ $fileName = $block->getTemplateFile();
39
+
40
+ if($fileName) {
41
+ $store = Mage::app()->getStore();
42
+
43
+ // Getting full carrier config for for module synergeticagency_gls
44
+ $config = Mage::getStoreConfig(
45
+ 'carriers/synergeticagency_gls',
46
+ $store
47
+ );
48
+
49
+ // Checking if GLS module is active at all
50
+ if ($config['active'] == '1') {
51
+
52
+ // Getting Store Country to build logo path
53
+ $country = Mage::getStoreConfig('general/country/default');
54
+ $countryCode = strtolower(Mage::getModel('directory/country')->loadByCode($country)->getIso2Code());
55
+
56
+ // Getting logo configuration
57
+ // Careful with config array key naming in case new delivery options are added - stick to convention
58
+ $logoConfigKeys = preg_filter('/^show_logo_(.*)/', '$1', array_keys($config));
59
+ foreach ($logoConfigKeys AS $logoKey) {
60
+
61
+ // Just render javascript for logo if shipment option is active and show_logo_* is active
62
+ if ($config['active_' . $logoKey] === '1' && $config['show_logo_' . $logoKey] === '1') {
63
+ //Getting Store Country -> Logo per country and available shipping method
64
+ //need also a default in case country logo not available
65
+ $logoWwwPath = Mage::getDesign()->getSkinUrl('images/gls/logo/' . $countryCode . '/' . $logoKey . '.png');
66
+ $logoLocalPath = Mage::getSingleton('core/design_package')->getFilename('images/gls/logo/' . $countryCode . '/' . $logoKey . '.png', array('_type' => 'skin', '_default' => false));
67
+ if (!file_exists($logoLocalPath)) {
68
+ $logoWwwPath = Mage::getDesign()->getSkinUrl('images/gls/logo/default/' . $logoKey . '.png');
69
+ }
70
+ $logos[$logoKey] = $logoWwwPath;
71
+ }
72
+ }
73
+ // Create a new block for JavaScript and set Logo Data
74
+ $layout = Mage::app()->getLayout();
75
+ $jsBlock = $layout->createBlock(
76
+ 'Mage_Core_Block_Template',
77
+ 'synergeticagency_logo_js',
78
+ array(
79
+ 'template' => 'gls/logoJs.phtml'
80
+ )
81
+ )->setLogos($logos);
82
+
83
+ // Append Javascript block to Mage_Checkout_Block_Onepage
84
+ $html = $transport->getHtml();
85
+ $html = $html . $jsBlock->toHtml();
86
+ $transport->setHtml($html);
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Adding some js to adminhtml configuration shipping methods to show/hide the 'show errormessage' field in dependency to show shipping also if not possible
94
+ */
95
+ public function setCountryModel()
96
+ {
97
+
98
+ $layout = Mage::app()->getLayout();
99
+
100
+ $layout->getBlock('js')->append($layout
101
+ ->createBlock('adminhtml/template')
102
+ ->setTemplate('gls/system/shipping/gls_applicable_country.phtml'));
103
+ }
104
+
105
+ /**
106
+ * Saves additional gls data to shipment
107
+ *
108
+ * @return null|void
109
+ */
110
+ public function saveShipmentData()
111
+ {
112
+
113
+ if(Mage::registry('gls_shipment_error') === true) {
114
+ return null;
115
+ }
116
+
117
+ $shipment = Mage::registry('current_shipment');
118
+ // Return if current shipment is null.
119
+ if (is_null($shipment)):
120
+ return null;
121
+ endif;
122
+
123
+ $store = $shipment->getStore();
124
+ // Return if global gls config is disabled.
125
+ if (!Mage::getStoreConfig('gls/general/active' , $store)) {
126
+ return null;
127
+ }
128
+
129
+ // get post data
130
+ $data = Mage::app()->getRequest()->getPost();
131
+ if(!isset($data['ship_with_gls']) || $data['ship_with_gls'] !== '1') {
132
+ // shipment with gls is not selected
133
+ return null;
134
+ }
135
+
136
+ // Return if validation fails.
137
+ if ( false === $this->_validateGlsShipmentData($data) ){
138
+ return null;
139
+ }
140
+
141
+ $glsModel = Mage::getModel('synergeticagency_gls/gls');
142
+ $glsModel->saveGlsShipment($data, $shipment);
143
+
144
+ }
145
+
146
+
147
+ /**
148
+ * Server side validation of gls shipment data in sales_order view
149
+ * This validation should never be triggered due to client side validation
150
+ * @param $data
151
+ * @return bool
152
+ */
153
+ public function _validateGlsShipmentData($data) {
154
+
155
+ if (empty($data['shipment']['packages']) ) {
156
+ return false;
157
+ }
158
+
159
+ if ( empty($data['shipment']['gls']) ) {
160
+ return false;
161
+ }
162
+
163
+ $errorMessages = Mage::getModel('synergeticagency_gls/gls')->validateGlsShipmentData($data);
164
+ if(true !== $errorMessages) {
165
+ return false;
166
+ }
167
+
168
+ return $errorMessages;
169
+ }
170
+
171
+
172
+ /**
173
+ * Checks GLS shipment data and throws exception if not valid
174
+ * saving of shipment is not executed then and data can be corrected by the user
175
+ *
176
+ * @param Varien_Event_Observer $observer
177
+ */
178
+ public function checkGlsShipmentData(Varien_Event_Observer $observer)
179
+ {
180
+ $data = Mage::app()->getRequest()->getPost();
181
+ //at the moment this method is also getting called when label is printed
182
+ //check if post data...
183
+ if(isset($data['shipment']['gls']) && isset($data['shipment']['gls']['ship_with_gls']) && $data['shipment']['gls']['ship_with_gls'] == '1') {
184
+ $check = Mage::getModel('synergeticagency_gls/gls')->validateGlsShipmentData($data);
185
+ if ($check !== true) {
186
+ Mage::register('gls_shipment_error', true);
187
+ Mage::throwException($check);
188
+ }
189
+ }
190
+ }
191
+
192
+ /**
193
+ * Adding a button to print a gls shipment label to sales_order view
194
+ * @param Varien_Event_Observer $observer
195
+ */
196
+ public function addGlsPdfButtonToOrder(Varien_Event_Observer $observer) {
197
+ $block = $observer->getBlock();
198
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
199
+ $orderId = $block->getOrderId();
200
+ $glsShipmentCollection = Mage::getModel('synergeticagency_gls/shipment')
201
+ ->getCollection()
202
+ ->addFieldToFilter('order_id',$orderId)
203
+ ->addFieldToFilter('printed','0')
204
+ ->setOrder('gls_shipment_id');
205
+ $hasUnprintedGlsShipments = $glsShipmentCollection->count();
206
+ if($hasUnprintedGlsShipments) {
207
+ $glsShipment = $glsShipmentCollection->getFirstItem();
208
+ $block->addButton('printLastLabel',
209
+ array(
210
+ 'label' => Mage::helper('synergeticagency_gls')->__('Print GLS Label'),
211
+ 'onclick' => "setLocation('{$block->getUrl('adminhtml/gls_shipment/print', array('id' => $glsShipment->getId()))}');this.disabled=true;this.className += ' disabled';",
212
+ 'class' => 'save'
213
+ ), 0, 1
214
+ );
215
+ }
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Observe Mage_Adminhtml_Block_Sales_Order_Grid to add GLS logo
221
+ * @param Varien_Event_Observer $observer
222
+ */
223
+
224
+ public function beforeBlockToHtml(Varien_Event_Observer $observer) {
225
+ $block = $observer->getEvent()->getBlock();
226
+
227
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
228
+ $this->_modifyOrderGrid($block);
229
+ }
230
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Address_Form) {
231
+ $this->_modifyParcelShopId($block);
232
+ }
233
+ }
234
+
235
+ /**
236
+ * @param Mage_Adminhtml_Block_Sales_Order_Grid $grid
237
+ * @throws Exception
238
+ */
239
+ protected function _modifyOrderGrid(Mage_Adminhtml_Block_Sales_Order_Grid $grid) {
240
+ $grid->addColumn('real_order_id', array(
241
+ 'header' => Mage::helper('core')->__('Order #'),
242
+ 'align' => 'left',
243
+ 'index' => 'increment_id',
244
+ 'width' => '100',
245
+ 'renderer' => 'SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Template_Grid_Renderer_Order'
246
+ ));
247
+
248
+ }
249
+
250
+ /**
251
+ * @param Mage_Adminhtml_Block_Sales_Order_Address_Form $observer
252
+ * @throws Exception
253
+ */
254
+ protected function _modifyParcelShopId(Mage_Adminhtml_Block_Sales_Order_Address_Form $observer) {
255
+ $form = $observer->getForm();
256
+ $customValues = $form->getElement('parcelshop_id');
257
+ if ($customValues) {
258
+ $customValues->setRenderer(
259
+ Mage::app()->getLayout()->createBlock('SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Address_Form_Attr_Parcelshopid')
260
+ ); //set a custom renderer to your attribute
261
+ }
262
+
263
+
264
+
265
+ }
266
+
267
+ }
app/code/community/SynergeticAgency/Gls/Model/Product.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Product
24
+ */
25
+ class SynergeticAgency_Gls_Model_Product extends Mage_Core_Model_Abstract {
26
+
27
+ /**
28
+ * Initialize resource model
29
+ *
30
+ */
31
+ protected function _construct() {
32
+ $this->_init('synergeticagency_gls/product');
33
+ }
34
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Combination.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Combination
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Combination extends Mage_Core_Model_Resource_Abstract {
26
+
27
+ /**
28
+ * Get path to (gls service)combination config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * Resource initialization
35
+ */
36
+ protected function _construct()
37
+ {
38
+ $this->path = Mage::getModuleDir('','SynergeticAgency_Gls').DS.'config'.DS.'combinations.php';
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Retrieve connection for read data
44
+ */
45
+ protected function _getReadAdapter()
46
+ {
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * Retrieve connection for write data
52
+ */
53
+ protected function _getWriteAdapter()
54
+ {
55
+ return false;
56
+ }
57
+
58
+ /**
59
+ * Load GLS combination configuration
60
+ * @param SynergeticAgency_Gls_Model_Combination $object
61
+ * @param $value
62
+ * @param null $field
63
+ * @return $this
64
+ */
65
+ public function load(SynergeticAgency_Gls_Model_Combination $object, $value, $field = null)
66
+ {
67
+ if (is_null($field)) {
68
+ $field = $this->getIdFieldName();
69
+ }
70
+
71
+ if (!is_null($value)) {
72
+ $data = null;
73
+ $combinations = new Zend_Config(include($this->path));
74
+ foreach($combinations->combinations as $combination) {
75
+ if($combination->get($field, null) == $value ) {
76
+ $data = $combination;
77
+ break;
78
+ }
79
+ }
80
+
81
+ if ($data) {
82
+ $object->setData($data->toArray());
83
+ }
84
+ }
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Get the name of the field (array index) holding the combination id
91
+ * @return string
92
+ */
93
+ public function getIdFieldName() {
94
+ return 'id';
95
+ }
96
+
97
+ /**
98
+ * Get path to combination config file
99
+ * @return mixed
100
+ */
101
+ public function getPath() {
102
+ return $this->path;
103
+ }
104
+
105
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Combination/Collection.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource\Combination
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Combination_Collection
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Combination_Collection extends Varien_Data_Collection {
26
+
27
+ /**
28
+ * path to combination config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * constructor - set path and parent construct
35
+ */
36
+ public function __construct()
37
+ {
38
+ $this->path = Mage::getResourceModel('synergeticagency_gls/combination')->getPath();
39
+ parent::__construct();
40
+ }
41
+ /**
42
+ * Load data
43
+ *
44
+ * @param bool $printQuery
45
+ * @param bool $logQuery
46
+ * @return $this
47
+ */
48
+ public function load($printQuery = false, $logQuery = false)
49
+ {
50
+ if (empty($this->_items)) {
51
+ $combinations = new Zend_Config(include($this->path));
52
+
53
+ foreach ($combinations->combinations as $combination) {
54
+ $add = true;
55
+
56
+ foreach($this->_filters as $filter) {
57
+ $product = Mage::getModel('synergeticagency_gls/product')->load($combination->product);
58
+ if($filter['field'] == 'national' && $product->getNational() != $filter['value']) {
59
+ $add = false;
60
+ }
61
+ }
62
+ if($add) {
63
+ $item = Mage::getModel('synergeticagency_gls/combination');
64
+ $item->setData($combination->toArray());
65
+ $this->addItem($item);
66
+ }
67
+ }
68
+ }
69
+ return $this;
70
+ }
71
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Country.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Country
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Country extends Mage_Core_Model_Resource_Abstract {
26
+
27
+ /**
28
+ * Path to country config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * constructor - set path to country config file
35
+ * Resource initialization
36
+ */
37
+ protected function _construct()
38
+ {
39
+ $this->path = Mage::getModuleDir('','SynergeticAgency_Gls').DS.'config'.DS.'countries.php';
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Retrieve connection for read data
45
+ */
46
+ protected function _getReadAdapter()
47
+ {
48
+ return false;
49
+ }
50
+
51
+ /**
52
+ * Retrieve connection for write data
53
+ */
54
+ protected function _getWriteAdapter()
55
+ {
56
+ return false;
57
+ }
58
+
59
+ /**
60
+ * Load GLS country configuration
61
+ * @param SynergeticAgency_Gls_Model_Country $object
62
+ * @param $value
63
+ * @param null $field
64
+ * @return $this
65
+ */
66
+ public function load(SynergeticAgency_Gls_Model_Country $object, $value, $field = null)
67
+ {
68
+ if (is_null($field)) {
69
+ $field = $this->getIdFieldName();
70
+ }
71
+
72
+ if (!is_null($value)) {
73
+ $data = null;
74
+ $countries = new Zend_Config(include($this->path));
75
+ foreach($countries->countries as $country) {
76
+ if($country->get($field, null) == $value ) {
77
+ $data = $country;
78
+ break;
79
+ }
80
+ }
81
+
82
+ if ($data) {
83
+ $object->setData($data->toArray());
84
+ }
85
+ }
86
+
87
+ return $this;
88
+ }
89
+
90
+ /**
91
+ * Get the name of the field (array index) holding the country id
92
+ * @return string
93
+ */
94
+ public function getIdFieldName() {
95
+ return 'id';
96
+ }
97
+
98
+ /**
99
+ * Get path to combination config file
100
+ * @return mixed
101
+ */
102
+ public function getPath() {
103
+ return $this->path;
104
+ }
105
+
106
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Country/Collection.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource\Country
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Country_Collection
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Country_Collection extends Varien_Data_Collection {
26
+
27
+ /**
28
+ * path to country config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * constructor - setting path to config file and parent construct
35
+ */
36
+ public function __construct()
37
+ {
38
+ $this->path = Mage::getResourceModel('synergeticagency_gls/country')->getPath();
39
+ parent::__construct();
40
+ }
41
+ /**
42
+ * Load data
43
+ *
44
+ * @param bool $printQuery
45
+ * @param bool $logQuery
46
+ * @return $this
47
+ */
48
+ public function load($printQuery = false, $logQuery = false)
49
+ {
50
+ if (empty($this->_items)) {
51
+ $countries = new Zend_Config(include($this->path));
52
+
53
+ foreach ($countries->countries as $country) {
54
+ $add = true;
55
+
56
+ // @TODO
57
+ /*foreach($this->_filters as $filter) {
58
+ $product = Mage::getModel('synergeticagency_gls/country')->load($country->product);
59
+ if($filter['field'] == 'national' && $product->getNational() != $filter['value']) {
60
+ $add = false;
61
+ }
62
+ }*/
63
+ if($add) {
64
+ $item = Mage::getModel('synergeticagency_gls/country');
65
+ $item->setData($country->toArray());
66
+ $this->addItem($item);
67
+ }
68
+ }
69
+ }
70
+ return $this;
71
+ }
72
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Product.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Product
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Product extends Mage_Core_Model_Resource_Abstract {
26
+
27
+ /**
28
+ * path to product config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * Resource initialization
35
+ */
36
+ protected function _construct()
37
+ {
38
+ $this->path = Mage::getModuleDir('','SynergeticAgency_Gls').DS.'config'.DS.'products.php';
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Retrieve connection for read data
44
+ */
45
+ protected function _getReadAdapter()
46
+ {
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * Retrieve connection for write data
52
+ */
53
+ protected function _getWriteAdapter()
54
+ {
55
+ return false;
56
+ }
57
+
58
+ /**
59
+ * Load GLS product configuration
60
+ * @param SynergeticAgency_Gls_Model_Product $object
61
+ * @param $value
62
+ * @param null $field
63
+ * @return $this
64
+ */
65
+ public function load(SynergeticAgency_Gls_Model_Product $object, $value, $field = null)
66
+ {
67
+ if (is_null($field)) {
68
+ $field = $this->getIdFieldName();
69
+ }
70
+
71
+ if (!is_null($value)) {
72
+ $data = null;
73
+ $products = new Zend_Config(include($this->path));
74
+ foreach($products->products as $product) {
75
+ if($product->get($field, null) == $value ) {
76
+ $data = $product;
77
+ break;
78
+ }
79
+ }
80
+
81
+ if ($data) {
82
+ $object->setData($data->toArray());
83
+ }
84
+ }
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Get the name of the field (array index) holding the product id
91
+ * @return string
92
+ */
93
+ public function getIdFieldName() {
94
+ return 'id';
95
+ }
96
+
97
+
98
+ /**
99
+ * Get path to product config file
100
+ * @return mixed
101
+ */
102
+ public function getPath() {
103
+ return $this->path;
104
+ }
105
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Product/Collection.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource\Collection
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Product_Collection
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Product_Collection extends Varien_Data_Collection {
26
+
27
+ /**
28
+ * path to product config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * constructor setting path to config file and parent construct
35
+ */
36
+ public function __construct()
37
+ {
38
+ $this->path = Mage::getResourceModel('synergeticagency_gls/product')->getPath();
39
+ parent::__construct();
40
+ }
41
+ /**
42
+ * Load data
43
+ *
44
+ * @param bool $printQuery
45
+ * @param bool $logQuery
46
+ * @return $this
47
+ */
48
+ public function load($printQuery = false, $logQuery = false)
49
+ {
50
+ if (empty($this->_items)) {
51
+ $products = new Zend_Config(include($this->path));
52
+
53
+ foreach ($products->products as $product) {
54
+ $add = true;
55
+ foreach($this->_filters as $filter) {
56
+ if(isset($product->{$filter['field']}) && $product->{$filter['field']} != $filter['value']) {
57
+ $add = false;
58
+ }
59
+ }
60
+ if($add) {
61
+ $item = Mage::getModel('synergeticagency_gls/product');
62
+ $item->setData($product->toArray());
63
+ $this->addItem($item);
64
+ }
65
+ }
66
+ }
67
+ return $this;
68
+ }
69
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Service.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Service
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Service extends Mage_Core_Model_Resource_Abstract {
26
+
27
+ /**
28
+ * Path to service config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * Resource initialization
35
+ */
36
+ protected function _construct()
37
+ {
38
+ $this->path = Mage::getModuleDir('','SynergeticAgency_Gls').DS.'config'.DS.'services.php';
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Retrieve connection for read data
44
+ */
45
+ protected function _getReadAdapter()
46
+ {
47
+ return false;
48
+ }
49
+
50
+ /**
51
+ * Retrieve connection for write data
52
+ */
53
+ protected function _getWriteAdapter()
54
+ {
55
+ return false;
56
+ }
57
+
58
+ /**
59
+ * Load GLS service configuration
60
+ * @param SynergeticAgency_Gls_Model_Service $object
61
+ * @param $value
62
+ * @param null $field
63
+ * @return $this
64
+ */
65
+ public function load(SynergeticAgency_Gls_Model_Service $object, $value, $field = null)
66
+ {
67
+ if (is_null($field)) {
68
+ $field = $this->getIdFieldName();
69
+ }
70
+
71
+ if (!is_null($value)) {
72
+ $data = null;
73
+ $products = new Zend_Config(include($this->path));
74
+ foreach($products->services as $service) {
75
+ if($service->get($field, null) == $value ) {
76
+ $data = $service;
77
+ break;
78
+ }
79
+ }
80
+
81
+ if ($data) {
82
+ $object->setData($data->toArray());
83
+ }
84
+ }
85
+
86
+ return $this;
87
+ }
88
+
89
+ /**
90
+ * Get the name of the field (array index) holding the service id
91
+ * @return string
92
+ */
93
+ public function getIdFieldName() {
94
+ return 'id';
95
+ }
96
+
97
+ /**
98
+ * Get path to service config file
99
+ * @return mixed
100
+ */
101
+ public function getPath() {
102
+ return $this->path;
103
+ }
104
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Service/Collection.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model\Resource\Service
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Resource_Service_Collection
24
+ */
25
+ class SynergeticAgency_Gls_Model_Resource_Service_Collection extends Varien_Data_Collection {
26
+
27
+ /**
28
+ * path to service config file
29
+ * @var
30
+ */
31
+ private $path;
32
+
33
+ /**
34
+ * service id to get service by id
35
+ * @var
36
+ */
37
+ private $idFilter;
38
+
39
+ /**
40
+ * constructor
41
+ */
42
+ public function __construct()
43
+ {
44
+ $this->path = Mage::getResourceModel('synergeticagency_gls/service')->getPath();
45
+ parent::__construct();
46
+ }
47
+
48
+ /**
49
+ * Load GLS services configuration
50
+ *
51
+ * @param bool $printQuery
52
+ * @param bool $logQuery
53
+ * @return $this
54
+ */
55
+ public function load($printQuery = false, $logQuery = false)
56
+ {
57
+ if (empty($this->_items)) {
58
+ $services = new Zend_Config(include($this->path));
59
+
60
+ foreach ($services->services as $service) {
61
+ $add=true;
62
+
63
+ $idFilter = $this->getIdFilter();
64
+ if(!empty($idFilter)) {
65
+ if(!in_array($service->id,$idFilter)) {
66
+ $add = false;
67
+ }
68
+ }
69
+
70
+ foreach($this->_filters as $filter) {
71
+ if(isset($service->{$filter['field']}) && $service->{$filter['field']} != $filter['value']) {
72
+ $add = false;
73
+ }
74
+ }
75
+ if($add) {
76
+ $item = Mage::getModel('synergeticagency_gls/service');;
77
+ $item->setData($service->toArray());
78
+ $this->addItem($item);
79
+ }
80
+ }
81
+ }
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * setter for id filter value
87
+ * @param array $ids
88
+ * @return $this
89
+ */
90
+ public function setIdFilter(array $ids) {
91
+ if(count($ids)) {
92
+ $this->idFilter = $ids;
93
+ }
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * getter for id filter value
99
+ * @return mixed
100
+ */
101
+ public function getIdFilter() {
102
+ return $this->idFilter;
103
+ }
104
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Resource
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment resource model
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Resource_Shipment extends Mage_Core_Model_Resource_Db_Abstract {
35
+
36
+ /**
37
+ * Resource initialization
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment', 'gls_shipment_id');
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Address.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Resource\Shipment
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment address resource model
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Resource_Shipment_Address extends Mage_Core_Model_Resource_Db_Abstract {
35
+
36
+ /**
37
+ * This Constructor initiates synergeticagency_gls/shipment_address using the magic _init function of Mage_Core_Model_Abstract
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment_address', 'gls_shipment_address_id');
41
+ }
42
+
43
+ /**
44
+ * Load data by specified glsShipmentId
45
+ *
46
+ * @param int $glsShipmentId
47
+ * @return false|array
48
+ */
49
+ public function loadByGlsShipmentId($glsShipmentId)
50
+ {
51
+ $adapter = $this->_getReadAdapter();
52
+
53
+ $select = $adapter->select()
54
+ ->from($this->getMainTable())
55
+ ->where('gls_shipment_id=:gls_shipment_id');
56
+
57
+ $binds = array(
58
+ 'gls_shipment_id' => $glsShipmentId
59
+ );
60
+
61
+ return $adapter->fetchRow($select, $binds);
62
+ }
63
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Address/Collection.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Shipment\Address
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment address collection
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Resource_Shipment_Address_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
35
+
36
+ /**
37
+ * constructor for gls shipment address
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment_address');
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Collection.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Resource\Shipment
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment collection
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Resource_Shipment_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
35
+
36
+ /**
37
+ * constructor for GLS shipment model
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment');
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Parcel.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Resource\Shipment
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment parcel resource model
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Resource_Shipment_Parcel extends Mage_Core_Model_Resource_Db_Abstract {
35
+
36
+ /**
37
+ * This Constructor initiates synergeticagency_gls/shipment_parcel using the magic _init function of Mage_Core_Model_Abstract
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment_parcel', 'gls_shipment_parcel_id');
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Model/Resource/Shipment/Parcel/Collection.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Shipment\Parcel
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment parcel collection
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Resource_Shipment_Parcel_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
35
+
36
+ /**
37
+ * constructor for parcels
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment_parcel');
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Model/Service.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\Model
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Model_Service
24
+ */
25
+ class SynergeticAgency_Gls_Model_Service extends Mage_Core_Model_Abstract {
26
+
27
+ /**
28
+ * Initialize resource model
29
+ *
30
+ */
31
+ protected function _construct() {
32
+ $this->_init('synergeticagency_gls/service');
33
+ }
34
+ }
app/code/community/SynergeticAgency/Gls/Model/Shipment.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment model
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Shipment extends Mage_Core_Model_Abstract {
35
+
36
+ /**
37
+ * Shipments target address
38
+ * @var
39
+ */
40
+ private $_shipmentAddress;
41
+
42
+ /**
43
+ * Shipments parcels
44
+ * @var
45
+ */
46
+ private $_shipmentParcels;
47
+
48
+ /**
49
+ * Initialize resource model
50
+ *
51
+ */
52
+ protected function _construct() {
53
+ $this->_init('synergeticagency_gls/shipment');
54
+ }
55
+
56
+ /**
57
+ * Get the shipment address from GLS Model by id (vs. loading shipment address from Magento Model)
58
+ * @return mixed
59
+ */
60
+ public function getShipmentAddress() {
61
+ if(is_null($this->_shipmentAddress) && $this->getId()) {
62
+ $shipmentAddress = Mage::getModel('synergeticagency_gls/shipment_address')->loadByGlsShipmentId($this->getId());
63
+ if($shipmentAddress && $shipmentAddress->getId()) {
64
+ $this->_shipmentAddress = $shipmentAddress;
65
+ }
66
+ }
67
+ return $this->_shipmentAddress;
68
+ }
69
+
70
+ /**
71
+ * Get parcels for a shipment by shipment id)
72
+ * @return mixed
73
+ */
74
+ public function getShipmentParcels() {
75
+ if(is_null($this->_shipmentParcels) && $this->getId()) {
76
+ $shipmentParcels = Mage::getModel('synergeticagency_gls/shipment_parcel')->getCollection()->addFieldToFilter('gls_shipment_id',$this->getId())->load();
77
+ if($shipmentParcels && count($shipmentParcels)) {
78
+ $this->_shipmentParcels = $shipmentParcels;
79
+ }
80
+ }
81
+ return $this->_shipmentParcels;
82
+ }
83
+
84
+ /**
85
+ * Get shipments GLS (service)combination
86
+ * @return SynergeticAgency_Gls_Model_Combination
87
+ */
88
+ public function getCombination() {
89
+ $combinationModel = Mage::getModel('synergeticagency_gls/combination');
90
+ $combinationId = $this->getCombinationId();
91
+ if($combinationId) {
92
+ $combinationModel->load($combinationId);
93
+ }
94
+ return $combinationModel;
95
+ }
96
+
97
+ /**
98
+ * Get shipments additional GLS services
99
+ * @param bool $addonOnly
100
+ * @return SynergeticAgency_Gls_Model_Resource_Service_Collection
101
+ */
102
+ public function getServices($addonOnly=false) {
103
+ $serviceCollection = Mage::getModel('synergeticagency_gls/service')->getCollection();
104
+ $serviceIds = $this->getGlsServices();
105
+ if( $serviceIds === NULL ){
106
+ $serviceIds = "";
107
+ }
108
+
109
+ if( !empty($serviceIds) ) {
110
+ $serviceIds = explode(',',$serviceIds);
111
+ $serviceCollection->setIdFilter($serviceIds);
112
+ if($addonOnly) {
113
+ $serviceCollection->addFilter('is_addon',true);
114
+ }
115
+ $serviceCollection->load();
116
+ return $serviceCollection;
117
+ }
118
+ return array();
119
+ }
120
+ }
app/code/community/SynergeticAgency/Gls/Model/Shipment/Address.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Shipment
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment address model
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Shipment_Address extends Mage_Core_Model_Abstract {
35
+
36
+ /**
37
+ * This Constructor initiates synergeticagency_gls/shipment_address using the magic _init function of Mage_Core_Model_Abstract
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment_address');
41
+ }
42
+
43
+ /**
44
+ * Load gls shipment address by glsShipmentId
45
+ *
46
+ * @param string $glsShipmentId
47
+ * @return SynergeticAgency_Gls_Model_Shipment_Address
48
+ */
49
+ public function loadByGlsShipmentId($glsShipmentId)
50
+ {
51
+ $this->setData($this->getResource()->loadByGlsShipmentId($glsShipmentId));
52
+ return $this;
53
+ }
54
+ }
app/code/community/SynergeticAgency/Gls/Model/Shipment/Parcel.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\Shipment
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * GLS shipment parcel model
29
+ *
30
+ * @category SynergeticAgency
31
+ * @package SynergeticAgency_Gls
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_Gls_Model_Shipment_Parcel extends Mage_Core_Model_Abstract {
35
+
36
+ /**
37
+ * This Constructor initiates synergeticagency_gls/shipment_parcel using the magic _init function of Mage_Core_Model_Abstract
38
+ */
39
+ protected function _construct() {
40
+ $this->_init('synergeticagency_gls/shipment_parcel');
41
+ }
42
+ }
app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Country.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class SynergeticAgency_Gls_Model_System_Config_Source_Country
29
+ */
30
+ class SynergeticAgency_Gls_Model_System_Config_Source_Country
31
+ {
32
+ /**
33
+ * Options for available shipping countries in magento backend spipping method GLS
34
+ * @var
35
+ */
36
+ protected $_options;
37
+
38
+ /**
39
+ * Getting options for available shipping countries in magento backend spipping method GLS
40
+ * @param bool|false $isMultiselect
41
+ * @return array
42
+ */
43
+ public function toOptionArray($isMultiselect=false)
44
+ {
45
+ if (!$this->_options) {
46
+ $countries = Mage::getResourceModel('directory/country_collection')->load();
47
+ $sort = array();
48
+ foreach($countries as $country) {
49
+ $name = Mage::app()->getLocale()->getCountryTranslation($country->getCountryId());
50
+ if($country->getIso2Code() && !empty($name)) {
51
+ //$this->_options[] = array('value' => $country->getIsoN3Code(), 'label'=> $name);
52
+ if (!empty($name)) {
53
+ $sort[$name] = $country->getIso2Code();
54
+ }
55
+ }
56
+ }
57
+ Mage::helper('core/string')->ksortMultibyte($sort);
58
+ $options = array();
59
+ foreach ($sort as $label => $value) {
60
+ $options[] = array(
61
+ 'value' => $value,
62
+ 'label' => $label
63
+ );
64
+ }
65
+ $this->_options = $options;
66
+ }
67
+
68
+
69
+ $options = $this->_options;
70
+ if(!$isMultiselect){
71
+ array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
72
+ }
73
+
74
+ return $options;
75
+ }
76
+ }
app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Labelsize.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\System\Config\Source
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for GLS labelsize config value selection
29
+ *
30
+ */
31
+ class SynergeticAgency_Gls_Model_System_Config_Source_Labelsize
32
+ {
33
+ /**
34
+ * Options getter
35
+ *
36
+ * @param bool $isMultiselect
37
+ * @return array
38
+ */
39
+ public function toOptionArray( $isMultiselect=false )
40
+ {
41
+ $options = array(
42
+ array('value' => "A6", 'label'=>Mage::helper('synergeticagency_gls')->__('A6')),
43
+ array('value' => "A5", 'label'=>Mage::helper('synergeticagency_gls')->__('A5')),
44
+ array('value' => "A4", 'label'=>Mage::helper('synergeticagency_gls')->__('A4')),
45
+ );
46
+ #$gls = Mage::getModel('synergeticagency_gls/gls');
47
+ #$options = $gls->nationalProductServiceCombinationsToOptionArray(false);
48
+
49
+ #if(!$isMultiselect){
50
+ # array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
51
+ #}
52
+ return $options;
53
+ }
54
+
55
+ /**
56
+ * Get options in "key-value" format
57
+ *
58
+ * @return array
59
+ */
60
+ public function toArray()
61
+ {
62
+ return array(
63
+ "A6" => Mage::helper('synergeticagency_gls')->__('A6'),
64
+ "A5" => Mage::helper('synergeticagency_gls')->__('A5'),
65
+ "A4" => Mage::helper('synergeticagency_gls')->__('A4'),
66
+ );
67
+ }
68
+
69
+ }
app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Payment/Shippingmethods.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\System\Config\Source\Payment
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class Synergeticagency_Gls_Model_System_Config_Source_Payment_Shippingmethods
29
+ */
30
+ class Synergeticagency_Gls_Model_System_Config_Source_Payment_Shippingmethods
31
+ {
32
+
33
+ /**
34
+ * Returns available GLS shipping methods for checkout shipping step
35
+ * @return mixed
36
+ */
37
+ public function toOptionArray()
38
+ {
39
+ return Mage::helper('synergeticagency_gls')->getShippingMethodList(true,true);
40
+ }
41
+ }
app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Product.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\System\Config\Source
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for GLS product config value selection
29
+ *
30
+ */
31
+ class SynergeticAgency_Gls_Model_System_Config_Source_Product
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @param bool $isMultiselect
38
+ * @return array
39
+ */
40
+ public function toOptionArray($isMultiselect=false)
41
+ {
42
+ /*$options = array(
43
+ array('value' => 1, 'label'=>Mage::helper('synergeticagency_gls')->__('BusinessParcel')),
44
+ array('value' => 2, 'label'=>Mage::helper('synergeticagency_gls')->__('BusinessParcel + CashService')),
45
+ array('value' => 3, 'label'=>Mage::helper('synergeticagency_gls')->__('BusinessParcel + Guaranteed24')),
46
+ );*/
47
+ $gls = Mage::getModel('synergeticagency_gls/gls');
48
+ $options = $gls->nationalProductServiceCombinationsToOptionArray(false);
49
+
50
+ if(!$isMultiselect){
51
+ array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
52
+ }
53
+ return $options;
54
+ }
55
+
56
+ /**
57
+ * Get options in "key-value" format
58
+ *
59
+ * @return array
60
+ */
61
+ public function toArray()
62
+ {
63
+ /*return array(
64
+ 1 => Mage::helper('synergeticagency_gls')->__('BusinessParcel'),
65
+ 2 => Mage::helper('synergeticagency_gls')->__('BusinessParcel + CashService'),
66
+ 3 => Mage::helper('synergeticagency_gls')->__('BusinessParcel + Guaranteed24'),
67
+ );*/
68
+ $gls = Mage::getModel('synergeticagency_gls/gls');
69
+ return $gls->nationalProductServiceCombinationsToOptionArray(true);
70
+ }
71
+
72
+ }
app/code/community/SynergeticAgency/Gls/Model/System/Config/Source/Service.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\Model\System\Config\Source
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for GLS service config value selection
29
+ *
30
+ */
31
+ class SynergeticAgency_Gls_Model_System_Config_Source_Service
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @param bool $isMultiselect
38
+ * @return array
39
+ */
40
+ public function toOptionArray($isMultiselect=false)
41
+ {
42
+ /*$options = array(
43
+ array('value' => 1, 'label'=>Mage::helper('synergeticagency_gls')->__('ThinkGreen Service')),
44
+ array('value' => 2, 'label'=>Mage::helper('synergeticagency_gls')->__('FlexDelivery Service')),
45
+ array('value' => 3, 'label'=>Mage::helper('synergeticagency_gls')->__('E-Mail-Notification Service')),
46
+ array('value' => 4, 'label'=>Mage::helper('synergeticagency_gls')->__('PrivateDelivery Service')),
47
+ );*/
48
+
49
+ $gls = Mage::getModel('synergeticagency_gls/gls');
50
+ $options = $gls->addonServicesToOptionArray(false);
51
+
52
+ if(!$isMultiselect){
53
+ array_unshift($options, array('value'=>'', 'label'=> Mage::helper('adminhtml')->__('--Please Select--')));
54
+ }
55
+ return $options;
56
+ }
57
+
58
+ /**
59
+ * Get options in "key-value" format
60
+ *
61
+ * @return array
62
+ */
63
+ public function toArray()
64
+ {
65
+ /*return array(
66
+ 1 => Mage::helper('synergeticagency_gls')->__('ThinkGreen Service'),
67
+ 2 => Mage::helper('synergeticagency_gls')->__('FlexDelivery Service'),
68
+ 3 => Mage::helper('synergeticagency_gls')->__('E-Mail-Notification Service'),
69
+ 4 => Mage::helper('synergeticagency_gls')->__('PrivateDelivery Service'),
70
+ );*/
71
+
72
+ $gls = Mage::getModel('synergeticagency_gls/gls');
73
+ return $gls->addonServicesToOptionArray(false);
74
+ }
75
+
76
+ }
app/code/community/SynergeticAgency/Gls/config/combinations.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\config
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ return [
23
+ 'combinations' => [
24
+ [
25
+ 'id' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL,
26
+ 'product' => SynergeticAgency_Gls_Model_Gls::PRODUCT_BUSINESS_PARCEL,
27
+ 'services' => [],
28
+ ],
29
+ [
30
+ 'id' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE,
31
+ 'product' => SynergeticAgency_Gls_Model_Gls::PRODUCT_BUSINESS_PARCEL,
32
+ 'services' => [
33
+ SynergeticAgency_Gls_Model_Gls::SERVICE_CASHSERVICE,
34
+ ],
35
+ ],
36
+ [
37
+ 'id' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_GUARANTEED,
38
+ 'product' => SynergeticAgency_Gls_Model_Gls::PRODUCT_BUSINESS_PARCEL,
39
+ 'services' => [
40
+ SynergeticAgency_Gls_Model_Gls::SERVICE_GUARANTEED,
41
+ ],
42
+ ],
43
+ [
44
+ 'id' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY,
45
+ 'product' => SynergeticAgency_Gls_Model_Gls::PRODUCT_BUSINESS_PARCEL,
46
+ 'services' => [
47
+ SynergeticAgency_Gls_Model_Gls::SERVICE_SHOPDELIVERY,
48
+ ],
49
+ ],
50
+ [
51
+ 'id' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL,
52
+ 'product' => SynergeticAgency_Gls_Model_Gls::PRODUCT_EUROBUSINESS_PARCEL,
53
+ 'services' => [],
54
+ ],
55
+ [
56
+ 'id' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY,
57
+ 'product' => SynergeticAgency_Gls_Model_Gls::PRODUCT_EUROBUSINESS_PARCEL,
58
+ 'services' => [
59
+ SynergeticAgency_Gls_Model_Gls::SERVICE_SHOPDELIVERY,
60
+ ],
61
+ ],
62
+ ]
63
+ ];
app/code/community/SynergeticAgency/Gls/config/countries.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\config
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ return [
23
+ 'countries' => [
24
+ [
25
+ 'id' => 'DE',
26
+ 'options' => [
27
+ [
28
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL,
29
+ 'addon_services' => [
30
+ SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN,
31
+ SynergeticAgency_Gls_Model_Gls::SERVICE_FLEXDELIVERY,
32
+ ],
33
+ 'domestic' => true,
34
+ 'foreign' => false,
35
+ 'cashservice' => false,
36
+ ],
37
+ [
38
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE,
39
+ 'addon_services' => [
40
+ #SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN,
41
+ ],
42
+ 'domestic' => true,
43
+ 'foreign' => false,
44
+ 'cashservice' => true,
45
+ ],
46
+ [
47
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_GUARANTEED,
48
+ 'addon_services' => [
49
+ #SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN,
50
+ ],
51
+ 'domestic' => true,
52
+ 'foreign' => false,
53
+ 'cashservice' => false,
54
+ ],
55
+ [
56
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY,
57
+ 'addon_services' => [
58
+ SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN,
59
+ ],
60
+ 'domestic' => true,
61
+ 'foreign' => false,
62
+ 'cashservice' => false,
63
+ ],
64
+ [
65
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL,
66
+ 'addon_services' => [
67
+ SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN,
68
+ ],
69
+ 'domestic' => false,
70
+ 'foreign' => true,
71
+ 'cashservice' => false,
72
+ ],
73
+ [
74
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY,
75
+ 'addon_services' => [],
76
+ 'domestic' => false,
77
+ 'foreign' => true,
78
+ 'cashservice' => false,
79
+ ],
80
+ ],
81
+ ],
82
+ [
83
+ 'id' => 'DK',
84
+ 'options' => [
85
+ [
86
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL,
87
+ 'addon_services' => [
88
+ SynergeticAgency_Gls_Model_Gls::SERVICE_EMAILNOTIFICATION,
89
+ SynergeticAgency_Gls_Model_Gls::SERVICE_PRIVATEDELIVERY,
90
+ ],
91
+ 'domestic' => true,
92
+ 'foreign' => false,
93
+ 'cashservice' => false,
94
+ ],
95
+ [
96
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_CASHSERVICE,
97
+ 'addon_services' => [
98
+ SynergeticAgency_Gls_Model_Gls::SERVICE_EMAILNOTIFICATION,
99
+ SynergeticAgency_Gls_Model_Gls::SERVICE_PRIVATEDELIVERY,
100
+ ],
101
+ 'domestic' => true,
102
+ 'foreign' => false,
103
+ 'cashservice' => true,
104
+ ],
105
+ [
106
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_BUSINESS_PARCEL_SHOPDELIVERY,
107
+ 'addon_services' => [],
108
+ 'domestic' => true,
109
+ 'foreign' => false,
110
+ 'cashservice' => false,
111
+ ],
112
+ [
113
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL,
114
+ 'addon_services' => [],
115
+ 'domestic' => false,
116
+ 'foreign' => true,
117
+ 'cashservice' => false,
118
+ ],
119
+ [
120
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL_SHOPDELIVERY,
121
+ 'addon_services' => [],
122
+ 'domestic' => false,
123
+ 'foreign' => true,
124
+ 'cashservice' => false,
125
+ ],
126
+ ],
127
+ ],
128
+ [
129
+ 'id' => 'FI',
130
+ 'options' => [
131
+ [
132
+ 'combination' => SynergeticAgency_Gls_Model_Gls::COMB_EUROBUSINESS_PARCEL,
133
+ 'addon_services' => [],
134
+ 'domestic' => true,
135
+ 'foreign' => true,
136
+ 'cashservice' => false,
137
+ ],
138
+ ],
139
+ ],
140
+ ]
141
+ ];
app/code/community/SynergeticAgency/Gls/config/products.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\config
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ return [
23
+ 'products' => [
24
+ [
25
+ 'id' => SynergeticAgency_Gls_Model_Gls::PRODUCT_BUSINESS_PARCEL,
26
+ 'name' => 'BusinessParcel',
27
+ 'national' => true,
28
+ ],
29
+ [
30
+ 'id' => SynergeticAgency_Gls_Model_Gls::PRODUCT_EUROBUSINESS_PARCEL,
31
+ 'name' => 'EuroBusinessParcel',
32
+ 'national' => false,
33
+ ],
34
+ ]
35
+ ];
app/code/community/SynergeticAgency/Gls/config/services.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\config
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ //notice will show up in packaging form
23
+ return [
24
+ 'services' => [
25
+ [
26
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN,
27
+ 'name' => 'ThinkGreenService',
28
+ 'notice' => '',
29
+ 'is_addon' => true,
30
+ ],
31
+ [
32
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_FLEXDELIVERY,
33
+ 'name' => 'FlexDeliveryService',
34
+ 'notice' => '',
35
+ 'is_addon' => true,
36
+ ],
37
+ [
38
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_EMAILNOTIFICATION,
39
+ 'name' => 'E-Mail-NotificationService',
40
+ 'notice' => '',
41
+ 'is_addon' => true,
42
+ ],
43
+ [
44
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_PRIVATEDELIVERY,
45
+ 'name' => 'PrivateDeliveryService',
46
+ 'notice' => '',
47
+ 'is_addon' => true,
48
+ ],
49
+ [
50
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_CASHSERVICE,
51
+ 'name' => 'CashService',
52
+ 'notice' => '',
53
+ 'is_addon' => false,
54
+ ],
55
+ [
56
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_GUARANTEED,
57
+ 'name' => 'Guaranteed24Service',
58
+ 'notice' => '',
59
+ 'is_addon' => false,
60
+ ],
61
+ [
62
+ 'id' => SynergeticAgency_Gls_Model_Gls::SERVICE_SHOPDELIVERY,
63
+ 'name' => 'ShopDeliveryService',
64
+ 'notice' => '',
65
+ 'is_addon' => false,
66
+ ],
67
+ ]
68
+ ];
app/code/community/SynergeticAgency/Gls/controllers/Adminhtml/Gls/ShipmentController.php ADDED
@@ -0,0 +1,750 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\controllers\Adminhtml\Gls
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController
24
+ */
25
+ class SynergeticAgency_Gls_Adminhtml_Gls_ShipmentController extends Mage_Adminhtml_Controller_Action {
26
+
27
+ /**
28
+ * Logger to track several things in application
29
+ * @var $glsHelperLog SynergeticAgency_Gls_Helper_Log
30
+ */
31
+ private $glsHelperLog;
32
+
33
+
34
+ /**
35
+ * Data helper
36
+ * @var $glsHelperData SynergeticAgency_Gls_Helper_Data
37
+ */
38
+ private $glsHelperData;
39
+
40
+ /**
41
+ * The Constructor. Used i.e. to init the logger
42
+ */
43
+ function _construct(){
44
+ $this->setGlsHelperLog( Mage::helper("synergeticagency_gls/log") );
45
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
46
+
47
+ $this->setGlsHelperData( Mage::helper("synergeticagency_gls/data") );
48
+ }
49
+
50
+
51
+ /**
52
+ * Initialising the sales GLS deliveries view
53
+ */
54
+ public function indexAction()
55
+ {
56
+ $this->_title($this->__('GLS'))->_title($this->__('GLS shipment list'));
57
+ $this->loadLayout();
58
+ $this->_setActiveMenu('sales/sales');
59
+ $this->_addContent($this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_gls_shipment'));
60
+ $this->renderLayout();
61
+ }
62
+
63
+ /**
64
+ * Initialising the sales GLS deliveries grid view
65
+ */
66
+ public function gridAction()
67
+ {
68
+ $this->loadLayout();
69
+ $this->getResponse()->setBody(
70
+ $this->getLayout()->createBlock('synergeticagency_gls/adminhtml_sales_gls_shipment_grid')->toHtml()
71
+ );
72
+ }
73
+
74
+ /**
75
+ * collect data for shipment and create shipment using GLS API Connector
76
+ * @todo Refactor printAction: Too much code in one function ;-(
77
+ * @return null
78
+ * @throws Exception
79
+ * @throws Zend_Locale_Exception
80
+ */
81
+ public function printAction() {
82
+
83
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
84
+
85
+ $glsShipmentId = $this->getRequest()->getParam('id');
86
+ $glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($glsShipmentId);
87
+ $glsShipment->setSandbox( Mage::getStoreConfig('gls/general/sandbox',$glsShipment->getStore()) );
88
+ $glsShipmentAddress = $glsShipment->getShipmentAddress();
89
+ $glsShipmentParcels = $glsShipment->getShipmentParcels();
90
+
91
+ $magentoShipment = Mage::getModel('sales/order_shipment')->load($glsShipment->getShipmentId());
92
+ $store = $magentoShipment->getStore();
93
+
94
+ // do prechecks
95
+ $check = $this->doChecks($magentoShipment,$glsShipment);
96
+ if($check === false) {
97
+ $this->_redirectReferer();
98
+ return null;
99
+ }
100
+
101
+ $connector = $this->getConnector($store);
102
+ $shipment = $this->getShipment($magentoShipment,$glsShipment,$store);
103
+ $deliveryAddress = $this->getDeliveryAddress($shipment,$glsShipmentAddress,$glsShipment);
104
+ if($deliveryAddress === false) {
105
+ $this->_redirectReferer();
106
+ return null;
107
+ }
108
+ $check = $this->setAlternateShipperAddress($shipment,$store);
109
+ if($check === false) {
110
+ $this->_redirectReferer();
111
+ return null;
112
+ }
113
+
114
+ $this->setParcels($glsShipment,$glsShipmentParcels,$store,$magentoShipment,$shipment);
115
+
116
+ if($glsShipment->getReturnLabel() == '1') {
117
+ $check = $this->setReturnAddress($shipment,$store);
118
+ if($check === false) {
119
+ $this->_redirectReferer();
120
+ return null;
121
+ }
122
+ }
123
+
124
+
125
+ // set labelsize
126
+ $shipment->setLabelSize( $this->getGlsHelperData()->getShipmentGlsConfig('labelsize') );
127
+
128
+ // add useful references for shipment such as
129
+ // shipment id concatinated with dash and parcel id, printed date and the controller information
130
+ $shipmentReferences = array();
131
+ foreach( $glsShipmentParcels AS $glsShipmentParcel){
132
+ $shipmentReferences[] = $glsShipment->getId() . "-" . $glsShipmentParcel->getdata()['gls_shipment_parcel_id'];
133
+ }
134
+ $shipmentReferences[] = date( "r" );
135
+ $shipmentReferences[] = basename( __FILE__ );
136
+
137
+ $shipment->setReferences( $shipmentReferences );
138
+
139
+ // add shipment to the connector to be able to send the shipment to the GLS-API
140
+ $connector->setShipment( $shipment );
141
+ $this->getGlsHelperLog()->logApi( __METHOD__, __LINE__, $connector->getShipment()->toJson() );
142
+
143
+ if( $this->getGlsHelperData()->getGeneralGlsConfig('logging_enabled') == 1 ){
144
+ Mage::log( $connector->getShipment()->toJson(), Zend_Log::DEBUG );
145
+ }
146
+
147
+ // SynergeticAgency_Gls_Helper_Log
148
+ try {
149
+ // send shipment to the GLS-API
150
+ $connector->createShipment();
151
+ } catch( Exception $e ){
152
+ $this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00010" );
153
+ $this->_redirectReferer();
154
+ return null;
155
+ }
156
+
157
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS-API Response: ConsignmentId = " . $connector->getShipment()->getConsignmentId(), Zend_Log::INFO );
158
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, $connector->getCurlResponse() );
159
+
160
+
161
+ if( $this->getGlsHelperData()->getGeneralGlsConfig('logging_enabled') == 1 ){
162
+ Mage::log( $connector->getCurlResponse(), Zend_Log::DEBUG );
163
+ }
164
+
165
+ // process response of an sent shipment ----------------------------
166
+ // handle GLS-API Response Errors
167
+ if( $connector->getError()->hasError() === true ){
168
+
169
+ Mage::getSingleton('adminhtml/session')->addError(
170
+ sprintf(Mage::helper('synergeticagency_gls')->__('GLS-API Connector has caused an error: %s'), $connector->getError()->getMessage()) .
171
+ "<br /><textarea name=\"gls_json_debug\" style=\"width: 80%;\">" . $connector->getShipment()->toJson() . $connector->getError()->getModelState( true ) .
172
+ "</textarea><br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00005")
173
+ );
174
+ $this->getGlsHelperLog()->logApi( __METHOD__, __LINE__, "GLS-API Connector has caused an error: " . $connector->getError()->getMessage(), Zend_Log::ERR );
175
+ $this->getGlsHelperLog()->logApi( __METHOD__, __LINE__, $connector->getError()->getModelState(true) );
176
+
177
+ $this->_redirectReferer();
178
+ return null;
179
+ } else {
180
+ // get the shipment object right after the GLS-API Response for further processing
181
+ // i.e. to write the pdf into a file
182
+ /** @var SynergeticAgency_GlsConnector_Model_Shipment $shipmentResponse */
183
+ $shipmentResponse = $connector->getShipment();
184
+
185
+ $consignmentId = $shipmentResponse->getConsignmentId();
186
+ if(empty($consignmentId)) {
187
+ Mage::getSingleton('adminhtml/session')->addError(
188
+ Mage::helper('synergeticagency_gls')->__('No GLS ConsignmentId available or empty in GLS-API shipment response') .
189
+ "<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00006")
190
+ );
191
+ $this->getGlsHelperLog()->logApi( __METHOD__, __LINE__, "No GLS ConsignmentId available or empty in GLS-API shipment response", Zend_Log::ERR );
192
+ $this->_redirectReferer();
193
+ return null;
194
+ }
195
+
196
+ $glsShipment->setConsignmentId($consignmentId);
197
+ $glsShipment->setPrinted(1);
198
+ $glsShipment->save();
199
+
200
+ $parcels = $shipmentResponse->getParcels();
201
+ foreach($parcels as $parcel) {
202
+ $glsParcel = Mage::getModel('synergeticagency_gls/shipment_parcel')->load($parcel->getReferences()[0]);
203
+ if($glsParcel->getId()) {
204
+ $glsParcel->setTrackId($parcel->getTrackId());
205
+ $glsParcel->setLocation($parcel->getLocation());
206
+ $glsParcel->setParcelNumber($parcel->getParcelNumber());
207
+ $glsParcel->save();
208
+
209
+ $track = Mage::getModel('sales/order_shipment_track')
210
+ ->setNumber($parcel->getParcelNumber()) //tracking number / awb number
211
+ ->setCarrierCode(SynergeticAgency_Gls_Model_Carrier::CODE) //carrier code
212
+ ->setTitle(SynergeticAgency_Gls_Model_Carrier::CARRIER_TITLE); //carrier title
213
+ $magentoShipment->addTrack($track);
214
+ }
215
+ }
216
+ $magentoShipment->save();
217
+
218
+
219
+ // handle GLS label response and send header containing label(s) START
220
+ $labelHeaderData = false;
221
+ $labels = $shipmentResponse->getLabels();
222
+ $tmpLabelFilesArray = false;
223
+
224
+ // combine labels, if shipment response has more than one label
225
+ if( is_array($labels) ){
226
+ if( count($labels) > 1 ){
227
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, count($labels) . " Labels in GLS response", Zend_Log::INFO );
228
+ $tmpLabelFilesArray = array();
229
+ $tmpLabelPath = rtrim(Mage::getBaseDir('var') ,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
230
+
231
+ foreach( $labels as $key => $label){
232
+ $savedLabel = $this->decodeAndSaveLabel( $label, $tmpLabelPath . $shipmentResponse->getConsignmentId() . '.' . str_pad ( $key, 3, 0, STR_PAD_RIGHT ) . '.pdf');
233
+ if( $savedLabel !== false && is_readable($savedLabel) ){
234
+ $tmpLabelFilesArray[$key] = $savedLabel;
235
+ }
236
+ }
237
+
238
+ if( count($tmpLabelFilesArray) > 1 ){
239
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "combine " . count($labels) . " GLS Labels into one file", Zend_Log::INFO );
240
+ $combinedFile = $connector->combineLabels( $tmpLabelFilesArray, $target = false );
241
+
242
+ if( is_readable($combinedFile) ){
243
+ $labelHeaderData = file_get_contents( $combinedFile );
244
+ }
245
+ }
246
+
247
+ } else {
248
+ // just for debugging: write and save label START
249
+ #$tmpLabelPath = rtrim(Mage::getBaseDir('var') ,DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
250
+ #if( base64_decode($shipmentResponse->getLabels()[0]) === false ){
251
+ # print "FAILED base64_decode \$shipmentResponse->getLabels()[0]" . $shipmentResponse->getLabels()[0];
252
+ # exit();
253
+ #} else {
254
+ # print "SUCCESS base64_decode \$shipmentResponse->getLabels()[0]:<br><pre>" . ($shipmentResponse->getLabels()[0]) . "</pre><br>";
255
+ # $this->decodeAndSaveLabel( $shipmentResponse->getLabels()[0], $tmpLabelPath . date("Ymd-His") . "." . $shipmentResponse->getConsignmentId() . '.pdf' );
256
+ # exit();
257
+ #}
258
+ // just for debugging: write and save label STOP
259
+
260
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "One label in GLS response", Zend_Log::INFO );
261
+ $labelHeaderData = base64_decode($shipmentResponse->getLabels()[0]);
262
+ }
263
+ }
264
+
265
+ $pdfCheckLine = trim(strtok($labelHeaderData, "\n"));
266
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$pdfCheckLine=" . substr ( $pdfCheckLine, 0, 25 ), Zend_Log::INFO );
267
+ if( !preg_match("/^%PDF-[0-9]+\\.[0-9]+$/", $pdfCheckLine) ){
268
+
269
+ Mage::getSingleton('adminhtml/session')->addError(
270
+ sprintf(Mage::helper('synergeticagency_gls')->__('The label data with GLS-ConsignmentId %s obtained are not correct'), $shipmentResponse->getConsignmentId()) .
271
+ "<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00013")
272
+ );
273
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, sprintf("The label data with GLS-ConsignmentId %s obtained are not correct", $shipmentResponse->getConsignmentId()), Zend_Log::INFO );
274
+
275
+ $glsShipment->setPrinted(0);
276
+ $glsShipment->save();
277
+
278
+ $this->_redirectReferer();
279
+ return null;
280
+ }
281
+
282
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$labelHeaderData=" . substr ( $labelHeaderData, 0, 25 ), Zend_Log::DEBUG );
283
+ if( $labelHeaderData !== false ){
284
+ $this->_prepareDownloadResponse(
285
+ $shipmentResponse->getConsignmentId() . '.pdf',
286
+ $labelHeaderData,
287
+ 'application/pdf'
288
+ );
289
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "Label" . $shipmentResponse->getConsignmentId() . ".pdf sent to header", Zend_Log::INFO );
290
+
291
+ } else {
292
+ Mage::getSingleton('adminhtml/session')->addError(
293
+ sprintf(Mage::helper('synergeticagency_gls')->__('Creation of the label with the GLS-ConsignmentId %s failed'), $shipmentResponse->getConsignmentId()) .
294
+ "<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00012")
295
+ );
296
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, sprintf('Creation of the label with the GLS-ConsignmentId %s failed'), $shipmentResponse->getConsignmentId(), Zend_Log::ERR );
297
+ $this->_redirectReferer();
298
+ return null;
299
+ }
300
+
301
+ // remove temporary saved labels
302
+ if( is_array($tmpLabelFilesArray) && count($tmpLabelFilesArray) > 0 ){
303
+ $removedLabelFiles = $connector->removeLabels( $tmpLabelFilesArray );
304
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, $removedLabelFiles . " temporary files deleted", Zend_Log::INFO );
305
+ }
306
+ // handle GLS label response and send header containing label(s) STOP
307
+ }
308
+ }
309
+
310
+ /**
311
+ * collect data for requested shipment and renders the edit shipment grid
312
+ * @return null
313
+ */
314
+ public function editAction() {
315
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
316
+ $id = $this->getRequest()->getParam('id');
317
+ $glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($id);
318
+ $glsShipment->setSandbox( Mage::getStoreConfig('gls/general/sandbox',$glsShipment->getStore()) );
319
+ if (!$glsShipment->getId() || $glsShipment->getPrinted() == '1') {
320
+ Mage::getSingleton('adminhtml/session')->addError(
321
+ Mage::helper('synergeticagency_gls')->__('GLS Shipment can not be edited') .
322
+ "<br />" . Mage::helper('synergeticagency_gls')->__('The shipment id is not set or found') .
323
+ "<br />" . Mage::helper('synergeticagency_gls')->__('or') .
324
+ "<br />" . Mage::helper('synergeticagency_gls')->__('The label has already been printed') .
325
+ "<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00007")
326
+ );
327
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment can not be edited. " . get_class($glsShipment) . "::id is not set/found or the label has already been printed: " . get_class($glsShipment) . "::printed == 1" , Zend_Log::ERR );
328
+ $this->_redirectReferer();
329
+ return null;
330
+ }
331
+ $shipment = Mage::getModel('sales/order_shipment')->load($glsShipment->getShipmentId());
332
+ Mage::register('current_shipment', $shipment);
333
+ Mage::register('gls_shipment', $glsShipment);
334
+ $this->_title($this->__('GLS'))->_title($this->__('Edit GLS Shipment'));
335
+ $this->loadLayout();
336
+ $this->renderLayout();
337
+ }
338
+
339
+ /**
340
+ * Creates a GLS delivery note by contacting the GLS API
341
+ * @return null
342
+ */
343
+ public function saveAction() {
344
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
345
+ $request = $this->getRequest();
346
+ $shimentId = $request->getParam('shipment_id');
347
+ $id = $request->getParam('id');
348
+ $data = $request->getPost();
349
+ $shipment = Mage::getModel('sales/order_shipment')->load($shimentId);
350
+ $glsShipment = Mage::getModel('synergeticagency_gls/shipment')->load($id);
351
+ $glsShipment->setSandbox( Mage::getStoreConfig('gls/general/sandbox',$shipment->getStore()) );
352
+ if($glsShipment->getPrinted() == '1') {
353
+ Mage::getSingleton('adminhtml/session')->addError(
354
+ Mage::helper('synergeticagency_gls')->__('GLS Shipment can not be saved') .
355
+ "<br />" . Mage::helper('synergeticagency_gls')->__('The label has already been printed') .
356
+ "<br />" . sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00008")
357
+ );
358
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment can not be saved. The label has already been printed: " . get_class($glsShipment) . "::printed == 1" , Zend_Log::ERR );
359
+ $this->_redirect('adminhtml/sales_shipment/view/',array('shipment_id' => $shimentId));
360
+ return null;
361
+ }
362
+
363
+ if($data['ship_with_gls'] === '0') {
364
+ $glsShipment->delete();
365
+ Mage::getSingleton('adminhtml/session')->addNotice(
366
+ Mage::helper('synergeticagency_gls')->__('GLS Shipment successfully deleted')
367
+ );
368
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment successfully deleted" );
369
+ $this->_redirect('adminhtml/sales_shipment/view/',array('shipment_id' => $shimentId));
370
+ return null;
371
+ }
372
+
373
+ $glsModel = Mage::getModel('synergeticagency_gls/gls');
374
+ try {
375
+ $glsModel->saveGlsShipment($data, $shipment, $glsShipment);
376
+ } catch(Exception $e) {
377
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$data: " . var_export($data, 1), Zend_Log::INFO);
378
+ //$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$shipment: " . var_export($shipment, 1), Zend_Log::INFO);
379
+ //$this->getGlsHelperLog()->log( __METHOD__, __LINE__, "\$glsShipment:" . var_export($glsShipment, 1), Zend_Log::INFO);
380
+ $this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be saved', "00009" );
381
+ $this->_redirectReferer();
382
+ return null;
383
+ }
384
+ Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('synergeticagency_gls')->__('GLS Shipment successfully saved'));
385
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Shipment successfully saved", Zend_Log::NOTICE );
386
+ $this->_redirect('adminhtml/sales_shipment/view/',array('shipment_id' => $shimentId));
387
+ }
388
+
389
+ /**
390
+ * Getting the logger
391
+ * @return SynergeticAgency_Gls_Helper_Log
392
+ */
393
+ public function getGlsHelperLog()
394
+ {
395
+ return $this->glsHelperLog;
396
+ }
397
+
398
+ /**
399
+ * Setting the logger
400
+ * @param SynergeticAgency_Gls_Helper_Log $glsHelperLog
401
+ */
402
+ public function setGlsHelperLog($glsHelperLog)
403
+ {
404
+ $this->glsHelperLog = $glsHelperLog;
405
+ }
406
+
407
+ /**
408
+ * @return SynergeticAgency_Gls_Helper_Data
409
+ */
410
+ public function getGlsHelperData()
411
+ {
412
+ return $this->glsHelperData;
413
+ }
414
+
415
+ /**
416
+ * setting teh data helper
417
+ * @param SynergeticAgency_Gls_Helper_Data $glsHelperData
418
+ */
419
+ public function setGlsHelperData($glsHelperData)
420
+ {
421
+ $this->glsHelperData = $glsHelperData;
422
+ }
423
+
424
+
425
+
426
+ /**
427
+ * @param Mage_Sales_Model_Order_Shipment $magentoShipment
428
+ * @param SynergeticAgency_Gls_Model_Shipment $glsShipment
429
+ * @return bool
430
+ */
431
+ private function doChecks($magentoShipment,$glsShipment) {
432
+ if(!$magentoShipment->getId()) {
433
+ Mage::getSingleton('adminhtml/session')->addError(
434
+ Mage::helper('synergeticagency_gls')->__('Magento shipment is missing') .
435
+ sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00001")
436
+ );
437
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "Magento shipment is missing(Error-Code: 00001)", Zend_Log::ERR );
438
+ return false;
439
+ }
440
+
441
+ if($glsShipment->getPrinted() == '1') {
442
+ Mage::getSingleton('adminhtml/session')->addError(
443
+ Mage::helper('synergeticagency_gls')->__('GLS Label is already printed') .
444
+ sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00002")
445
+ );
446
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "GLS Label is already printed(Error-Code: 00002)", Zend_Log::ERR );
447
+ return false;
448
+ }
449
+
450
+
451
+
452
+ $check = Mage::helper('synergeticagency_gls')->checkConfigSettings();
453
+ if($check !== true) {
454
+ $errorDetails = '';
455
+ if( is_array($check) ){
456
+ $errorDetails = "<br />";
457
+ foreach( $check AS $key => $value ){
458
+ $errorDetails.= $key . ": " . $value . "<br />";
459
+ }
460
+ }
461
+
462
+ Mage::getSingleton('adminhtml/session')->addError(
463
+ sprintf(Mage::helper('synergeticagency_gls')->__('The GLS %s has errors or is not complete'), Mage::helper('synergeticagency_gls')->__('Basic configuration')) .
464
+ sprintf(Mage::helper('synergeticagency_gls')->__('(Error-Code: %s)'), "00003") .
465
+ "<br />" . $errorDetails
466
+ );
467
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "The GLS Basic configuration has errors or is not complete(Error-Code: 00003)", Zend_Log::ERR );
468
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, var_export($check,1), Zend_Log::INFO );
469
+
470
+
471
+
472
+ return false;
473
+ }
474
+ return true;
475
+ }
476
+
477
+ /**
478
+ * @param Mage_Core_Model_Store $store
479
+ * @return SynergeticAgency_GlsConnector_Connector
480
+ */
481
+ private function getConnector($store) {
482
+ $connector = new SynergeticAgency_GlsConnector_Connector();
483
+
484
+ // in default sandbox is enabled
485
+ if( Mage::getStoreConfig('gls/general/sandbox',$store) !== '1' ){
486
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "gls/general/sandbox is set to '0'", Zend_Log::INFO );
487
+ $connector->setGlsApiSandbox( false );
488
+ }
489
+
490
+ $connector->setGlsApiUrl(Mage::getStoreConfig('gls/general/api_url',$store));
491
+ $connector->setGlsApiAuthUsername( Mage::getStoreConfig('gls/general/apiAuthUsername',$store) );
492
+ $connector->setGlsApiAuthPassword( Mage::helper('core')->decrypt(Mage::getStoreConfig('gls/general/apiAuthPassword', $store)) );
493
+
494
+ // disabled by default
495
+ if(Mage::getStoreConfig('gls/general/connector_log_enabled',$store) === '1') {
496
+ $connector->getLog()->activate()->setLogFile(Mage::getBaseDir('log').DS.'SynergeticAgency_GlsConnector.log');
497
+ }
498
+ return $connector;
499
+ }
500
+
501
+ /**
502
+ * @param Mage_Sales_Model_Order_Shipment $magentoShipment
503
+ * @param SynergeticAgency_Gls_Model_Shipment $glsShipment
504
+ * @param Mage_Core_Model_Store $store
505
+ * @return SynergeticAgency_GlsConnector_Model_Shipment
506
+ */
507
+ private function getShipment($magentoShipment,$glsShipment,$store) {
508
+ $shipment = new SynergeticAgency_GlsConnector_Model_Shipment();
509
+
510
+
511
+ // reformat date without time
512
+ $shippingDate = date('Y-m-d',strtotime($glsShipment->getShippingDate()));
513
+ $glsShipment->setShippingDate($shippingDate);
514
+ // if shipping date is in the past and label is not printed set it to now
515
+ if(strtotime($shippingDate) < strtotime(date('Y-m-d'))) {
516
+ $shippingDate = date('Y-m-d');
517
+ $glsShipment->setShippingDate($shippingDate);
518
+ $glsShipment->save();
519
+ }
520
+
521
+ // set up shipment basic values
522
+ $shipperId = Mage::getStoreConfig('gls/general/customer_id', $store) .
523
+ " " .
524
+ Mage::getStoreConfig('gls/general/contact_id', $store);
525
+ $shipment
526
+ ->setCustomerId( Mage::getStoreConfig('gls/general/customer_id',$store) )
527
+ ->setContactId( Mage::getStoreConfig('gls/general/contact_id',$store) )
528
+ ->setShipperId($shipperId)
529
+ ->setShipmentDate($glsShipment->getShippingDate() )
530
+ ->setReference( $magentoShipment->getOrder()->getIncrementId() );
531
+ return $shipment;
532
+ }
533
+
534
+ /**
535
+ * @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
536
+ * @param SynergeticAgency_Gls_Model_Shipment_Address $glsShipmentAddress
537
+ * @param SynergeticAgency_Gls_Model_Shipment $glsShipment
538
+ * @return bool|SynergeticAgency_GlsConnector_Model_Address
539
+ */
540
+ private function getDeliveryAddress($shipment,$glsShipmentAddress,$glsShipment) {
541
+
542
+ /** @var SynergeticAgency_GlsConnector_Model_Address $deliveryAddress */
543
+ $deliveryAddress = $shipment->getAddresses( SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_DELIVERY );
544
+
545
+ try {
546
+ $deliveryAddress
547
+ ->setName1( $glsShipmentAddress->getName1())
548
+ ->setName2( $glsShipmentAddress->getName2())
549
+ ->setName3( $glsShipmentAddress->getName3())
550
+ ->setStreet1( $glsShipmentAddress->getStreet1())
551
+ ->setCountry( $glsShipmentAddress->getCountry())
552
+ ->setZipCode($glsShipmentAddress->getZipCode())
553
+ ->setCity( $glsShipmentAddress->getCity())
554
+ ->setEmail( $glsShipmentAddress->getEmail())
555
+ ->setPhone( $glsShipmentAddress->getPhone());
556
+
557
+ $parcelShopId = $glsShipment->getParcelshopId();
558
+ if(!empty($parcelShopId)) {
559
+ // todo: check in name context
560
+ $deliveryAddress->setContact( $glsShipmentAddress->getName1() );
561
+ }
562
+ } catch( Exception $e ){
563
+ $this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00010" );
564
+ return false;
565
+ }
566
+ return $deliveryAddress;
567
+ }
568
+
569
+ /**
570
+ * @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
571
+ * @param Mage_Core_Model_Store $store
572
+ * @return bool
573
+ */
574
+ private function setAlternateShipperAddress($shipment,$store) {
575
+ if(Mage::getStoreConfig('gls/alternative_shipper/alternative_shipper_enabled',$store) === '1' && Mage::helper('synergeticagency_gls')->checkAlternativeShipper($store)) {
576
+ $addressAlternativeShipping = new SynergeticAgency_GlsConnector_Model_Address();
577
+ try {
578
+ $addressAlternativeShipping->setType(SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_ALTERNATIVESHIPPING)
579
+ ->setName1(Mage::getStoreConfig('gls/alternative_shipper/name1',$store))
580
+ ->setName2(Mage::getStoreConfig('gls/alternative_shipper/name2',$store))
581
+ ->setName3(Mage::getStoreConfig('gls/alternative_shipper/name3',$store))
582
+ ->setStreet1(Mage::getStoreConfig('gls/alternative_shipper/street1',$store))
583
+ ->setCountry(Mage::getStoreConfig('gls/alternative_shipper/country',$store))
584
+ ->setZipCode(Mage::getStoreConfig('gls/alternative_shipper/zip_code',$store))
585
+ ->setCity(Mage::getStoreConfig('gls/alternative_shipper/city',$store));
586
+ } catch( Exception $e ){
587
+ $this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00011" );
588
+ return false;
589
+ }
590
+ $shipment->addAddress( $addressAlternativeShipping );
591
+ }
592
+ return true;
593
+ }
594
+
595
+ /**
596
+ * @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
597
+ * @param Mage_Core_Model_Store $store
598
+ * @return bool
599
+ */
600
+ private function setReturnAddress($shipment,$store) {
601
+ if(Mage::helper('synergeticagency_gls')->checkReturnAddress($store)) {
602
+ $addressReturn = new SynergeticAgency_GlsConnector_Model_Address();
603
+ try {
604
+ $addressReturn->setType(SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_RETURN)
605
+ ->setName1(Mage::getStoreConfig('gls/return_address/name1',$store))
606
+ ->setName2(Mage::getStoreConfig('gls/return_address/name2',$store))
607
+ ->setName3(Mage::getStoreConfig('gls/return_address/name3',$store))
608
+ ->setStreet1(Mage::getStoreConfig('gls/return_address/street1',$store))
609
+ ->setCountry(Mage::getStoreConfig('gls/return_address/country',$store))
610
+ ->setZipCode(Mage::getStoreConfig('gls/return_address/zip_code',$store))
611
+ ->setCity(Mage::getStoreConfig('gls/return_address/city',$store));
612
+ } catch( Exception $e ){
613
+ $this->getGlsHelperLog()->logException( $e, __METHOD__, __LINE__, Zend_Log::ERR, 'GLS Shipment could not be created', "00011" );
614
+ return false;
615
+ }
616
+ $shipment->addAddress( $addressReturn );
617
+ }
618
+ return true;
619
+ }
620
+
621
+ /**
622
+ * @param SynergeticAgency_Gls_Model_Shipment $glsShipment
623
+ * @param array $glsShipmentParcels
624
+ * @param Mage_Core_Model_Store $store
625
+ * @param Mage_Sales_Model_Order_Shipment $magentoShipment
626
+ * @param SynergeticAgency_GlsConnector_Model_Shipment $shipment
627
+ */
628
+ private function setParcels($glsShipment,$glsShipmentParcels,$store,$magentoShipment,$shipment) {
629
+
630
+ $glsServices = $glsShipment->getServices();
631
+ $resultingServices = array();
632
+ if($glsServices && count($glsServices)) {
633
+ foreach($glsServices as $glsService) {
634
+ $service = new SynergeticAgency_GlsConnector_Model_Service();
635
+ switch($glsService->getId()) {
636
+ case SynergeticAgency_Gls_Model_Gls::SERVICE_EMAILNOTIFICATION:
637
+ //$service = new SynergeticAgency_GlsConnector_Model_Service();
638
+ //$service->setName( );
639
+ // todo not available anymore??
640
+ //$service->setNotificationEmail($glsShipmentAddress->getEmail());
641
+
642
+ break;
643
+ case SynergeticAgency_Gls_Model_Gls::SERVICE_FLEXDELIVERY:
644
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_FLEXDELIVERYSERVICE );
645
+ break;
646
+ case SynergeticAgency_Gls_Model_Gls::SERVICE_THINKGREEN:
647
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_THINKGREENSERVICE);
648
+ break;
649
+ case SynergeticAgency_Gls_Model_Gls::SERVICE_PRIVATEDELIVERY:
650
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_PRIVATEDELIVERYSERVICE);
651
+ break;
652
+ case SynergeticAgency_Gls_Model_Gls::SERVICE_GUARANTEED:
653
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_GUARANTEED24SERVICE);
654
+ break;
655
+ }
656
+ if(!is_null($service->getName()) && $service->getName() !== '') {
657
+ $resultingServices[] = $service;
658
+ }
659
+ }
660
+ }
661
+
662
+ if($glsShipment->getReturnLabel() === '1' && Mage::helper('synergeticagency_gls')->checkReturnAddress($store)) {
663
+ $service = new SynergeticAgency_GlsConnector_Model_Service();
664
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_SHOPRETURNSERVICE);
665
+ $shipment->setReturnLabel(true);
666
+ $resultingServices[] = $service;
667
+ }
668
+
669
+ foreach($glsShipmentParcels as $parcel) {
670
+ $apiParcel = new SynergeticAgency_GlsConnector_Model_Parcel();
671
+ $apiParcel->setWeight($parcel->getWeight());
672
+ #// sorry, but we cannot use the database table fields
673
+ #// synergeticagency_gls_shipment_parcel.gls_shipment_parcel_id and
674
+ #// synergeticagency_gls_shipment_parcel.gls_shipment_id
675
+ #// as reference for the GLS-API, because the GLS-API just accepts non assosiate arrays here
676
+ #$apiParcel->pushReference( $parcel->getId(), "gls_shipment_parcel_id" );
677
+ #$apiParcel->pushReference( $glsShipment->getId(), "gls_shipment_id" );
678
+ $apiParcel->setReferences( array($parcel->getId()) );
679
+
680
+ if($parcel->getCashservice() > 0) {
681
+ $service = new SynergeticAgency_GlsConnector_Model_Service();
682
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_CASHONDELIVERY);
683
+ $symbols = Zend_Locale_Data::getList(Mage::getStoreConfig('general/locale/code', $store) , 'symbols');
684
+ $info = new SynergeticAgency_GlsConnector_Model_Info();
685
+ $info->setName('amount');
686
+ $info->setValue(round(floatval(str_replace($symbols['decimal'], '.', $parcel->getCashservice())),2));
687
+ // special case: if amount has no dezimal point, add decimal point and zero,
688
+ // because info object is defined as string, but GLS needs "float string"
689
+ if( !strpos($info->getValue() , '.') ){
690
+ $info->setValue( $info->getValue() . ".0" );
691
+ }
692
+ $service->pushInfo($info);
693
+
694
+ $info = new SynergeticAgency_GlsConnector_Model_Info();
695
+ $info->setName('reference');
696
+ $info->setValue($magentoShipment->getOrder()->getIncrementId());
697
+ $service->pushInfo($info);
698
+ $apiParcel->pushService($service);
699
+ }
700
+
701
+ if($glsShipment->getParcelshopId() !== '' && !is_null($glsShipment->getParcelshopId())) {
702
+ $service = new SynergeticAgency_GlsConnector_Model_Service();
703
+ $service->setName( SynergeticAgency_GlsConnector_Model_Service::GLS_API_SERVICE_SHOPDELIVERYSERVICE);
704
+ $info = new SynergeticAgency_GlsConnector_Model_Info();
705
+ $info->setName('parcelshopid');
706
+ $info->setValue($glsShipment->getParcelshopId());
707
+ $service->pushInfo($info);
708
+ $apiParcel->pushService($service);
709
+ }
710
+ if(count($resultingServices))
711
+ {
712
+ foreach($resultingServices as $service) {
713
+ $apiParcel->pushService($service);
714
+ }
715
+ }
716
+ $shipment->pushParcel($apiParcel);
717
+ }
718
+ }
719
+
720
+
721
+ /**
722
+ * decode base64 string and save to $file
723
+ *
724
+ * @param string $label base64 encoded string
725
+ * @param string $file full path/filename to save file
726
+ * @return bool|string $returnValue false, if something went wrong,
727
+ * $filename if saved successful
728
+ */
729
+ private function decodeAndSaveLabel( $label, $file ){
730
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, "entered", Zend_Log::DEBUG );
731
+
732
+ $returnValue = false;
733
+
734
+ $base64decodedLabel = base64_decode($label);
735
+ if( $base64decodedLabel !== false ){
736
+ if (!$handle = fopen($file, "w")) {
737
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, " cannot open file " . $file, Zend_Log::WARN );
738
+ } else {
739
+ if (!fwrite($handle, $base64decodedLabel)) {
740
+ $this->getGlsHelperLog()->log( __METHOD__, __LINE__, " cannot write into file " . $file, Zend_Log::WARN );
741
+ } else {
742
+ $returnValue = $file;
743
+ }
744
+ fclose($handle);
745
+ }
746
+ }
747
+
748
+ return $returnValue;
749
+ }
750
+ }
app/code/community/SynergeticAgency/Gls/controllers/FrontendController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to info@synergetic.ag so we can send you a copy immediately.
14
+ *
15
+ *
16
+ * @category SynergetigAgency
17
+ * @package SynergeticAgency\Gls\controllers\Adminhtml
18
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Class SynergeticAgency_Gls_FrontendController
24
+ */
25
+ class SynergeticAgency_Gls_FrontendController extends Mage_Core_Controller_Front_Action
26
+ {
27
+ /**
28
+ * Shows the map for the parcelshop search
29
+ */
30
+ public function parcelshopmapAction()
31
+ {
32
+ $this->loadLayout();
33
+ $this->renderLayout();
34
+ }
35
+
36
+ /**
37
+ * providing billing country and postcode in checkout step shipping
38
+ * ajax call is done to fetch this
39
+ */
40
+ public function parcelShopMapParamsAction()
41
+ {
42
+ $billingAddress = Mage::getSingleton('checkout/session')->getQuote()->getBillingAddress()->getData();
43
+
44
+ $parcelShopMapParams = array(
45
+ 'country_id' => $billingAddress['country_id'],
46
+ 'postcode' => $billingAddress['postcode']
47
+ );
48
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($parcelShopMapParams));
49
+ $this->getResponse()->setHeader('Content-type', 'application/json');
50
+ }
51
+
52
+ }
app/code/community/SynergeticAgency/Gls/data/synergeticagency_gls_setup/data-install-0.1.0.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\data\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+
30
+ $installer->startSetup();
31
+
32
+
33
+
34
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/data/synergeticagency_gls_setup/data-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\data\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+
30
+ $installer->startSetup();
31
+
32
+ /**
33
+ * all ISO 3166-1 N3 Codes
34
+ */
35
+ $countryArray = array(
36
+ "AF" => "004",
37
+ "AL" => "008",
38
+ "DZ" => "012",
39
+ "AS" => "016",
40
+ "AD" => "020",
41
+ "AO" => "024",
42
+ "AI" => "660",
43
+ "AQ" => "010",
44
+ "AG" => "028",
45
+ "AR" => "032",
46
+ "AM" => "051",
47
+ "AW" => "533",
48
+ "AU" => "036",
49
+ "AT" => "040",
50
+ "AX" => "248",
51
+ "AZ" => "031",
52
+ "BS" => "044",
53
+ "BH" => "048",
54
+ "BD" => "050",
55
+ "BB" => "052",
56
+ "BY" => "112",
57
+ "BE" => "056",
58
+ "BZ" => "084",
59
+ "BJ" => "204",
60
+ "BM" => "060",
61
+ "BT" => "064",
62
+ "BO" => "068",
63
+ "BA" => "070",
64
+ "BW" => "072",
65
+ "BV" => "074",
66
+ "BR" => "076",
67
+ "IO" => "086",
68
+ "VG" => "092",
69
+ "BN" => "096",
70
+ "BG" => "100",
71
+ "BF" => "854",
72
+ "MM" => "104",
73
+ "BI" => "108",
74
+ "CV" => "132",
75
+ "KH" => "116",
76
+ "CM" => "120",
77
+ "CA" => "124",
78
+ "KY" => "136",
79
+ "CF" => "140",
80
+ "TD" => "148",
81
+ "CL" => "152",
82
+ "CN" => "156",
83
+ "CX" => "162",
84
+ "CC" => "166",
85
+ "CO" => "170",
86
+ "KM" => "174",
87
+ "CD" => "180",
88
+ "CG" => "178",
89
+ "CK" => "184",
90
+ "CR" => "188",
91
+ "CI" => "384",
92
+ "HR" => "191",
93
+ "CU" => "192",
94
+ "CW" => "531",
95
+ "CY" => "196",
96
+ "CZ" => "203",
97
+ "DK" => "208",
98
+ "DJ" => "262",
99
+ "DM" => "212",
100
+ "DO" => "214",
101
+ "EC" => "218",
102
+ "EG" => "818",
103
+ "SV" => "222",
104
+ "GQ" => "226",
105
+ "ER" => "232",
106
+ "EE" => "233",
107
+ "ET" => "231",
108
+ "FK" => "238",
109
+ "FO" => "234",
110
+ "FJ" => "242",
111
+ "FI" => "246",
112
+ "FR" => "250",
113
+ "FX" => "249",
114
+ "GF" => "254",
115
+ "PF" => "258",
116
+ "TF" => "260",
117
+ "GA" => "266",
118
+ "GM" => "270",
119
+ "PS" => "275",
120
+ "GE" => "268",
121
+ "DE" => "276",
122
+ "GH" => "288",
123
+ "GI" => "292",
124
+ "GR" => "300",
125
+ "GL" => "304",
126
+ "GD" => "308",
127
+ "GP" => "312",
128
+ "GU" => "316",
129
+ "GT" => "320",
130
+ "GG" => "831",
131
+ "GN" => "324",
132
+ "GW" => "624",
133
+ "GY" => "328",
134
+ "HT" => "332",
135
+ "HM" => "334",
136
+ "VA" => "336",
137
+ "HN" => "340",
138
+ "HK" => "344",
139
+ "HU" => "348",
140
+ "IS" => "352",
141
+ "IN" => "356",
142
+ "ID" => "360",
143
+ "IR" => "364",
144
+ "IQ" => "368",
145
+ "IE" => "372",
146
+ "IM" => "833",
147
+ "IL" => "376",
148
+ "IT" => "380",
149
+ "JM" => "388",
150
+ "JP" => "392",
151
+ "JE" => "832",
152
+ "JO" => "400",
153
+ "KZ" => "398",
154
+ "KE" => "404",
155
+ "KI" => "296",
156
+ "KP" => "408",
157
+ "KR" => "410",
158
+ "KW" => "414",
159
+ "KG" => "417",
160
+ "LA" => "418",
161
+ "LV" => "428",
162
+ "LB" => "422",
163
+ "LS" => "426",
164
+ "LR" => "430",
165
+ "LY" => "434",
166
+ "LI" => "438",
167
+ "LT" => "440",
168
+ "LU" => "442",
169
+ "MO" => "446",
170
+ "MK" => "807",
171
+ "MG" => "450",
172
+ "MW" => "454",
173
+ "MY" => "458",
174
+ "MV" => "462",
175
+ "ML" => "466",
176
+ "MT" => "470",
177
+ "MH" => "584",
178
+ "MQ" => "474",
179
+ "MR" => "478",
180
+ "MU" => "480",
181
+ "YT" => "175",
182
+ "MX" => "484",
183
+ "FM" => "583",
184
+ "MD" => "498",
185
+ "MC" => "492",
186
+ "MN" => "496",
187
+ "ME" => "499",
188
+ "MS" => "500",
189
+ "MA" => "504",
190
+ "MZ" => "508",
191
+ "NA" => "516",
192
+ "NR" => "520",
193
+ "NP" => "524",
194
+ "NL" => "528",
195
+ "NC" => "540",
196
+ "NZ" => "554",
197
+ "NI" => "558",
198
+ "NE" => "562",
199
+ "NG" => "566",
200
+ "NU" => "570",
201
+ "NF" => "574",
202
+ "MP" => "580",
203
+ "NO" => "578",
204
+ "OM" => "512",
205
+ "PK" => "586",
206
+ "PW" => "585",
207
+ "PA" => "591",
208
+ "PG" => "592",
209
+ "PY" => "600",
210
+ "PE" => "604",
211
+ "PH" => "608",
212
+ "PN" => "612",
213
+ "PL" => "616",
214
+ "PT" => "620",
215
+ "PR" => "630",
216
+ "QA" => "634",
217
+ "RE" => "638",
218
+ "RO" => "642",
219
+ "RU" => "643",
220
+ "RW" => "646",
221
+ "BL" => "652",
222
+ "SH" => "654",
223
+ "KN" => "659",
224
+ "LC" => "662",
225
+ "MF" => "663",
226
+ "PM" => "666",
227
+ "VC" => "670",
228
+ "WS" => "882",
229
+ "SM" => "674",
230
+ "ST" => "678",
231
+ "SA" => "682",
232
+ "SN" => "686",
233
+ "RS" => "688",
234
+ "SC" => "690",
235
+ "SL" => "694",
236
+ "SG" => "702",
237
+ "SX" => "534",
238
+ "SK" => "703",
239
+ "SI" => "705",
240
+ "SB" => "090",
241
+ "SO" => "706",
242
+ "ZA" => "710",
243
+ "GS" => "239",
244
+ "SS" => "728",
245
+ "ES" => "724",
246
+ "LK" => "144",
247
+ "SD" => "729",
248
+ "SR" => "740",
249
+ "SJ" => "744",
250
+ "SZ" => "748",
251
+ "SE" => "752",
252
+ "CH" => "756",
253
+ "SY" => "760",
254
+ "TW" => "158",
255
+ "TJ" => "762",
256
+ "TZ" => "834",
257
+ "TH" => "764",
258
+ "TL" => "626",
259
+ "TG" => "768",
260
+ "TK" => "772",
261
+ "TO" => "776",
262
+ "TT" => "780",
263
+ "TN" => "788",
264
+ "TR" => "792",
265
+ "TM" => "795",
266
+ "TC" => "796",
267
+ "TV" => "798",
268
+ "UG" => "800",
269
+ "UA" => "804",
270
+ "AE" => "784",
271
+ "GB" => "826",
272
+ "US" => "840",
273
+ "UM" => "581",
274
+ "UY" => "858",
275
+ "UZ" => "860",
276
+ "VU" => "548",
277
+ "VE" => "862",
278
+ "VN" => "704",
279
+ "VI" => "850",
280
+ "WF" => "876",
281
+ "EH" => "732",
282
+ "YE" => "887",
283
+ "ZM" => "894",
284
+ "ZW" => "716"
285
+ );
286
+
287
+ /**
288
+ * add the ISO 3166-1 N3 codes to available countries
289
+ */
290
+ $countries = Mage::getModel('directory/country')->getCollection();
291
+ foreach($countries as $country) {
292
+ if(isset($countryArray[$country->getIso2Code()])) {
293
+ $bind = array(
294
+ 'iso_n3_code' => $countryArray[$country->getIso2Code()],
295
+ );
296
+ $installer->getConnection()->update($installer->getTable('directory/country'), $bind, array('country_id = ?' => $country->getCountryId()));
297
+ }
298
+ }
299
+
300
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/etc/adminhtml.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <sales>
5
+ <children>
6
+ <gls_shipments translate="title" module="synergeticagency_gls">
7
+ <title>GLS Shipments</title>
8
+ <action>adminhtml/gls_shipment/</action>
9
+ <sort_order>35</sort_order>
10
+ </gls_shipments>
11
+ </children>
12
+ </sales>
13
+ </menu>
14
+ <acl>
15
+ <resources>
16
+ <admin>
17
+ <children>
18
+ <sales>
19
+ <children>
20
+ <gls_shipments translate="title">
21
+ <title>GLS Shipments</title>
22
+ </gls_shipments>
23
+ </children>
24
+ </sales>
25
+ <system>
26
+ <children>
27
+ <config>
28
+ <children>
29
+ <gls translate="title" module="synergeticagency_gls">
30
+ <title>GLS Shipments</title>
31
+ </gls>
32
+ </children>
33
+ </config>
34
+ </children>
35
+ </system>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </config>
app/code/community/SynergeticAgency/Gls/etc/config.xml ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SynergeticAgency_Gls>
5
+ <version>1.0.0</version>
6
+ </SynergeticAgency_Gls>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <synergeticagency_gls>
11
+ <class>SynergeticAgency_Gls_Model</class>
12
+ <resourceModel>synergeticagency_gls_resource</resourceModel>
13
+ </synergeticagency_gls>
14
+ <synergeticagency_gls_resource>
15
+ <class>SynergeticAgency_Gls_Model_Resource</class>
16
+ <entities>
17
+ <shipment>
18
+ <table>synergeticagency_gls_shipment</table>
19
+ </shipment>
20
+ <shipment_parcel>
21
+ <table>synergeticagency_gls_shipment_parcel</table>
22
+ </shipment_parcel>
23
+ <shipment_address>
24
+ <table>synergeticagency_gls_shipment_address</table>
25
+ </shipment_address>
26
+ </entities>
27
+ </synergeticagency_gls_resource>
28
+ </models>
29
+ <blocks>
30
+ <synergeticagency_gls>
31
+ <class>SynergeticAgency_Gls_Block</class>
32
+ </synergeticagency_gls>
33
+ <adminhtml>
34
+ <rewrite>
35
+ <sales_order_shipment_create_tracking>SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_Create_Tracking</sales_order_shipment_create_tracking>
36
+ </rewrite>
37
+ <rewrite>
38
+ <sales_order_shipment_view_tracking>SynergeticAgency_Gls_Block_Adminhtml_Sales_Order_Shipment_View_Tracking</sales_order_shipment_view_tracking>
39
+ </rewrite>
40
+ </adminhtml>
41
+ </blocks>
42
+ <helpers>
43
+ <synergeticagency_gls>
44
+ <class>SynergeticAgency_Gls_Helper</class>
45
+ </synergeticagency_gls>
46
+ </helpers>
47
+ <resources>
48
+ <synergeticagency_gls_setup>
49
+ <setup>
50
+ <module>SynergeticAgency_Gls</module>
51
+ <class>Mage_Customer_Model_Resource_Setup</class>
52
+ </setup>
53
+ </synergeticagency_gls_setup>
54
+ </resources>
55
+ <fieldsets>
56
+ <sales_copy_order_billing_address>
57
+ <parcelshop_name>
58
+ <to_order>*</to_order>
59
+ </parcelshop_name>
60
+ <parcelshop_id>
61
+ <to_order>*</to_order>
62
+ </parcelshop_id>
63
+ </sales_copy_order_billing_address>
64
+ <sales_copy_order_shipping_address>
65
+ <parcelshop_name>
66
+ <to_order>*</to_order>
67
+ </parcelshop_name>
68
+ <parcelshop_id>
69
+ <to_order>*</to_order>
70
+ </parcelshop_id>
71
+ </sales_copy_order_shipping_address>
72
+ <sales_convert_quote_address>
73
+ <parcelshop_name>
74
+ <to_order_address>*</to_order_address>
75
+ </parcelshop_name>
76
+ <parcelshop_id>
77
+ <to_order_address>*</to_order_address>
78
+ </parcelshop_id>
79
+ <parcelshop_active>
80
+ <to_order_address>*</to_order_address>
81
+ </parcelshop_active>
82
+ </sales_convert_quote_address>
83
+ <sales_convert_order_address>
84
+ <parcelshop_name>
85
+ <to_quote_address>*</to_quote_address>
86
+ </parcelshop_name>
87
+ <parcelshop_id>
88
+ <to_quote_address>*</to_quote_address>
89
+ </parcelshop_id>
90
+ <parcelshop_active>
91
+ <to_quote_address>*</to_quote_address>
92
+ </parcelshop_active>
93
+ </sales_convert_order_address>
94
+ <customer_address>
95
+ <parcelshop_name>
96
+ <to_quote_address>*</to_quote_address>
97
+ <to_order_address>*</to_order_address>
98
+ </parcelshop_name>
99
+ <parcelshop_id>
100
+ <to_quote_address>*</to_quote_address>
101
+ <to_order_address>*</to_order_address>
102
+ </parcelshop_id>
103
+ <parcelshop_active>
104
+ <to_quote_address>*</to_quote_address>
105
+ <to_order_address>*</to_order_address>
106
+ </parcelshop_active>
107
+ </customer_address>
108
+ </fieldsets>
109
+ </global>
110
+ <crontab>
111
+ <jobs>
112
+ <synergeticagency_gls_jsonconfig_import>
113
+ <schedule><cron_expr>*/10 * * * *</cron_expr></schedule>
114
+ <run><model>synergeticagency_gls/jsonimport::run</model></run>
115
+ </synergeticagency_gls_jsonconfig_import>
116
+ </jobs>
117
+ </crontab>
118
+ <adminhtml>
119
+ <translate>
120
+ <modules>
121
+ <SynergeticAgency_Gls>
122
+ <files>
123
+ <default>SynergeticAgency_Gls.csv</default>
124
+ </files>
125
+ </SynergeticAgency_Gls>
126
+ </modules>
127
+ </translate>
128
+ <events>
129
+ <controller_action_layout_render_before_adminhtml_system_config_edit>
130
+ <observers>
131
+ <gls_controller_action_layout_render_before_adminhtml_system_config_edit>
132
+ <class>synergeticagency_gls/observer</class>
133
+ <method>setCountryModel</method>
134
+ </gls_controller_action_layout_render_before_adminhtml_system_config_edit>
135
+ </observers>
136
+ </controller_action_layout_render_before_adminhtml_system_config_edit>
137
+ <controller_action_postdispatch_adminhtml_sales_order_shipment_save>
138
+ <observers>
139
+ <save_gls_shipment_data>
140
+ <class>synergeticagency_gls/observer</class>
141
+ <method>saveShipmentData</method>
142
+ </save_gls_shipment_data>
143
+ </observers>
144
+ </controller_action_postdispatch_adminhtml_sales_order_shipment_save>
145
+ <sales_order_shipment_save_before>
146
+ <observers>
147
+ <check_gls_shipment_data>
148
+ <class>synergeticagency_gls/observer</class>
149
+ <method>checkGlsShipmentData</method>
150
+ </check_gls_shipment_data>
151
+ </observers>
152
+ </sales_order_shipment_save_before>
153
+ <adminhtml_widget_container_html_before>
154
+ <observers>
155
+ <add_gls_pdf_button_to_order>
156
+ <class>synergeticagency_gls/observer</class>
157
+ <method>addGlsPdfButtonToOrder</method>
158
+ </add_gls_pdf_button_to_order>
159
+ </observers>
160
+ </adminhtml_widget_container_html_before>
161
+ <adminhtml_block_html_before>
162
+ <observers>
163
+ <synergeticagency_gls_ordergrid_adminhtml_block_html_before>
164
+ <class>synergeticagency_gls/observer</class>
165
+ <method>beforeBlockToHtml</method>
166
+ </synergeticagency_gls_ordergrid_adminhtml_block_html_before>
167
+ </observers>
168
+ </adminhtml_block_html_before>
169
+ </events>
170
+ <layout>
171
+ <updates>
172
+ <synergeticagency_gls>
173
+ <file>synergeticagency/gls.xml</file>
174
+ </synergeticagency_gls>
175
+ </updates>
176
+ </layout>
177
+ </adminhtml>
178
+ <admin>
179
+ <routers>
180
+ <adminhtml>
181
+ <args>
182
+ <modules>
183
+ <SynergeticAgency_Gls after="Mage_Adminhtml">SynergeticAgency_Gls_Adminhtml</SynergeticAgency_Gls>
184
+ </modules>
185
+ </args>
186
+ </adminhtml>
187
+ </routers>
188
+ </admin>
189
+ <frontend>
190
+ <events>
191
+ <core_block_abstract_to_html_after>
192
+ <observers>
193
+ <!-- todo: please use another more descripable name instead of "gls_core_block_abstract_to_html_after" here -->
194
+ <gls_core_block_abstract_to_html_after>
195
+ <class>synergeticagency_gls/observer</class>
196
+ <method>setGlsShippingLogos</method>
197
+ </gls_core_block_abstract_to_html_after>
198
+ </observers>
199
+ </core_block_abstract_to_html_after>
200
+ </events>
201
+ <translate>
202
+ <modules>
203
+ <SynergeticAgency_Gls>
204
+ <files>
205
+ <default>SynergeticAgency_Gls.csv</default>
206
+ </files>
207
+ </SynergeticAgency_Gls>
208
+ </modules>
209
+ </translate>
210
+ <layout>
211
+ <updates>
212
+ <synergeticagency_gls>
213
+ <file>synergeticagency/gls.xml</file>
214
+ </synergeticagency_gls>
215
+ </updates>
216
+ </layout>
217
+ <routers>
218
+ <synergeticagency_gls>
219
+ <use>standard</use>
220
+ <args>
221
+ <module>SynergeticAgency_Gls</module>
222
+ <frontName>gls</frontName>
223
+ </args>
224
+ </synergeticagency_gls>
225
+ </routers>
226
+ </frontend>
227
+ <default>
228
+ <gls>
229
+ <general>
230
+ <active>0</active>
231
+ <sandbox>0</sandbox>
232
+ <logging_enabled>0</logging_enabled>
233
+ <debug_enabled>0</debug_enabled>
234
+ <connector_log_enabled>0</connector_log_enabled>
235
+ <api_url><![CDATA[https://api.gls-group.eu/public/v1/]]></api_url>
236
+ <json_url><![CDATA[https://gls-group.eu/glsmagentoplugin/gls-magento-config.json]]></json_url>
237
+ <tracking_url><![CDATA[https://www.gls-one.eu/#/trace?query=]]></tracking_url>
238
+ </general>
239
+ <shipment>
240
+ <weight>0</weight>
241
+ <return_label_enabled>0</return_label_enabled>
242
+ <labelsize>A6</labelsize>
243
+ </shipment>
244
+ <alternative_shipper>
245
+ <alternative_shipper_enabled>0</alternative_shipper_enabled>
246
+ </alternative_shipper>
247
+ <parcel_shop>
248
+ <parcel_shop_enabled>0</parcel_shop_enabled>
249
+ <parcel_shop_css_enabled>1</parcel_shop_css_enabled>
250
+ <parcel_shop_url><![CDATA[https://gls-one.eu/#/parcelShopsExtern]]></parcel_shop_url>
251
+ </parcel_shop>
252
+ </gls>
253
+ <carriers>
254
+ <synergeticagency_gls>
255
+ <active>0</active>
256
+ <sort_order>10</sort_order>
257
+ <model>synergeticagency_gls/carrier</model>
258
+ <title>GLS</title>
259
+ <sort_order>10</sort_order>
260
+ <sallowspecific>0</sallowspecific>
261
+ <showmethod>0</showmethod>
262
+ <active_foreigncountries>1</active_foreigncountries>
263
+ <name_foreigncountries>Europaversand - Zustellzeit je nach Zielland</name_foreigncountries>
264
+ <show_logo_foreigncountries>1</show_logo_foreigncountries>
265
+ <price_per_order_foreigncountries>0.00</price_per_order_foreigncountries>
266
+ <active_express>1</active_express>
267
+ <name_express>24h-Express - Garantierte Zustellung am nächsten Werktag (nach Versand) bis 17 Uhr</name_express>
268
+ <show_logo_express>1</show_logo_express>
269
+ <price_per_order_express>0.00</price_per_order_express>
270
+ <active_standard>1</active_standard>
271
+ <name_standard>Standardversand - Zustellung in 1-2 Werktagen (nach Versand)</name_standard>
272
+ <show_logo_standard>1</show_logo_standard>
273
+ <price_per_order_standard>0.00</price_per_order_standard>
274
+ </synergeticagency_gls>
275
+ </carriers>
276
+ <payment>
277
+ <glscashondelivery>
278
+ <active>0</active>
279
+ <sort_order>10</sort_order>
280
+ <model>synergeticagency_gls/Glscashondelivery</model>
281
+ <title>GLS-Nachnahme</title>
282
+ <sort_order>10</sort_order>
283
+ <order_status>pending</order_status>
284
+ </glscashondelivery>
285
+ </payment>
286
+ </default>
287
+ </config>
app/code/community/SynergeticAgency/Gls/etc/system.xml ADDED
@@ -0,0 +1,700 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <gls translate="label" module="synergeticagency_gls">
5
+ <label>GLS</label>
6
+ <tab>sales</tab>
7
+ <sort_order>325</sort_order>
8
+ <frontend_type>text</frontend_type>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <note>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <label>GLS</label>
18
+ <frontend_type>text</frontend_type>
19
+ <frontend_model>synergeticagency_gls/adminhtml_system_config_note</frontend_model>
20
+ <support_url>https://gls-group.eu/DE/de/kontakt</support_url>
21
+ <agency_url>https://gls-group.eu/DE/de/home</agency_url>
22
+ <sort_order>0</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ </note>
27
+ <general translate="label comment" module="synergeticagency_gls">
28
+ <label>Basic configuration</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <expanded>1</expanded>
35
+ <fields>
36
+ <active translate="label comment" module="synergeticagency_gls">
37
+ <label>Enabled</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>100</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </active>
45
+ <!--
46
+ <sandbox translate="label comment">
47
+ <label>Sandbox-Mode</label>
48
+ <comment><![CDATA[In Sandbox-Mode, the so called TEST-flag will be sent to GLS. No Labels and all other processes have an productive effect. Use the test mode in your development- or test-systems.]]></comment>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>adminhtml/system_config_source_yesno</source_model>
51
+ <sort_order>110</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>0</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ </sandbox>
56
+ -->
57
+ <logging_enabled translate="label comment">
58
+ <label>Log requests and responses of the GLS API</label>
59
+ <comment><![CDATA[Please ensure that the Magento-Log is activated. It will be logged into Magento's system.log]]></comment>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>120</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>0</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </logging_enabled>
67
+ <debug_enabled translate="label comment">
68
+ <label>Debug mode</label>
69
+ <comment><![CDATA[In debug mode all relevant processes are logged. Attention, the log file can become very large in debug mode! It will be logged into SynergeticAgency_Gls.log and/or SynergeticAgency_GlsApi.log]]></comment>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_yesno</source_model>
72
+ <sort_order>130</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>0</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </debug_enabled>
77
+ <connector_log_enabled translate="label comment">
78
+ <label>Connector Logging</label>
79
+ <comment><![CDATA[When enabled, additional Connector debug information will be written into a Connector Logfile (SynergeticAgency_GlsApi.log). Attention, the log file can become very large!]]></comment>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>135</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>0</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </connector_log_enabled>
87
+ <api_url translate="label comment">
88
+ <label>GLS-API URL</label>
89
+ <frontend_type>text</frontend_type>
90
+ <comment><![CDATA[This URL should not be changed by default.]]></comment>
91
+ <validate>validate-url</validate>
92
+ <sort_order>140</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>0</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </api_url>
97
+ <json_url translate="label comment">
98
+ <label>GLS-JSON-Config URL</label>
99
+ <frontend_type>text</frontend_type>
100
+ <comment><![CDATA[This URL should not be changed by default.]]></comment>
101
+ <validate>validate-url</validate>
102
+ <sort_order>150</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>0</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ </json_url>
107
+ <tracking_url translate="label comment">
108
+ <label>GLS tracking URL</label>
109
+ <frontend_type>text</frontend_type>
110
+ <comment><![CDATA[This URL should not be changed by default.]]></comment>
111
+ <validate>validate-url</validate>
112
+ <sort_order>160</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>0</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </tracking_url>
117
+ <apiAuthUsername translate="label comment">
118
+ <label>GLS-API Username</label>
119
+ <frontend_type>text</frontend_type>
120
+ <comment><![CDATA[The GLS-API HTTP-Authentication-Username]]></comment>
121
+ <sort_order>170</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>0</show_in_website>
124
+ <show_in_store>0</show_in_store>
125
+ </apiAuthUsername>
126
+ <apiAuthPassword translate="label comment">
127
+ <label>GLS-API Password</label>
128
+ <frontend_type>obscure</frontend_type>
129
+ <comment><![CDATA[The GLS-API HTTP-Authentication-Password]]></comment>
130
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
131
+ <sort_order>180</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>0</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ </apiAuthPassword>
136
+ <customer_id translate="label comment">
137
+ <label>GLS customer ID</label>
138
+ <frontend_type>text</frontend_type>
139
+ <comment><![CDATA[GLS customer ID. For details see manual.]]></comment>
140
+ <sort_order>190</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>0</show_in_website>
143
+ <show_in_store>0</show_in_store>
144
+ </customer_id>
145
+ <contact_id translate="label comment">
146
+ <label>GLS contact ID</label>
147
+ <frontend_type>text</frontend_type>
148
+ <comment><![CDATA[GLS contact ID. For details see manual.]]></comment>
149
+ <sort_order>200</sort_order>
150
+ <show_in_default>1</show_in_default>
151
+ <show_in_website>0</show_in_website>
152
+ <show_in_store>0</show_in_store>
153
+ </contact_id>
154
+ </fields>
155
+ </general>
156
+ <shipment translate="label comment" module="synergeticagency_gls">
157
+ <label>Shipment options</label>
158
+ <frontend_type>text</frontend_type>
159
+ <sort_order>30</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>1</show_in_website>
162
+ <show_in_store>1</show_in_store>
163
+ <fields>
164
+ <weight translate="label comment">
165
+ <label>Default weight</label>
166
+ <frontend_type>text</frontend_type>
167
+ <validate>validate-number</validate>
168
+ <sort_order>100</sort_order>
169
+ <show_in_default>1</show_in_default>
170
+ <show_in_website>1</show_in_website>
171
+ <show_in_store>1</show_in_store>
172
+ <comment>kilogram (kg)</comment>
173
+ </weight>
174
+ <default_combination translate="label comment">
175
+ <label>Default GLS product</label>
176
+ <frontend_type>select</frontend_type>
177
+ <comment><![CDATA[For international shipment EuroBusinessParcel is chosen by default. Default product is only selected when the possibility is given.]]></comment>
178
+ <source_model>synergeticagency_gls/system_config_source_product</source_model>
179
+ <sort_order>110</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ </default_combination>
184
+ <default_services translate="label comment">
185
+ <label>Default GLS services</label>
186
+ <frontend_type>multiselect</frontend_type>
187
+ <comment><![CDATA[Service gets only selected when combination is available.]]></comment>
188
+ <source_model>synergeticagency_gls/system_config_source_service</source_model>
189
+ <sort_order>120</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>1</show_in_store>
193
+ <can_be_empty>1</can_be_empty>
194
+ </default_services>
195
+ <return_label_enabled translate="label comment">
196
+ <label>Create return label</label>
197
+ <frontend_type>select</frontend_type>
198
+ <comment><![CDATA[Service gets only selected when combination is available.]]></comment>
199
+ <source_model>adminhtml/system_config_source_yesno</source_model>
200
+ <sort_order>130</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>1</show_in_store>
204
+ </return_label_enabled>
205
+ <labelsize translate="label comment">
206
+ <label>Label Size</label>
207
+ <frontend_type>select</frontend_type>
208
+ <comment><![CDATA[Please note that not all label sizes are supported in some circumstances. Default is 'A6'. For details see manual.]]></comment>
209
+ <source_model>synergeticagency_gls/system_config_source_labelsize</source_model>
210
+ <sort_order>140</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>0</show_in_website>
213
+ <show_in_store>0</show_in_store>
214
+ </labelsize>
215
+ </fields>
216
+ </shipment>
217
+ <alternative_shipper translate="label comment" module="synergeticagency_gls">
218
+ <label>Alternative shipper data</label>
219
+ <frontend_type>text</frontend_type>
220
+ <sort_order>40</sort_order>
221
+ <show_in_default>1</show_in_default>
222
+ <show_in_website>1</show_in_website>
223
+ <show_in_store>1</show_in_store>
224
+ <fields>
225
+ <alternative_shipper_enabled translate="label comment">
226
+ <label>Alternative shipper enabled</label>
227
+ <frontend_type>select</frontend_type>
228
+ <source_model>adminhtml/system_config_source_yesno</source_model>
229
+ <sort_order>100</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>1</show_in_store>
233
+ </alternative_shipper_enabled>
234
+ <name1 translate="label comment">
235
+ <label>Name 1</label>
236
+ <frontend_type>text</frontend_type>
237
+ <validate>validate-length maximum-length-40</validate>
238
+ <sort_order>110</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>1</show_in_store>
242
+ </name1>
243
+ <name2 translate="label comment">
244
+ <label>Name 2</label>
245
+ <frontend_type>text</frontend_type>
246
+ <validate>validate-length maximum-length-40</validate>
247
+ <sort_order>120</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ </name2>
252
+ <name3 translate="label comment">
253
+ <label>Name 3</label>
254
+ <frontend_type>text</frontend_type>
255
+ <validate>validate-length maximum-length-40</validate>
256
+ <sort_order>130</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>1</show_in_store>
260
+ </name3>
261
+ <street1 translate="label comment">
262
+ <label>Street</label>
263
+ <frontend_type>text</frontend_type>
264
+ <validate>validate-length maximum-length-40</validate>
265
+ <sort_order>140</sort_order>
266
+ <show_in_default>1</show_in_default>
267
+ <show_in_website>1</show_in_website>
268
+ <show_in_store>1</show_in_store>
269
+ </street1>
270
+ <country translate="label comment">
271
+ <label>Country</label>
272
+ <frontend_type>select</frontend_type>
273
+ <source_model>synergeticagency_gls/system_config_source_country</source_model>
274
+ <sort_order>150</sort_order>
275
+ <show_in_default>1</show_in_default>
276
+ <show_in_website>1</show_in_website>
277
+ <show_in_store>1</show_in_store>
278
+ </country>
279
+ <zip_code translate="label comment">
280
+ <label>ZIP code</label>
281
+ <frontend_type>text</frontend_type>
282
+ <validate>validate-length maximum-length-10</validate>
283
+ <sort_order>160</sort_order>
284
+ <show_in_default>1</show_in_default>
285
+ <show_in_website>1</show_in_website>
286
+ <show_in_store>1</show_in_store>
287
+ </zip_code>
288
+ <city translate="label comment">
289
+ <label>City</label>
290
+ <frontend_type>text</frontend_type>
291
+ <validate>validate-length maximum-length-40</validate>
292
+ <sort_order>170</sort_order>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ </city>
297
+ </fields>
298
+ </alternative_shipper>
299
+ <return_address translate="label comment" module="synergeticagency_gls">
300
+ <label>Return address data</label>
301
+ <frontend_type>text</frontend_type>
302
+ <sort_order>40</sort_order>
303
+ <show_in_default>1</show_in_default>
304
+ <show_in_website>1</show_in_website>
305
+ <show_in_store>1</show_in_store>
306
+ <comment>This address is mandatory for return labels</comment>
307
+ <fields>
308
+ <name1 translate="label comment">
309
+ <label>Name 1</label>
310
+ <frontend_type>text</frontend_type>
311
+ <validate>validate-length maximum-length-40</validate>
312
+ <sort_order>110</sort_order>
313
+ <show_in_default>1</show_in_default>
314
+ <show_in_website>1</show_in_website>
315
+ <show_in_store>1</show_in_store>
316
+ </name1>
317
+ <name2 translate="label comment">
318
+ <label>Name 2</label>
319
+ <frontend_type>text</frontend_type>
320
+ <validate>validate-length maximum-length-40</validate>
321
+ <sort_order>120</sort_order>
322
+ <show_in_default>1</show_in_default>
323
+ <show_in_website>1</show_in_website>
324
+ <show_in_store>1</show_in_store>
325
+ </name2>
326
+ <name3 translate="label comment">
327
+ <label>Name 3</label>
328
+ <frontend_type>text</frontend_type>
329
+ <validate>validate-length maximum-length-40</validate>
330
+ <sort_order>130</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <show_in_store>1</show_in_store>
334
+ </name3>
335
+ <street1 translate="label comment">
336
+ <label>Street</label>
337
+ <frontend_type>text</frontend_type>
338
+ <validate>validate-length maximum-length-40</validate>
339
+ <sort_order>140</sort_order>
340
+ <show_in_default>1</show_in_default>
341
+ <show_in_website>1</show_in_website>
342
+ <show_in_store>1</show_in_store>
343
+ </street1>
344
+ <country translate="label comment">
345
+ <label>Country</label>
346
+ <frontend_type>select</frontend_type>
347
+ <source_model>synergeticagency_gls/system_config_source_country</source_model>
348
+ <sort_order>150</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_website>1</show_in_website>
351
+ <show_in_store>1</show_in_store>
352
+ </country>
353
+ <zip_code translate="label comment">
354
+ <label>ZIP code</label>
355
+ <frontend_type>text</frontend_type>
356
+ <validate>validate-length maximum-length-10</validate>
357
+ <sort_order>160</sort_order>
358
+ <show_in_default>1</show_in_default>
359
+ <show_in_website>1</show_in_website>
360
+ <show_in_store>1</show_in_store>
361
+ </zip_code>
362
+ <city translate="label comment">
363
+ <label>City</label>
364
+ <frontend_type>text</frontend_type>
365
+ <validate>validate-length maximum-length-40</validate>
366
+ <sort_order>170</sort_order>
367
+ <show_in_default>1</show_in_default>
368
+ <show_in_website>1</show_in_website>
369
+ <show_in_store>1</show_in_store>
370
+ </city>
371
+ </fields>
372
+ </return_address>
373
+ <parcel_shop translate="label comment" module="synergeticagency_gls">
374
+ <label>GLS ParcelShop</label>
375
+ <frontend_type>text</frontend_type>
376
+ <sort_order>50</sort_order>
377
+ <show_in_default>1</show_in_default>
378
+ <show_in_website>1</show_in_website>
379
+ <show_in_store>1</show_in_store>
380
+ <fields>
381
+ <parcel_shop_enabled translate="label comment">
382
+ <label>GLS ParcelShop enabled</label>
383
+ <frontend_type>select</frontend_type>
384
+ <source_model>adminhtml/system_config_source_yesno</source_model>
385
+ <sort_order>100</sort_order>
386
+ <show_in_default>1</show_in_default>
387
+ <show_in_website>1</show_in_website>
388
+ <show_in_store>1</show_in_store>
389
+ </parcel_shop_enabled>
390
+ <parcel_shop_url translate="label comment">
391
+ <label>URL for GLS ParcelShop Service</label>
392
+ <frontend_type>text</frontend_type>
393
+ <comment><![CDATA[This URL should not be changed by default.]]></comment>
394
+ <validate>validate-url</validate>
395
+ <sort_order>150</sort_order>
396
+ <show_in_default>1</show_in_default>
397
+ <show_in_website>0</show_in_website>
398
+ <show_in_store>0</show_in_store>
399
+ </parcel_shop_url>
400
+ </fields>
401
+ </parcel_shop>
402
+ </groups>
403
+ </gls>
404
+ <carriers>
405
+ <groups>
406
+ <synergeticagency_gls translate="label">
407
+ <label>GLS</label>
408
+ <sort_order>4</sort_order>
409
+ <show_in_default>1</show_in_default>
410
+ <show_in_website>1</show_in_website>
411
+ <show_in_store>1</show_in_store>
412
+ <fields>
413
+ <gls_general_label translate="label" module="synergeticagency_gls">
414
+ <label>General</label>
415
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
416
+ <sort_order>2</sort_order>
417
+ <show_in_default>1</show_in_default>
418
+ <show_in_website>1</show_in_website>
419
+ </gls_general_label>
420
+ <active translate="label">
421
+ <label>Enabled</label>
422
+ <frontend_type>select</frontend_type>
423
+ <source_model>adminhtml/system_config_source_yesno</source_model>
424
+ <sort_order>4</sort_order>
425
+ <show_in_default>1</show_in_default>
426
+ <show_in_website>1</show_in_website>
427
+ <show_in_store>0</show_in_store>
428
+ </active>
429
+ <title translate="label" module="synergeticagency_gls">
430
+ <label>Carrier title</label>
431
+ <frontend_type>text</frontend_type>
432
+ <validate>required-entry</validate>
433
+ <sort_order>6</sort_order>
434
+ <show_in_default>1</show_in_default>
435
+ <show_in_website>1</show_in_website>
436
+ <show_in_store>1</show_in_store>
437
+ </title>
438
+ <showmethod translate="label">
439
+ <label>Show Method if Not Applicable</label>
440
+ <frontend_type>select</frontend_type>
441
+ <sort_order>8</sort_order>
442
+ <source_model>adminhtml/system_config_source_yesno</source_model>
443
+ <show_in_default>1</show_in_default>
444
+ <show_in_website>1</show_in_website>
445
+ <show_in_store>0</show_in_store>
446
+ </showmethod>
447
+ <specificerrmsg translate="label">
448
+ <label>Displayed Error Message</label>
449
+ <frontend_type>textarea</frontend_type>
450
+ <sort_order>9</sort_order>
451
+ <show_in_default>1</show_in_default>
452
+ <show_in_website>1</show_in_website>
453
+ <show_in_store>1</show_in_store>
454
+ </specificerrmsg>
455
+ <sallowspecific translate="label">
456
+ <label>Available for specific countries only</label>
457
+ <frontend_type>select</frontend_type>
458
+ <frontend_class>shipping-applicable-country</frontend_class>
459
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
460
+ <sort_order>10</sort_order>
461
+ <show_in_default>1</show_in_default>
462
+ <show_in_website>1</show_in_website>
463
+ <show_in_store>0</show_in_store>
464
+ </sallowspecific>
465
+ <specificcountry translate="label">
466
+ <label>Ship to Specific Countries</label>
467
+ <frontend_type>multiselect</frontend_type>
468
+ <sort_order>12</sort_order>
469
+ <source_model>adminhtml/system_config_source_country</source_model>
470
+ <show_in_default>1</show_in_default>
471
+ <show_in_website>1</show_in_website>
472
+ <show_in_store>0</show_in_store>
473
+ <can_be_empty>1</can_be_empty>
474
+ </specificcountry>
475
+ <label_standard translate="label" module="synergeticagency_gls">
476
+ <label>gls_standard_delivery</label>
477
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
478
+ <sort_order>25</sort_order>
479
+ <show_in_default>1</show_in_default>
480
+ <show_in_website>1</show_in_website>
481
+ </label_standard>
482
+ <active_standard translate="label" module="synergeticagency_gls">
483
+ <label>Active</label>
484
+ <frontend_type>select</frontend_type>
485
+ <source_model>adminhtml/system_config_source_yesno</source_model>
486
+ <sort_order>30</sort_order>
487
+ <show_in_default>1</show_in_default>
488
+ <show_in_website>1</show_in_website>
489
+ <show_in_store>0</show_in_store>
490
+ </active_standard>
491
+ <name_standard translate="label" module="synergeticagency_gls">
492
+ <label>Name</label>
493
+ <frontend_type>text</frontend_type>
494
+ <validate>required-entry</validate>
495
+ <sort_order>40</sort_order>
496
+ <show_in_default>1</show_in_default>
497
+ <show_in_website>1</show_in_website>
498
+ <show_in_store>1</show_in_store>
499
+ </name_standard>
500
+ <show_logo_standard translate="label" module="synergeticagency_gls">
501
+ <label>Show gls_logo</label>
502
+ <frontend_type>select</frontend_type>
503
+ <source_model>adminhtml/system_config_source_yesno</source_model>
504
+ <sort_order>50</sort_order>
505
+ <show_in_default>1</show_in_default>
506
+ <show_in_website>1</show_in_website>
507
+ <show_in_store>0</show_in_store>
508
+ </show_logo_standard>
509
+ <price_per_order_standard translate="label" module="synergeticagency_gls">
510
+ <label>Price per order</label>
511
+ <frontend_type>text</frontend_type>
512
+ <validate>validate-number validate-zero-or-greater</validate>
513
+ <sort_order>60</sort_order>
514
+ <show_in_default>1</show_in_default>
515
+ <show_in_website>1</show_in_website>
516
+ <show_in_store>0</show_in_store>
517
+ </price_per_order_standard>
518
+ <label_express translate="label" module="synergeticagency_gls">
519
+ <label>gls_express_delivery</label>
520
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
521
+ <sort_order>65</sort_order>
522
+ <show_in_default>1</show_in_default>
523
+ <show_in_website>1</show_in_website>
524
+ </label_express>
525
+ <active_express translate="label" module="synergeticagency_gls">
526
+ <label>Active</label>
527
+ <frontend_type>select</frontend_type>
528
+ <source_model>adminhtml/system_config_source_yesno</source_model>
529
+ <sort_order>70</sort_order>
530
+ <show_in_default>1</show_in_default>
531
+ <show_in_website>1</show_in_website>
532
+ <show_in_store>0</show_in_store>
533
+ </active_express>
534
+ <name_express translate="label" module="synergeticagency_gls">
535
+ <label>Name</label>
536
+ <frontend_type>text</frontend_type>
537
+ <validate>required-entry</validate>
538
+ <sort_order>80</sort_order>
539
+ <show_in_default>1</show_in_default>
540
+ <show_in_website>1</show_in_website>
541
+ <show_in_store>1</show_in_store>
542
+ </name_express>
543
+ <show_logo_express translate="label" module="synergeticagency_gls">
544
+ <label>Show gls_logo</label>
545
+ <frontend_type>select</frontend_type>
546
+ <source_model>adminhtml/system_config_source_yesno</source_model>
547
+ <sort_order>90</sort_order>
548
+ <show_in_default>1</show_in_default>
549
+ <show_in_website>1</show_in_website>
550
+ <show_in_store>0</show_in_store>
551
+ </show_logo_express>
552
+ <price_per_order_express translate="label" module="synergeticagency_gls">
553
+ <label>Price per order</label>
554
+ <frontend_type>text</frontend_type>
555
+ <validate>validate-number validate-zero-or-greater</validate>
556
+ <sort_order>100</sort_order>
557
+ <show_in_default>1</show_in_default>
558
+ <show_in_website>1</show_in_website>
559
+ <show_in_store>0</show_in_store>
560
+ </price_per_order_express>
561
+ <label_foreigncountries translate="label" module="synergeticagency_gls">
562
+ <label>gls_foreign_countries_delivery</label>
563
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
564
+ <sort_order>145</sort_order>
565
+ <show_in_default>1</show_in_default>
566
+ <show_in_website>1</show_in_website>
567
+ </label_foreigncountries>
568
+ <active_foreigncountries translate="label" module="synergeticagency_gls">
569
+ <label>Active</label>
570
+ <frontend_type>select</frontend_type>
571
+ <source_model>adminhtml/system_config_source_yesno</source_model>
572
+ <sort_order>150</sort_order>
573
+ <show_in_default>1</show_in_default>
574
+ <show_in_website>1</show_in_website>
575
+ <show_in_store>0</show_in_store>
576
+ </active_foreigncountries>
577
+ <name_foreigncountries translate="label" module="synergeticagency_gls">
578
+ <label>Name</label>
579
+ <frontend_type>text</frontend_type>
580
+ <validate>required-entry</validate>
581
+ <sort_order>160</sort_order>
582
+ <show_in_default>1</show_in_default>
583
+ <show_in_website>1</show_in_website>
584
+ <show_in_store>1</show_in_store>
585
+ </name_foreigncountries>
586
+ <show_logo_foreigncountries translate="label" module="synergeticagency_gls">
587
+ <label>Show gls_logo</label>
588
+ <frontend_type>select</frontend_type>
589
+ <source_model>adminhtml/system_config_source_yesno</source_model>
590
+ <sort_order>170</sort_order>
591
+ <show_in_default>1</show_in_default>
592
+ <show_in_website>1</show_in_website>
593
+ <show_in_store>0</show_in_store>
594
+ </show_logo_foreigncountries>
595
+ <price_per_order_foreigncountries translate="label" module="synergeticagency_gls">
596
+ <label>Price per order</label>
597
+ <frontend_type>text</frontend_type>
598
+ <validate>validate-number validate-zero-or-greater</validate>
599
+ <sort_order>180</sort_order>
600
+ <show_in_default>1</show_in_default>
601
+ <show_in_website>1</show_in_website>
602
+ <show_in_store>0</show_in_store>
603
+ </price_per_order_foreigncountries>
604
+ </fields>
605
+ </synergeticagency_gls>
606
+ </groups>
607
+ </carriers>
608
+ <payment>
609
+ <groups>
610
+ <glscashondelivery translate="label" module="synergeticagency_gls">
611
+ <label>GLS - Cash on delivery</label>
612
+ <sort_order>1000</sort_order>
613
+ <show_in_default>1</show_in_default>
614
+ <show_in_website>1</show_in_website>
615
+ <show_in_store>0</show_in_store>
616
+ <fields>
617
+ <active translate="label">
618
+ <label>Enabled</label>
619
+ <frontend_type>select</frontend_type>
620
+ <source_model>adminhtml/system_config_source_yesno</source_model>
621
+ <show_in_default>1</show_in_default>
622
+ <show_in_website>1</show_in_website>
623
+ <show_in_store>0</show_in_store>
624
+ <sort_order>1</sort_order>
625
+ </active>
626
+ <title translate="label">
627
+ <label>Title</label>
628
+ <frontend_type>text</frontend_type>
629
+ <show_in_default>1</show_in_default>
630
+ <show_in_website>1</show_in_website>
631
+ <show_in_store>0</show_in_store>
632
+ <sort_order>2</sort_order>
633
+ </title>
634
+ <order_status translate="label">
635
+ <label>New Order Status</label>
636
+ <frontend_type>select</frontend_type>
637
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
638
+ <sort_order>20</sort_order>
639
+ <show_in_default>1</show_in_default>
640
+ <show_in_website>1</show_in_website>
641
+ <show_in_store>0</show_in_store>
642
+ </order_status>
643
+ <instructions translate="label">
644
+ <label>Instructions</label>
645
+ <frontend_type>textarea</frontend_type>
646
+ <sort_order>62</sort_order>
647
+ <show_in_default>1</show_in_default>
648
+ <show_in_website>1</show_in_website>
649
+ <show_in_store>1</show_in_store>
650
+ </instructions>
651
+ <min_order_total translate="label">
652
+ <label>Minimum Order Total</label>
653
+ <frontend_type>text</frontend_type>
654
+ <sort_order>98</sort_order>
655
+ <show_in_default>1</show_in_default>
656
+ <show_in_website>1</show_in_website>
657
+ <show_in_store>0</show_in_store>
658
+ </min_order_total>
659
+ <max_order_total translate="label">
660
+ <label>Maximum Order Total</label>
661
+ <frontend_type>text</frontend_type>
662
+ <sort_order>99</sort_order>
663
+ <show_in_default>1</show_in_default>
664
+ <show_in_website>1</show_in_website>
665
+ <show_in_store>0</show_in_store>
666
+ </max_order_total>
667
+ <sort_order translate="label">
668
+ <label>Sort Order</label>
669
+ <frontend_type>text</frontend_type>
670
+ <sort_order>100</sort_order>
671
+ <show_in_default>1</show_in_default>
672
+ <show_in_website>1</show_in_website>
673
+ <show_in_store>0</show_in_store>
674
+ </sort_order>
675
+ <disallow_delivery_services translate="label" module="synergeticagency_gls">
676
+ <label>Disallow certain delivery services</label>
677
+ <frontend_type>select</frontend_type>
678
+ <source_model>adminhtml/system_config_source_yesno</source_model>
679
+ <sort_order>150</sort_order>
680
+ <show_in_default>1</show_in_default>
681
+ <show_in_website>1</show_in_website>
682
+ <show_in_store>0</show_in_store>
683
+ </disallow_delivery_services>
684
+ <disallowed_delivery_services translate="label">
685
+ <label>Disallowed delivery services</label>
686
+ <frontend_type>multiselect</frontend_type>
687
+ <sort_order>151</sort_order>
688
+ <source_model>synergeticagency_gls/system_config_source_payment_shippingmethods</source_model>
689
+ <show_in_default>1</show_in_default>
690
+ <show_in_website>1</show_in_website>
691
+ <show_in_store>0</show_in_store>
692
+ <can_be_empty>1</can_be_empty>
693
+ <depends><disallow_delivery_services>1</disallow_delivery_services></depends>
694
+ </disallowed_delivery_services>
695
+ </fields>
696
+ </glscashondelivery>
697
+ </groups>
698
+ </payment>
699
+ </sections>
700
+ </config>
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/install-0.1.0.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /* @var $installer Mage_Core_Model_Resource_Setup */
29
+ $installer = $this;
30
+
31
+ $installer->startSetup();
32
+
33
+
34
+
35
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /* @var $installer Mage_Core_Model_Resource_Setup */
29
+ $installer = $this;
30
+
31
+ $installer->startSetup();
32
+
33
+
34
+ /**
35
+ * Create table 'synergeticagency_gls/shipment'
36
+ */
37
+ $table = $installer->getConnection()
38
+ ->newTable($installer->getTable('synergeticagency_gls/shipment'))
39
+ ->addColumn('gls_shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
40
+ 'identity' => true,
41
+ 'unsigned' => true,
42
+ 'nullable' => false,
43
+ 'primary' => true,
44
+ ), 'GLS Shipment ID')
45
+ ->addColumn('shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
46
+ 'unsigned' => true,
47
+ 'nullable' => true,
48
+ 'default' => null,
49
+ ), 'Shipment ID')
50
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
51
+ 'unsigned' => true,
52
+ 'nullable' => true,
53
+ 'default' => null,
54
+ ), 'Order ID')
55
+ ->addColumn('gls_product', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
56
+ 'nullable' => true,
57
+ 'default' => null,
58
+ ), 'GLS Product')
59
+ ->addColumn('gls_services', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
60
+ 'nullable' => true,
61
+ 'default' => null,
62
+ ), 'GLS Services')
63
+ ->addColumn('consignment_id', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
64
+ 'nullable' => true,
65
+ 'default' => null,
66
+ ), 'GLS Consignement ID')
67
+ ->addColumn('sandbox', Varien_Db_Ddl_Table::TYPE_TINYINT, 1, array(
68
+ 'unsigned' => true,
69
+ 'nullable' => false,
70
+ 'default' => '0',
71
+ ), 'Sandbox')
72
+ ->addColumn('printed', Varien_Db_Ddl_Table::TYPE_TINYINT, 1, array(
73
+ 'unsigned' => true,
74
+ 'nullable' => false,
75
+ 'default' => '0',
76
+ ), 'Shipment Printed')
77
+ ->addForeignKey($installer->getFkName('synergeticagency_gls/shipment', 'shipment_id', 'sales/shipment', 'entity_id'),
78
+ 'shipment_id', $installer->getTable('sales/shipment'), 'entity_id',
79
+ Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_SET_NULL)
80
+ ->addForeignKey($installer->getFkName('synergeticagency_gls/shipment', 'order_id', 'sales/order', 'entity_id'),
81
+ 'order_id', $installer->getTable('sales/order'), 'entity_id',
82
+ Varien_Db_Ddl_Table::ACTION_SET_NULL, Varien_Db_Ddl_Table::ACTION_SET_NULL)
83
+ ->setComment('GLS Shipment Table');
84
+ $installer->getConnection()->createTable($table);
85
+
86
+
87
+ /**
88
+ * Create table 'synergeticagency_gls/shipment_parcel'
89
+ */
90
+ $table = $installer->getConnection()
91
+ ->newTable($installer->getTable('synergeticagency_gls/shipment_parcel'))
92
+ ->addColumn('gls_shipment_parcel_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
93
+ 'identity' => true,
94
+ 'unsigned' => true,
95
+ 'nullable' => false,
96
+ 'primary' => true,
97
+ ), 'GLS Shipment Parcel ID')
98
+ ->addColumn('gls_shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
99
+ 'unsigned' => true,
100
+ 'nullable' => false,
101
+ ), 'GLS Shipment ID')
102
+ ->addColumn('weight', Varien_Db_Ddl_Table::TYPE_DECIMAL, '6,2', array(
103
+ 'nullable' => false,
104
+ 'default' => '0.00',
105
+ ), 'Parcel Weight')
106
+ ->addColumn('cashservice', Varien_Db_Ddl_Table::TYPE_DECIMAL, '12,4', array(
107
+ 'nullable' => false,
108
+ 'default' => '0.00',
109
+ ), 'Parcel Cashservice Amount')
110
+ ->addColumn('unique_number', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
111
+ 'nullable' => true,
112
+ 'default' => null,
113
+ ), 'GLS Tracking Number')
114
+ ->addColumn('parcel_number', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
115
+ 'nullable' => true,
116
+ 'default' => null,
117
+ ), 'GLS Parcel Number')
118
+ ->addColumn('ndi_number', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
119
+ 'nullable' => true,
120
+ 'default' => null,
121
+ ), 'GLS Ndi Number')
122
+ ->addColumn('primary2d', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
123
+ 'nullable' => true,
124
+ 'default' => null,
125
+ ), 'GLS Primary 2d Barcode')
126
+ ->addColumn('secondary2d', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
127
+ 'nullable' => true,
128
+ 'default' => null,
129
+ ), 'GLS Secondary 2d Barcode')
130
+ ->addColumn('national_ref', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
131
+ 'nullable' => true,
132
+ 'default' => null,
133
+ ), 'GLS National Reference Number')
134
+ ->addForeignKey($installer->getFkName('synergeticagency_gls/shipment_parcel', 'gls_shipment_id', 'synergeticagency_gls/shipment', 'gls_shipment_id'),
135
+ 'gls_shipment_id', $installer->getTable('synergeticagency_gls/shipment'), 'gls_shipment_id',
136
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
137
+ ->setComment('GLS Shipment Parcel Table');
138
+ $installer->getConnection()->createTable($table);
139
+
140
+
141
+ /**
142
+ * Create table 'synergeticagency_gls/shipment_address'
143
+ */
144
+ $table = $installer->getConnection()
145
+ ->newTable($installer->getTable('synergeticagency_gls/shipment_address'))
146
+ ->addColumn('gls_shipment_address_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
147
+ 'identity' => true,
148
+ 'unsigned' => true,
149
+ 'nullable' => false,
150
+ 'primary' => true,
151
+ ), 'GLS Shipment Address ID')
152
+ ->addColumn('gls_shipment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
153
+ 'unsigned' => true,
154
+ 'nullable' => false,
155
+ ), 'GLS Shipment ID')
156
+ ->addColumn('name1', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
157
+ 'nullable' => true,
158
+ 'default' => null,
159
+ ), 'Name 1')
160
+ ->addColumn('name2', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
161
+ 'nullable' => true,
162
+ 'default' => null,
163
+ ), 'Name 2')
164
+ ->addColumn('name3', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
165
+ 'nullable' => true,
166
+ 'default' => null,
167
+ ), 'Name 3')
168
+ ->addColumn('street1', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
169
+ 'nullable' => true,
170
+ 'default' => null,
171
+ ), 'Street 1')
172
+ ->addColumn('country_num', Varien_Db_Ddl_Table::TYPE_TEXT, 3, array(
173
+ 'nullable' => true,
174
+ 'default' => null,
175
+ ), 'Country ISO 3166-1 numeric')
176
+ ->addColumn('zip_code', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
177
+ 'nullable' => true,
178
+ 'default' => null,
179
+ ), 'ZIP Code')
180
+ ->addColumn('city', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
181
+ 'nullable' => true,
182
+ 'default' => null,
183
+ ), 'City')
184
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
185
+ 'nullable' => true,
186
+ 'default' => null,
187
+ ), 'E-Mail')
188
+ ->addColumn('phone', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
189
+ 'nullable' => true,
190
+ 'default' => null,
191
+ ), 'Phone Number')
192
+ ->addForeignKey($installer->getFkName('synergeticagency_gls/shipment_address', 'gls_shipment_id', 'synergeticagency_gls/shipment', 'gls_shipment_id'),
193
+ 'gls_shipment_id', $installer->getTable('synergeticagency_gls/shipment'), 'gls_shipment_id',
194
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
195
+ ->setComment('GLS Shipment Address Table');
196
+ $installer->getConnection()->createTable($table);
197
+
198
+ /*
199
+ * Add ISO 3166-1 N3 column to directory_country table
200
+ */
201
+ $installer->getConnection()->addColumn($installer->getTable('directory/country'), 'iso_n3_code', array(
202
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
203
+ 'length' => 3,
204
+ 'nullable' => true,
205
+ 'default' => null,
206
+ 'comment' => 'ISO 3166-1 N3'
207
+ ));
208
+
209
+
210
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ $installer = new Mage_Customer_Model_Entity_Setup('core_setup');
29
+ $installer->startSetup();
30
+
31
+ /**
32
+ * add attribute parcelshop_name to customer_address
33
+ */
34
+ $installer->addAttribute('customer_address', 'parcelshop_name', array(
35
+ 'type' => 'varchar',
36
+ 'input' => 'text',
37
+ 'label' => 'GLS Parcelshop Name',
38
+ 'global' => 1,
39
+ 'visible' => 1,
40
+ 'required' => 0,
41
+ 'user_defined' => 1,
42
+ 'visible_on_front' => 1
43
+ ));
44
+
45
+ /**
46
+ * add attribute parcelshop_id to customer_address
47
+ */
48
+ $installer->addAttribute('customer_address', 'parcelshop_id', array(
49
+ 'type' => 'varchar',
50
+ 'input' => 'text',
51
+ 'label' => 'GLS Parcelshop ID',
52
+ 'global' => 1,
53
+ 'visible' => 1,
54
+ 'required' => 0,
55
+ 'user_defined' => 1,
56
+ 'visible_on_front' => 1
57
+ ));
58
+
59
+ /**
60
+ * add attribute parcelshop_name to required forms
61
+ */
62
+ Mage::getSingleton('eav/config')
63
+ ->getAttribute('customer_address', 'parcelshop_name')
64
+ ->setData('used_in_forms', array('customer_address_edit','adminhtml_customer_address','customer_register_address'))
65
+ ->save();
66
+
67
+ /**
68
+ * add attribute parcelshop_id to required forms
69
+ */
70
+ Mage::getSingleton('eav/config')
71
+ ->getAttribute('customer_address', 'parcelshop_id')
72
+ ->setData('used_in_forms', array('customer_address_edit','adminhtml_customer_address','customer_register_address'))
73
+ ->save();
74
+
75
+ // todo remove later just for fixing
76
+ $installer->getConnection()->dropColumn($installer->getTable('sales/quote_address'), 'parcelshop_id');
77
+ $installer->getConnection()->dropColumn($installer->getTable('sales/order_address'), 'parcelshop_id');
78
+ $installer->getConnection()->dropColumn($installer->getTable('sales/quote_address'), 'parcelshop_name');
79
+ $installer->getConnection()->dropColumn($installer->getTable('sales/order_address'), 'parcelshop_name');
80
+ $installer->getConnection()->dropColumn($installer->getTable('sales/quote_address'), 'to_parcelshop');
81
+ $installer->getConnection()->dropColumn($installer->getTable('sales/order_address'), 'to_parcelshop');
82
+
83
+
84
+ /**
85
+ * add attribute parcelshop_id to quote_address table
86
+ */
87
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_address'), 'parcelshop_id', array(
88
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
89
+ 'length' => 255,
90
+ 'nullable' => true,
91
+ 'default' => null,
92
+ 'comment' => 'GLS Parcelshop id'
93
+ ));
94
+
95
+ /**
96
+ * add attribute parcelshop_name to quote_address table
97
+ */
98
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_address'), 'parcelshop_name', array(
99
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
100
+ 'length' => 255,
101
+ 'nullable' => true,
102
+ 'default' => null,
103
+ 'comment' => 'GLS Parcelshop name'
104
+ ));
105
+
106
+ /**
107
+ * add attribute parcelshop_id to order_address table
108
+ */
109
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_address'), 'parcelshop_id', array(
110
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
111
+ 'length' => 255,
112
+ 'nullable' => true,
113
+ 'default' => null,
114
+ 'comment' => 'GLS Parcelshop id'
115
+ ));
116
+
117
+ /**
118
+ * add attribute parcelshop_name to order_address table
119
+ */
120
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_address'), 'parcelshop_name', array(
121
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
122
+ 'length' => 255,
123
+ 'nullable' => true,
124
+ 'default' => null,
125
+ 'comment' => 'GLS Parcelshop name'
126
+ ));
127
+
128
+
129
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'return_label',array(
32
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
33
+ 'length' => 1,
34
+ 'unsigned' => true,
35
+ 'nullable' => false,
36
+ 'default' => '0',
37
+ 'comment' => 'Return Label Enabled'
38
+ ));
39
+
40
+ $installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'shipping_date',array(
41
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
42
+ 'length' => 255,
43
+ 'nullable' => true,
44
+ 'default' => null,
45
+ 'comment' => 'Shipment Date'
46
+ ));
47
+
48
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'combination_id',array(
32
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
33
+ 'length' => 8,
34
+ 'unsigned' => true,
35
+ 'nullable' => true,
36
+ 'comment' => 'GLS Combination ID'
37
+ ));
38
+
39
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.4-0.1.5.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment'),'parcelshop_id',array(
32
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
33
+ 'length' => 255,
34
+ 'nullable' => true,
35
+ 'comment' => 'GLS Parcelshop ID'
36
+ ));
37
+
38
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.5-0.1.6.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->changeColumn($installer->getTable('synergeticagency_gls/shipment_address'),'country_num','country',array(
32
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
33
+ 'length' => '2',
34
+ 'comment' => 'Country ISO 3166-1-alpha-2'
35
+ ));
36
+
37
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.1.6-0.1.7.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment_parcel'),'trackId',array(
32
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
33
+ 'length' => 10,
34
+ 'nullable' => true,
35
+ 'comment' => 'GLS Track id'
36
+ ));
37
+
38
+ $installer->getConnection()->addColumn($installer->getTable('synergeticagency_gls/shipment_parcel'),'location',array(
39
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
40
+ 'length' => 255,
41
+ 'nullable' => true,
42
+ 'comment' => 'GLS Track location'
43
+ ));
44
+
45
+ $installer->getConnection()->dropColumn($installer->getTable('synergeticagency_gls/shipment_parcel'),'ndi_number');
46
+ $installer->getConnection()->dropColumn($installer->getTable('synergeticagency_gls/shipment_parcel'),'primary2d');
47
+ $installer->getConnection()->dropColumn($installer->getTable('synergeticagency_gls/shipment_parcel'),'secondary2d');
48
+ $installer->getConnection()->dropColumn($installer->getTable('synergeticagency_gls/shipment_parcel'),'national_ref');
49
+
50
+
51
+ $installer->endSetup();
app/code/community/SynergeticAgency/Gls/sql/synergeticagency_gls_setup/upgrade-0.2.0-0.2.1.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SynergeticAgency_Gls
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency\Gls\sql\synergeticagency_gls_setup
23
+ * @copyright Copyright (c) 2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /* @var $installer Mage_Core_Model_Resource_Setup */
28
+ $installer = $this;
29
+ $installer->startSetup();
30
+
31
+ $installer->getConnection()->changeColumn($installer->getTable('synergeticagency_gls/shipment'),'shipping_date','shipping_date',array(
32
+ 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME,
33
+ 'comment' => 'Shipment Date'
34
+ ));
35
+
36
+ $installer->endSetup();
app/design/adminhtml/base/default/layout/synergeticagency/gls.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_sales_order_shipment_new>
4
+ <reference name="head">
5
+ <action method="addCss"><name>gls.css</name></action>
6
+ <action method="addJs"><script>gls/admin.js</script></action>
7
+ </reference>
8
+ </adminhtml_sales_order_shipment_new>
9
+ <adminhtml_gls_shipment_edit>
10
+ <reference name="head">
11
+ <action method="addCss"><name>gls.css</name></action>
12
+ <action method="addJs"><script>gls/admin.js</script></action>
13
+ </reference>
14
+ <reference name="content">
15
+ <block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit" name="gls_shipment_edit">
16
+ <block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit_form" name="gls_shipment_edit_form">
17
+ <block type="synergeticagency_gls/adminhtml_sales_gls_shipment_edit_form_packages" name="packages" />
18
+ </block>
19
+ </block>
20
+ </reference>
21
+ </adminhtml_gls_shipment_edit>
22
+ </layout>
app/design/adminhtml/base/default/template/gls/sales/order/address/form/attr/parcelshopid.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <tr>
2
+ <td class="label"><label for="<?php echo $this->getElement()->getHtmlId()?>"><?php echo $this->getElement()->getLabel()?></label></td>
3
+ <td class="value">
4
+ <input id="<?php echo $this->getElement()->getHtmlId()?>" name="<?php echo $this->getElement()->getHtmlId()?>" value="<?php echo $this->getElement()->getValue()?>" class=" input-text" type="text">
5
+ &nbsp;<a href="https://gls-group.eu/DE/de/depot-paketshop-suche" target="_blank">https://gls-group.eu/DE/de/depot-paketshop-suche</a>
6
+ </td>
7
+ </tr>
app/design/adminhtml/base/default/template/gls/sales/order/shipment/create/gls.phtml ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style type="text/css">
2
+ .gls-selector.fifty {
3
+ float:left;
4
+ width:32%;
5
+ display:block;
6
+ box-sizing: border-box;
7
+ margin-right:1%;
8
+ }
9
+
10
+ .gls-selector.fifty.last {
11
+ width:33%;
12
+ margin-right:0;
13
+ }
14
+ .gls-selector legend {
15
+ display:block;
16
+ width: 100%;
17
+ height: 20px;
18
+ line-height: 20px;
19
+ visibility: visible;
20
+ }
21
+
22
+ </style>
23
+
24
+ <div id="gls-form" class="field-row grid">
25
+ <?php
26
+ if ($this->isCountryAvailable()) {
27
+ ?>
28
+ <h3><?php echo $this->__('GLS shipping')?></h3>
29
+ <fieldset class="gls-selector fifty first">
30
+ <legend><?php echo $this->__('Ship with Gls?')?></legend>
31
+ <input type="radio" name="ship_with_gls" id="ship_with_gls_yes" value="1" checked="checked" />
32
+ <label for="ship_with_gls_yes"><?php echo $this->__('Yes')?></label>
33
+ <br />
34
+ <input type="radio" name="ship_with_gls" id="ship_with_gls_no" value="0" />
35
+ <label for="ship_with_gls_no"><?php echo $this->__('No')?></label>
36
+ </fieldset>
37
+ <fieldset class="gls-selector gls-top-control fifty">
38
+ <?php $returnLabel = $this->getReturnLabel();?>
39
+ <legend><?php echo $this->__('Create Return Label?')?></legend>
40
+ <input type="radio" name="shipment[gls][return_label]" id="gls_return_label_yes" value="1" <?php echo $returnLabel ? 'checked="checked"' : '';?> />
41
+ <label for="gls_return_label_yes"><?php echo $this->__('Yes')?></label>
42
+ <br />
43
+ <input type="radio" name="shipment[gls][return_label]" id="gls_return_label_no" value="0" <?php echo !$returnLabel ? 'checked="checked"' : '';?> />
44
+ <label for="gls_return_label_no"><?php echo $this->__('No')?></label>
45
+ </fieldset>
46
+ <fieldset class="gls-selector gls-top-control fifty last">
47
+ <legend><?php echo $this->__('Date to ship the parcel')?></legend>
48
+ <input name="shipment[gls][shipping_date]" readonly="readonly" id="shipping_date" value="<?php echo $this->getShippingDate();?>" tabindex="1" class="input-text" style="width:110px !important;" type="text"> <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif'); ?>" alt="" class="v-middle" id="date_trig" title="<?php echo $this->__('Select Shipment Date');?>" style="">
49
+ <script type="text/javascript">
50
+ //<![CDATA[
51
+ function disabledDate(date) {
52
+ var today = new Date();
53
+ var dd = today.getDate();
54
+ return date.getDate() < dd ;
55
+ };
56
+ Calendar.setup({
57
+ inputField: "shipping_date",
58
+ ifFormat: "%d.%m.%Y",
59
+ showsTime: false,
60
+ button: "date_trig",
61
+ align: "Bl",
62
+ singleClick : true,
63
+ dateStatusFunc : disabledDate
64
+ });
65
+ //]]>
66
+ </script><small><?php echo $this->__('Select the date the parcel will be shipped');?></small>
67
+ </fieldset>
68
+ <div id="inner-gls-form">
69
+ <table class="data" cellspacing="0" cellpadding="0">
70
+ <col width="20%" />
71
+ <col width="40%" />
72
+ <col width="40%" />
73
+ <tbody>
74
+ <tr class="even">
75
+ <td><?php print $this->__('Shipping option') ?></td>
76
+ <td colspan="2">
77
+ <?php
78
+ $readonly = '';
79
+ $hiddenField = '';
80
+ if($this->isParcelshopDelivery()) {
81
+ $readonly = ' disabled="disabled"';
82
+ $hiddenField = '<input id="parcelShopOptionId" type="hidden" name="shipment[gls][combination]" value="'.$this->getParcelShopCombinationId().'" />';
83
+ }
84
+ ?>
85
+
86
+ <select id="glsCombinations" name="shipment[gls][combination]" size="1"<?php echo $readonly;?>>
87
+ <?php foreach ($this->getCombinations() as $option): ?>
88
+ <?php
89
+ $selected = '';
90
+ //var_dump($this->isCombinationSelected($option['value']));
91
+ if($this->isCombinationSelected($option['value'])) :
92
+ $selected = ' selected="selected"';
93
+ endif;
94
+ ?>
95
+ <option value="<?php echo $option['value']; ?>"<?php echo $selected;?>><?php echo $option['label'] ?></option>
96
+ <?php endforeach; ?>
97
+ </select>
98
+ <?php echo $hiddenField;?>
99
+ </td>
100
+ </tr>
101
+ <?php $i = 0 ?>
102
+ <?php foreach($this->getAddonServices() as $service) : ?>
103
+ <?php
104
+ $selected = false;
105
+ if($this->isServiceSelected($service['value'])) :
106
+ $selected = true;
107
+ endif;
108
+ ?>
109
+ <tr class="gls-service-row gls-service-<?php echo $service['value']; ?> <?php echo (++$i % 2) ? 'odd' : 'even' ?>" id="service_<?php echo $service['value']; ?>">
110
+ <td>
111
+ <?php echo $service['label']; ?>
112
+ </td>
113
+ <td>
114
+ <select class="gls-service" name="shipment[gls][service][<?php echo $service['value']; ?>]" size="1">
115
+ <option value="1"<?php echo $selected ? ' selected="selected"' : '';?>><?php print $this->__('Yes') ?></option>
116
+ <option value="0"<?php echo !$selected ? ' selected="selected"' : '';?>><?php print $this->__('No') ?></option>
117
+ </select>
118
+ </td>
119
+ <td>
120
+ <?php if(!empty($service['notice'])) : ?>
121
+ <div class="notice-msg" style="padding-left:35px;min-height: 35px;">
122
+ <small>
123
+ <?php echo $service['notice']; ?>
124
+ </small>
125
+ </div>
126
+ <?php endif; ?>
127
+ </td>
128
+ </tr>
129
+ <?php endforeach; ?>
130
+
131
+ <tr class="even">
132
+ <td>
133
+ <?php print $this->__('Packages') ?>
134
+ </td>
135
+ <td colspan="2"><?php echo $this->getChildHtml('packages') ?></td>
136
+ </tr>
137
+ <tr class="odd">
138
+ <td></td>
139
+ <td colspan="2">
140
+ <div class="notice-msg" style="padding-left:35px;">
141
+ <small id="gls-weight-msg">
142
+ <?php echo $this->__('Advice')?>:<br/>
143
+ <?php echo $this->__('The maximum allowed package weight is %s kg') ?>
144
+ </small>
145
+ </div>
146
+ <?php if($this->isCashService()) : ?>
147
+ <div class="notice-msg" style="padding-left:35px;">
148
+ <small id="gls-cash-msg">
149
+ <?php echo $this->__('Advice')?>:<br/>
150
+ <?php echo $this->__('The maximum allowed cash amount is %s %d') ?>
151
+ </small>
152
+ </div>
153
+ <?php endif; ?>
154
+
155
+ </td>
156
+ <td></td>
157
+ </tr>
158
+ </tbody>
159
+ </table>
160
+ </div>
161
+ <?php } else { ?>
162
+ <p class="notice">
163
+ <strong><?php echo $this->__('Sorry, this shipment can not be sent using GLS.') ?></strong>
164
+ </p>
165
+ <p>
166
+ <?php echo $this->__('Either your shop origin or the ship to country of this order is not within the supported countries.') ?>
167
+ </p>
168
+ <?php } ?>
169
+ </div>
170
+
171
+ <?php
172
+ if ($this->isCountryAvailable()) : ?>
173
+ <script type="text/javascript">
174
+ //<![CDATA[
175
+
176
+ var glsShippingAdmin = new GlsShippingAdmin({
177
+ countryConfig:'<?php echo $this->getCountriesJson();?>',
178
+ isDomestic:'<?php echo $this->isDomestic(); ?>',
179
+ isParcelShopDelivery:'<?php echo $this->isParcelshopDelivery(); ?>',
180
+ parcelShopCombinationId:'<?php echo $this->getParcelShopCombinationId(); ?>',
181
+ config:'<?php echo $this->getJsonConfig(); ?>',
182
+ defaultCombination:'<?php echo $this->getDefaultCombination(); ?>',
183
+ defaultServices: '<?php echo $this->getDefaultServices(); ?>',
184
+ targetCountry:'<?php echo $this->getTargetCountry(); ?>',
185
+ weightWarning:'<?php echo $this->__('Please note the maximum weight') ?>',
186
+ cashWarning:'<?php echo $this->__('Please note the maximum cash amount') ?>',
187
+ emtyMsg:'<?php echo $this->__('Field can not be empty') ?>',
188
+ priceFormat:'<?php echo json_encode(Mage::app()->getLocale()->getJsPriceFormat()) ?>'
189
+ });
190
+
191
+ //]]>
192
+ </script>
193
+ <?php endif;?>
app/design/adminhtml/base/default/template/gls/sales/order/shipment/create/gls/packages.phtml ADDED
@@ -0,0 +1,539 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style type="text/css">
2
+ .dynamic-grid, .dynamic-grid tr td {
3
+ border:0!important;
4
+ width:40%;
5
+ }
6
+
7
+ .addParcel img {
8
+ margin-right:20px;
9
+
10
+ }
11
+
12
+ </style>
13
+ <table id="gls-default-parcel" class="dynamic-grid packages-table" cellspacing="0" cellpadding="0">
14
+ <tr>
15
+ <th><?php echo $this->__('Weight (in kg)') ?></th>
16
+ <th>
17
+ <?php if($this->isCashService()) : ?>
18
+ <?php echo sprintf($this->__('Cash Amount (in %s)'),$this->getCurrency()) ?>
19
+ <?php endif; ?>
20
+ </th>
21
+ </tr>
22
+
23
+ <?php if($this->hasParcels()) : ?>
24
+ <?php $i=0; ?>
25
+ <?php foreach($this->getParcels() as $parcel): ?>
26
+ <tr class="option-row">
27
+ <td><input class="input-text shipping-weight" type="text" name="shipment[packages][package_<?php echo $i;?>][weight]" value="<?php echo $parcel->getWeight() ?>" /></td>
28
+ <td>
29
+ <input class="input-text cash-service <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?>" <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?> style=" <? echo ($this->isCashService() == true) ? '' : 'display:none'; ?>" type="text" name="shipment[packages][package_<?php echo $i;?>][cashservice]" value="<?php echo $this->getStore()->roundPrice($parcel->getCashservice()) ?>" />
30
+ </td>
31
+ <td class="gls-controls"><a class="addParcel" href=""><img src="<?php echo $this->getSkinUrl('images/icon_btn_add.gif');?>" /></a></td>
32
+ </tr>
33
+ <?php $i++;?>
34
+ <?php endforeach; ?>
35
+ <?php else : ?>
36
+ <tr class="option-row">
37
+ <td><input class="input-text shipping-weight" type="text" name="shipment[packages][package_0][weight]" value="<?php echo $this->getWeight() ?>" /></td>
38
+ <td>
39
+ <input class="input-text cash-service <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?>" <? echo ($this->isCashService() == true) ? '' : 'disabled'; ?> style=" <? echo ($this->isCashService() == true) ? '' : 'display:none'; ?>" type="text" name="shipment[packages][package_0][cashservice]" value="<?php echo $this->getCashAmount() ?>" />
40
+ </td>
41
+ <td class="gls-controls"><a class="addParcel" href=""><img src="<?php echo $this->getSkinUrl('images/icon_btn_add.gif');?>" /></a></td>
42
+ </tr>
43
+ <?php endif;?>
44
+ </table>
45
+
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+
49
+ var GlsShippingAdmin = Class.create();
50
+ GlsShippingAdmin.prototype = {
51
+ initialize: function (options) {
52
+ var shippingAdmin = this;
53
+ shippingAdmin.options = Object.extend({
54
+ config:'',
55
+ countryConfig: '',
56
+ isDomestic:0,
57
+ isParcelShopDelivery:0,
58
+ parcelShopCombinationId:null,
59
+ targetCountry:'',
60
+ defaultCombination:'',
61
+ defaultServices:'',
62
+ defaultWeight:0,
63
+ productControl:$('glsCombinations'),
64
+ serviceRows:$$('.gls-service-row'),
65
+ weightMsgContainer:$('gls-weight-msg'),
66
+ cashMsgContainer:$('gls-cash-msg'),
67
+ shippingFormFields:$('inner-gls-form'),
68
+ //just id here no element due to dom ready + magento
69
+ shippingFormButtonContainerId:'ship_items_container',
70
+ shippingFormEditButtonId:'save',
71
+ activeStatusControl:$$('[name="ship_with_gls"]'),
72
+ priceFormat:'{"pattern":"%s €","precision":2,"requiredPrecision":2,"decimalSymbol":",","groupSymbol":".","groupLength":3,"integerRequired":1}',
73
+ weightWarning:'Please note the maximum weight',
74
+ cashWarning:'Please note the maximum cash amount',
75
+ emptyMsg:'Field can not be empty'
76
+
77
+ },options);
78
+ shippingAdmin.config = shippingAdmin.toJson(shippingAdmin.options.config);
79
+ shippingAdmin.countryConfig = shippingAdmin.toJson(shippingAdmin.options.countryConfig);
80
+ shippingAdmin.maxWeight = false;
81
+ shippingAdmin.maxCash = 0;
82
+ shippingAdmin.defaultWeight = <?php echo $this->getDefaultWeight();?>;
83
+ shippingAdmin.currency = 0;
84
+ shippingAdmin.priceFormat = shippingAdmin.toJson(shippingAdmin.options.priceFormat);
85
+ shippingAdmin.history = ['shippingFormButton','shippingFormEditButton'];
86
+ shippingAdmin.isValid = true;
87
+ shippingAdmin.cashService = false;
88
+ shippingAdmin.shippingFormEditButton = false;
89
+
90
+
91
+ Event.observe(document, "dom:loaded", function() {
92
+ shippingAdmin.setShippingFormButton();
93
+ shippingAdmin.addParcel();
94
+ shippingAdmin.removeParcel();
95
+ shippingAdmin.setFormFields(true);
96
+ shippingAdmin.validateForm();
97
+
98
+ /** observe product select **/
99
+ shippingAdmin.options.productControl.observe('change', function () {
100
+ shippingAdmin.setFormFields(false);
101
+ shippingAdmin.validateForm();
102
+ }.bind(this));
103
+
104
+ /** observe enable/disable radios **/
105
+ shippingAdmin.toggleActiveStatus();
106
+ shippingAdmin.options.activeStatusControl.invoke('on','change',function () {
107
+ shippingAdmin.toggleActiveStatus();
108
+ }.bind(this));
109
+
110
+
111
+
112
+ /** observe weight inputs **/
113
+ $('gls-default-parcel').on('change','.shipping-weight', function (event, element) {
114
+ shippingAdmin.validateForm();
115
+ }.bind(this));
116
+
117
+ /** observe cash on delivery inputs **/
118
+ $('gls-default-parcel').on('change','.cash-service', function (event, element) {
119
+ shippingAdmin.validateForm();
120
+ }.bind(this));
121
+ });
122
+ },
123
+
124
+ /**
125
+ * figure out which element is the save button ;-/
126
+ * @return void
127
+ */
128
+ setShippingFormButton: function() {
129
+ var shippingAdmin = this;
130
+ if($(shippingAdmin.options.shippingFormEditButtonId)){
131
+ shippingAdmin.shippingFormEditButton = $(shippingAdmin.options.shippingFormEditButtonId);
132
+ }
133
+ if($(shippingAdmin.options.shippingFormButtonContainerId)) {
134
+ if ($(shippingAdmin.options.shippingFormButtonContainerId).select('button')) {
135
+ shippingAdmin.shippingFormEditButton = $(shippingAdmin.options.shippingFormButtonContainerId).select('button')[0];
136
+ }
137
+ }
138
+ },
139
+
140
+ /**
141
+ * en- or disable other shipping form controls
142
+ * @return void
143
+ */
144
+ toggleActiveStatus: function() {
145
+ var shippingAdmin = this;
146
+
147
+ if(shippingAdmin.getRadioValue('*[name="' + shippingAdmin.options.activeStatusControl[0].readAttribute('name') + '"]') == 0){
148
+ $$('.gls-top-control').invoke('hide');
149
+ shippingAdmin.options.productControl.disabled = true;
150
+ shippingAdmin.options.shippingFormFields.hide();
151
+ }
152
+ else {
153
+ $$('.gls-top-control').invoke('show');
154
+ shippingAdmin.options.productControl.removeAttribute('disabled');
155
+ shippingAdmin.options.shippingFormFields.show();
156
+ }
157
+ shippingAdmin.validateForm();
158
+ },
159
+
160
+ validateForm: function() {
161
+ var shippingAdmin = this;
162
+ shippingAdmin.isValid = true;
163
+
164
+ //it's not gls shipping if active != 1 - ignore everything set valid true
165
+ if(shippingAdmin.getRadioValue('*[name="' + shippingAdmin.options.activeStatusControl[0].readAttribute('name') + '"]') == 1) {
166
+ //no product selected set valid false
167
+ if(shippingAdmin.options.productControl.getValue()) {
168
+ shippingAdmin.validateParcelInputs();
169
+ }
170
+ else{
171
+ shippingAdmin.isValid = false;
172
+ //if no product selected remove all max warnings as there is no config
173
+ shippingAdmin.removeParcelWarnings();
174
+ }
175
+ }
176
+ else {
177
+ shippingAdmin.isValid = true;
178
+ }
179
+
180
+ shippingAdmin.setFormSubmitAction();
181
+ },
182
+
183
+ /**
184
+ * make sure in weight and cash fields are no invalid figures
185
+ * @return boolean
186
+ */
187
+ validateNumber: function(element, max, msg) {
188
+ var shippingAdmin = this;
189
+ var isValid = true;
190
+ var currentValue = parseFloat(element.getValue().replace(/,/g, '.').replace(new RegExp('/'+ shippingAdmin.priceFormat.decimalSymbol +'/g'), '.'));
191
+ var floatMax = Math.floor(parseFloat(max));
192
+ if(shippingAdmin.isNaN(currentValue)){
193
+ currentValue = 0;
194
+ }
195
+ if(currentValue <= 0){
196
+ if(!element.up().select('.warning').length) {
197
+ element.up().appendChild(new Element('div', {class: 'error warning'}).update(shippingAdmin.options.emptyMsg));
198
+ }
199
+ isValid = false;
200
+ }
201
+
202
+ if(currentValue > floatMax){
203
+ element.setValue(currentValue.toFixed(2).replace('.', shippingAdmin.priceFormat.decimalSymbol));
204
+ if(!element.up().select('.warning').length) {
205
+ element.up().appendChild(new Element('div', {class: 'error warning'}).update(msg));
206
+ }
207
+ else{
208
+ element.up().select('.warning')[0].update(msg);
209
+ }
210
+ isValid = false;
211
+ }
212
+
213
+ if(isValid == true){
214
+ element.setValue(currentValue.toFixed(2).replace('.', shippingAdmin.priceFormat.decimalSymbol));
215
+ if(element.up().select('.warning').length) {
216
+ element.up().select('.warning')[0].remove();
217
+ }
218
+ }
219
+ return isValid;
220
+ },
221
+
222
+ /**
223
+ * add single parcel to list
224
+ * @return void
225
+ */
226
+ addParcel: function() {
227
+ var shippingAdmin = this;
228
+
229
+ if($$(".addParcel").length) {
230
+ $$(".addParcel")[0].up('.option-row').up().on("click", ".addParcel", function (event, element) {
231
+ Event.stop(event);
232
+ var defaultRow = $$('.packages-table tr:nth-child(2)')[0];
233
+ var copy = Element.clone(defaultRow, true);
234
+ var weightFields = $$('.packages-table')[0].up().select('[name^="shipment[packages][package_"]');
235
+ var index = 0;
236
+ weightFields.each(function (element) {
237
+ var string = element.readAttribute('name');
238
+ var currentNumber = Math.max.apply(null, string.match(/\d+/g));
239
+ if (currentNumber >= index)
240
+ {
241
+ index = currentNumber + 1;
242
+ }
243
+ });
244
+ if (copy.select('.warning').length) {
245
+ copy.select('.warning').each(function (element) {
246
+ element.remove();
247
+ });
248
+ }
249
+ copy.select('[name="shipment[packages][package_0][weight]"]')[0].setValue('');
250
+ copy.select('[name="shipment[packages][package_0][weight]"]')[0].setAttribute('name', 'shipment[packages][package_' + index + '][weight]');
251
+ if (copy.select('[name="shipment[packages][package_0][cashservice]"]').length) {
252
+ copy.select('[name="shipment[packages][package_0][cashservice]"]')[0].setValue('');
253
+ copy.select('[name="shipment[packages][package_0][cashservice]"]')[0].setAttribute('name', 'shipment[packages][package_' + index + '][cashservice]');
254
+ }
255
+ defaultRow.up().appendChild(copy);
256
+ copy.select('.addParcel')[0].up().appendChild(new Element('a', {
257
+ class: 'removeParcel',
258
+ href: ''
259
+ }).update(new Element('img', {'src': '<?php echo $this->getSkinUrl('images/icon_btn_delete.gif');?>'})));
260
+
261
+ });
262
+ }
263
+ },
264
+
265
+ /**
266
+ * remove single parcel from list
267
+ * @return void
268
+ */
269
+ removeParcel: function() {
270
+ if($$(".addParcel").length) {
271
+ $$(".addParcel")[0].up('.option-row').up().on("click", ".removeParcel", function (event, element) {
272
+ Event.stop(event);
273
+ element.up('.option-row').remove();
274
+ });
275
+ }
276
+ },
277
+
278
+ /**
279
+ * validate inputs for each parsel
280
+ * @return void
281
+ */
282
+ validateParcelInputs: function() {
283
+ var shippingAdmin = this;
284
+ isValid = true;
285
+
286
+ $$('.shipping-weight').each(function (element) {
287
+ if (shippingAdmin.validateNumber(element, shippingAdmin.maxWeight, shippingAdmin.options.weightWarning) == false) {
288
+ isValid = false;
289
+ }
290
+ });
291
+
292
+ if (shippingAdmin.cashService == true) {
293
+ $$('.cash-service').each(function (element) {
294
+ if (shippingAdmin.validateNumber(element, shippingAdmin.maxCash, shippingAdmin.options.cashWarning) == false) {
295
+ isValid = false;
296
+ }
297
+ });
298
+ }
299
+
300
+ shippingAdmin.isValid = isValid;
301
+
302
+ },
303
+ removeParcelWarnings: function() {
304
+ $$('.shipping-weight').each(function (element) {
305
+ if( element.up().select('.warning').length) {
306
+ element.up().select('.warning')[0].remove();
307
+ }
308
+ });
309
+ $$('.cash-service').each(function (element) {
310
+ if( element.up().select('.warning').length) {
311
+ element.up().select('.warning')[0].remove();
312
+ }
313
+ });
314
+ },
315
+
316
+ /**
317
+ * enable/disable form submit (dependent on valid state)
318
+ * @return void
319
+ */
320
+ setFormSubmitAction: function() {
321
+ var shippingAdmin = this;
322
+
323
+ if(shippingAdmin.shippingFormEditButton && shippingAdmin.isValid == false) {
324
+ if(!shippingAdmin.history.shippingFormEditButton) {
325
+ shippingAdmin.history.shippingFormEditButton = shippingAdmin.shippingFormEditButton.readAttribute('onclick');
326
+ }
327
+ shippingAdmin.shippingFormEditButton.removeAttribute('onclick');
328
+ }
329
+ if(shippingAdmin.shippingFormEditButton && shippingAdmin.isValid == true && shippingAdmin.history.shippingFormEditButton) {
330
+ shippingAdmin.shippingFormEditButton.setAttribute('onclick', shippingAdmin.history.shippingFormEditButton);
331
+ }
332
+ },
333
+
334
+ /**
335
+ * setting the initial values shipping form
336
+ * @return void
337
+ */
338
+ setFormFields: function(init) {
339
+ var shippingAdmin = this;
340
+
341
+ shippingAdmin.hasCashService();
342
+ shippingAdmin.options.serviceRows.invoke('hide');
343
+
344
+ shippingAdmin.setCashServiceField();
345
+
346
+ shippingAdmin.options.serviceRows.each(function(row){
347
+ row.select('.gls-service')[0].setAttribute('disabled', 'disabled');
348
+ });
349
+ if(!init) {
350
+ shippingAdmin.options.serviceRows.each(function(row){
351
+ row.select('.gls-service')[0].setValue(0);
352
+ });
353
+ }
354
+ else {
355
+ shippingAdmin.initForm();
356
+ }
357
+
358
+ if(shippingAdmin.options.productControl.getValue()){
359
+ shippingAdmin.setServiceOptions();
360
+
361
+ //TODO: refactor
362
+ //revalidate formfields also if form already invalid to show messages for all fields
363
+ $$('.shipping-weight').each(function(element){
364
+ shippingAdmin.validateNumber(element,shippingAdmin.maxWeight,shippingAdmin.options.weightWarning);
365
+ });
366
+ if(shippingAdmin.cashService == true) {
367
+ $$('.cash-service').each(function (element) {
368
+ shippingAdmin.validateNumber(element, shippingAdmin.maxCash, shippingAdmin.options.cashWarning);
369
+ });
370
+ }
371
+
372
+ }
373
+ else {
374
+ shippingAdmin.options.weightMsgContainer.up().hide();
375
+ }
376
+ },
377
+
378
+ /**
379
+ * en/disable cashinput
380
+ * @return void
381
+ */
382
+ setCashServiceField: function(){
383
+ var shippingAdmin = this;
384
+
385
+ if(shippingAdmin.cashService == true){
386
+ $$('.cash-service').each(function (element) {
387
+ element.removeClassName('disabled');
388
+ element.removeAttribute('disabled');
389
+ element.removeAttribute('style');
390
+
391
+ });
392
+ }
393
+ else{
394
+ $$('.cash-service').each(function (element) {
395
+ element.addClassName('disabled');
396
+ element.setAttribute('disabled','disabled');
397
+ element.setAttribute('style', 'display:none');
398
+ if(element.up().select('.warning').length) {
399
+ element.up().select('.warning')[0].remove();
400
+ }
401
+ });
402
+ }
403
+
404
+ },
405
+
406
+ /**
407
+ * set flag if product has cash service
408
+ * @return void
409
+ */
410
+ hasCashService: function(){
411
+ var shippingAdmin = this;
412
+
413
+ shippingAdmin.countryConfig.options.each(function(obj){
414
+ if(shippingAdmin.options.productControl.getValue() == obj.combination) {
415
+ if(obj.cashservice == true){
416
+ shippingAdmin.cashService = true;
417
+ }
418
+ else{
419
+ shippingAdmin.cashService = false;
420
+ }
421
+ }
422
+ });
423
+ },
424
+ /**
425
+ * set available additional services for selected product (combination)
426
+ * @return void
427
+ */
428
+
429
+ setServiceOptions: function(){
430
+ var shippingAdmin = this;
431
+
432
+ shippingAdmin.countryConfig.options.each(function(obj){
433
+ if(shippingAdmin.options.productControl.getValue() == obj.combination){
434
+
435
+ obj.addon_services.each(function(service){
436
+ $('service_' + service).show();
437
+ $('service_' + service).select('.gls-service')[0].removeAttribute('disabled');
438
+ });
439
+
440
+ /** updating max weight and max cash info and validation **/
441
+ if(shippingAdmin.options.isDomestic){
442
+ shippingAdmin.maxWeight = shippingAdmin.config.domestic.maxweight;
443
+ shippingAdmin.maxCash = shippingAdmin.config.domestic.cashmax;
444
+ shippingAdmin.currency = shippingAdmin.config.domestic.cashcurrency;
445
+ if(shippingAdmin.options.isParcelShopDelivery){
446
+ shippingAdmin.maxWeight = shippingAdmin.config.domestic.parcelshopweight;
447
+ }
448
+ }
449
+ else {
450
+ if(shippingAdmin.options.targetCountry) {
451
+ shippingAdmin.maxWeight = shippingAdmin.config.foreign.countries[shippingAdmin.options.targetCountry].maxweight;
452
+ if (shippingAdmin.options.isParcelShopDelivery) {
453
+ shippingAdmin.maxWeight = shippingAdmin.config.foreign.countries[shippingAdmin.options.targetCountry].parcelshopweight;
454
+
455
+ }
456
+ }
457
+ }
458
+
459
+ if(shippingAdmin.options.weightMsgContainer) {
460
+ shippingAdmin.options.weightMsgContainer.select('#gls-max-weight')[0].update(shippingAdmin.maxWeight);
461
+ }
462
+ if(shippingAdmin.options.cashMsgContainer) {
463
+ shippingAdmin.options.cashMsgContainer.select('#gls-max-cash')[0].update(shippingAdmin.maxCash);
464
+ shippingAdmin.options.cashMsgContainer.select('#gls-cash-currency')[0].update(shippingAdmin.currency);
465
+ }
466
+ shippingAdmin.options.weightMsgContainer.up().show();
467
+
468
+ }
469
+ });
470
+ },
471
+
472
+ /**
473
+ * set form status on load
474
+ * @return String
475
+ */
476
+ initForm: function () {
477
+ var shippingAdmin = this;
478
+
479
+ if(shippingAdmin.options.isDomestic == false){
480
+ $('gls_return_label_no').checked = true;
481
+ $('gls_return_label_yes').checked = false;
482
+ $$('*[name="shipment[gls][return_label]"]').each(function(element){
483
+ element.setAttribute('disabled', 'disabled');
484
+ });
485
+
486
+ }
487
+
488
+ if (!shippingAdmin.options.isParcelShopDelivery) {
489
+ $$('#glsCombinations option[value="' + shippingAdmin.options.parcelShopCombinationId + '"]')[0].remove();
490
+ }
491
+ else {
492
+ $$('#glsCombinations option').each(function (element) {
493
+ var value = element.readAttribute('value');
494
+ if(value != shippingAdmin.options.parcelShopCombinationId){
495
+ element.remove();
496
+ }
497
+ });
498
+ }
499
+ shippingAdmin.options.weightMsgContainer.update(shippingAdmin.options.weightMsgContainer.innerHTML.replace('%s', '<span id="gls-max-weight">' + shippingAdmin.defaultWeight + '</span>'));
500
+ if (shippingAdmin.options.cashMsgContainer) {
501
+ shippingAdmin.options.cashMsgContainer.update(shippingAdmin.options.cashMsgContainer.innerHTML.replace('%s', '<span id="gls-max-cash"></span>'));
502
+ shippingAdmin.options.cashMsgContainer.update(shippingAdmin.options.cashMsgContainer.innerHTML.replace('%d', '<span id="gls-cash-currency">' + shippingAdmin.options.currency + '</span>'));
503
+ }
504
+ shippingAdmin.countryConfig.options.each(function(obj){
505
+ if($$('#glsCombinations option[value="' + obj.combination + '"]').length){
506
+ if(obj.domestic == false && shippingAdmin.options.isDomestic == true){
507
+ $$('#glsCombinations option[value="' + obj.combination + '"]')[0].remove();
508
+ }
509
+ if(obj.foreign == false && shippingAdmin.options.isDomestic == false){
510
+ $$('#glsCombinations option[value="' + obj.combination + '"]')[0].remove();
511
+ }
512
+ }
513
+ });
514
+ },
515
+
516
+ /**
517
+ * parse json...
518
+ * @return {Object}
519
+ */
520
+ toJson: function(obj) {
521
+ return JSON.parse(obj);
522
+ },
523
+
524
+ /**
525
+ * get currently checked radio button of radio group
526
+ * @return String
527
+ */
528
+ getRadioValue: function ($elm) {
529
+ return $$($elm + ':checked').first().value;
530
+ },
531
+
532
+ isNaN: function (o) {
533
+ return o !== o;
534
+ }
535
+
536
+ }
537
+
538
+ //]]>
539
+ </script>
app/design/adminhtml/base/default/template/gls/sales/order/shipment/view/gls.phtml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var SynergeticAgency_Gls_model_Shipment $_glsShipment */
3
+ $_glsShipment = $this->getGlsShipment();
4
+
5
+ if ($_glsShipment && $_glsShipment->getId()):
6
+ $services = $_glsShipment->getServices(true);
7
+ $serviceNames = array();
8
+ foreach($services as $service) {
9
+ $serviceNames[] = $service->getName();
10
+ }
11
+ ?>
12
+ <h3><?php echo $this->__('GLS Shipment');?></h3>
13
+ <div class="field-row grid">
14
+ <table class="data" cellspacing="0">
15
+ <col width="40%" />
16
+ <col width="60%" />
17
+ <tbody>
18
+ <tr class="even">
19
+ <td><?php print $this->__('Shipping option') ?></td>
20
+ <td><?php echo $_glsShipment->getCombination()->getName() ?></td>
21
+ </tr>
22
+ <tr class="odd">
23
+ <td><?php echo $this->__('Services') ?></td>
24
+ <td>
25
+ <?php if(count($serviceNames)) :
26
+ echo implode(', ',$serviceNames);
27
+ endif; ?>
28
+ </td>
29
+ </tr>
30
+ <tr class="even">
31
+ <td><?php print $this->__('Shipping Date') ?></td>
32
+ <td>
33
+ <?php $format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
34
+ echo Mage::app()->getLocale()->date(strtotime($_glsShipment->getShippingDate()))->toString($format); ?>
35
+ </td>
36
+ </tr>
37
+ <tr class="odd">
38
+ <td><?php print $this->__('Sandbox') ?></td>
39
+ <td><?php echo $_glsShipment->getSandbox() == '1' ? $this->__('Yes') : $this->__('No') ?></td>
40
+ </tr>
41
+ <tr class="even">
42
+ <td><?php print $this->__('Return Label') ?></td>
43
+ <td><?php echo $_glsShipment->getReturnLabel() == '1' ? $this->__('Yes') : $this->__('No') ?></td>
44
+ </tr>
45
+ <tr class="odd">
46
+ <td><?php print $this->__('GLS Consignment ID') ?></td>
47
+ <td><?php echo $_glsShipment->getConsignmentId() ?></td>
48
+ </tr>
49
+ <tr class="even">
50
+ <td><strong><?php echo $this->__('Status')?></strong></td>
51
+ <td><strong><?php echo $_glsShipment->getPrinted() == '1' ? $this->__('Printed') : $this->__('Not printed') ?></strong></td>
52
+ </tr>
53
+ <tr class="odd">
54
+ <td colspan="2">
55
+ <?php echo $this->__('Packages') ?>
56
+ <table class="data" cellspacing="0">
57
+ <?php $i=1; ?>
58
+ <tr>
59
+ <th><?php echo $this->__('Parcel #');?></th>
60
+ <th><?php echo $this->__('Weight (in kg)');?></th>
61
+ <th><?php echo sprintf($this->__('Cash Amount (in %s)'),$this->getCurrency()) ?></th>
62
+ <th><?php echo $this->__('Parcel Number');?></th>
63
+ </tr>
64
+ <?php foreach ($_glsShipment->getShipmentParcels() as $parcel) : ?>
65
+ <tr>
66
+ <td><?php echo $i;?></td>
67
+ <td><?php echo $parcel->getWeight();?></td>
68
+ <td><?php echo $this->formatPrice($parcel->getCashservice());?></td>
69
+ <td><?php echo $parcel->getParcelNumber();?></td>
70
+ </tr>
71
+ <?php $i++;;?>
72
+ <?php endforeach; ?>
73
+ </table>
74
+ </td>
75
+ </tr>
76
+ </tbody>
77
+ </table>
78
+ </div>
79
+ <p class="form-buttons">
80
+ <?php if($_glsShipment->getPrinted() != '1') : ?>
81
+ <button id="pdf" type="button" class="scalable save" onclick="setLocation('<?php echo $this->getUrl('adminhtml/gls_shipment/print', array('id' => $_glsShipment->getId())); ?>');this.disabled=true;this.className += ' disabled';document.getElementById('edit_gls_shipment').disabled=true;document.getElementById('edit_gls_shipment').className += ' disabled';" style="">
82
+ <span><?php echo $this->__("PDF") ?></span>
83
+ </button>
84
+ <button id="edit_gls_shipment" type="button" class="scalable save" onclick="setLocation('<?php echo $this->getUrl('adminhtml/gls_shipment/edit', array('id' => $_glsShipment->getId())); ?>')" style="">
85
+ <span><?php echo $this->helper('sales')->__('Edit') ?></span>
86
+ </button>
87
+ <?php endif; ?>
88
+ </p>
89
+ <?php endif; ?>
app/design/adminhtml/base/default/template/gls/shipment/edit.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $glsShipment = Mage::registry('gls_shipment');
3
+ $shipment = Mage::registry('current_shipment');
4
+ ?>
5
+ <div class="content-header">
6
+ <h3 class="icon-head head-adminhtml-sales-shipment">
7
+ <?php echo $this->getHeaderText() ?>
8
+ </h3>
9
+ <div style="float: right;"><?php echo $this->getButtonsHtml() ?></div>
10
+ </div>
11
+ <div class="entry-edit">
12
+ <form method="post" action="<?php echo $this->getUrl('*/*/save', array('id' => $glsShipment->getId()));?>" id="edit_form">
13
+ <input type="hidden" name="shipment_id" value="<?php echo $shipment->getId(); ?>" />
14
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
15
+ <div class="entry-edit-head">
16
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('GLS Shipment Data');?></h4>
17
+ </div>
18
+ <?php echo $this->getChildHtml('gls_shipment_edit_form'); ?>
19
+ </form>
20
+ </div>
21
+ <script type="text/javascript">
22
+ editForm = new varienForm('edit_form', '');
23
+ </script>
app/design/adminhtml/base/default/template/gls/system/config/note.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <table class="switcher" width="100%" cellpadding="5" style="border-spacing:10px">
2
+ <tbody>
3
+ <tr>
4
+ <td>
5
+ <a href="<?php echo $this->escapeHtml($this->getAgencyUrl())?>" target="_blank"><IMG border="0" src="<?php echo $this->escapeHtml($this->getAgencyLogoUrl())?>"></a>
6
+ </td>
7
+ </tr>
8
+ <tr><td><hr/></td></tr>
9
+ <tr>
10
+ <td>
11
+ <b><?php echo Mage::helper('synergeticagency_gls')->__('Support')?></b>
12
+ </td>
13
+ </tr>
14
+ <tr>
15
+ <td>
16
+ <?php echo Mage::helper('synergeticagency_gls')->__('If you need assistance setting up the GLS credentials and GLS services')?>,<br />
17
+ <a href="<?php echo $this->getSupportUrl();?>" target="_blank"><?php echo Mage::helper('synergeticagency_gls')->__('feel free to <b>contact</b> us.')?></a>
18
+ <br /><br />
19
+ <?php echo Mage::helper('synergeticagency_gls')->__('To manage your GLS assignments, your account data etc. and for informations regarding your customer account, please use')?><br />
20
+ <a href="<?php echo $this->getAgencyUrl();?>" target="_blank"><?php echo Mage::helper('synergeticagency_gls')->__('your <b>YourGLS</b> account.')?></a>
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <td>
25
+ &nbsp;
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td>
30
+ <?php echo Mage::helper('synergeticagency_gls')->__('Version')?>: <b><?php echo Mage::helper('synergeticagency_gls')->getExtensionVersion();?></b>
31
+ </td>
32
+ </tr>
33
+ </tbody>
34
+ </table>
app/design/adminhtml/base/default/template/gls/system/shipping/gls_applicable_country.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ if (typeof CountryModel !== 'undefined') {
3
+ CountryModel.prototype.hideElement = CountryModel.prototype.hideElement.wrap(
4
+ function (parentMethod, elm) {
5
+ parentMethod(elm);
6
+ if (elm && elm.readAttribute('id') == 'row_carriers_synergeticagency_gls_showmethod') {
7
+ if (!elm.down('.shipping-skip-show')) {
8
+ elm.show();
9
+ }
10
+ }
11
+ }
12
+ );
13
+ if($('row_carriers_synergeticagency_gls_showmethod') != undefined) {
14
+ $('row_carriers_synergeticagency_gls_showmethod').show();
15
+ }
16
+ }
17
+ </script>
app/design/frontend/base/default/layout/synergeticagency/gls.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <checkout_onepage_index>
4
+ <reference name="form.additional.info">
5
+ <block type="synergeticagency_gls/checkout_onepage_parcelshop" name="gls.checkout.onepage.billing.extra.parcelshop" template="gls/checkout/onepage/billing_form_additional_parcelshop.phtml" />
6
+ </reference>
7
+ <reference name="checkout.onepage.shipping">
8
+ <action method="setTemplate"><template>gls/checkout/onepage/shipping.phtml</template></action>
9
+ <block type="checkout/onepage_shipping" name="checkout.onepage.shipping.original" as="shipping_original" template="checkout/onepage/shipping.phtml"/>
10
+ <block type="synergeticagency_gls/checkout_onepage_parcelshop" name="gls.checkout.onepage.shipping.parcelshop" as="gls_shipping_parcelshop" template="gls/checkout/onepage/shipping_parcelshop.phtml" />
11
+ </reference>
12
+ <reference name="head">
13
+ <action ifconfig="gls/parcel_shop/parcel_shop_enabled" method="addJs">
14
+ <script>gls/frontend.js</script>
15
+ </action>
16
+ </reference>
17
+ <reference name="head">
18
+ <action ifconfig="gls/parcel_shop/parcel_shop_css_enabled" method="addCss">
19
+ <script>css/gls/frontend.css</script>
20
+ </action>
21
+ </reference>
22
+ </checkout_onepage_index>
23
+ <synergeticagency_gls_frontend_parcelshopmap>
24
+ <reference name="root">
25
+ <action method="setTemplate">
26
+ <template>page/popup.phtml</template>
27
+ </action>
28
+ </reference>
29
+ <reference name="content">
30
+ <block type="synergeticagency_gls/checkout_onepage_parcelshop_map" name="gls.checkout.onepage.parcelshop.map" template="gls/checkout/onepage/parcelshop/map.phtml"/>
31
+ </reference>
32
+ </synergeticagency_gls_frontend_parcelshopmap>
33
+ </layout>
app/design/frontend/base/default/template/gls/checkout/onepage/billing_form_additional_parcelshop.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php if($this->isActive()) { ?>
2
+ <li class="control" id="parcelshop_control">
3
+ <input type="radio" class="radio" title="<?php print $this->__('Ship to Parcelshop') ?>" value="2" id="billing:use_for_parcelshop" name="billing[use_for_shipping]"><label for="billing:use_for_parcelshop"><?php print $this->__('Ship to Parcelshop') ?></label>
4
+ </li>
5
+ <?php } ?>
app/design/frontend/base/default/template/gls/checkout/onepage/parcelshop/map.phtml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript">
2
+ function toJson(obj) {
3
+ return JSON.stringify(obj, null, 2);
4
+ }
5
+
6
+ window.addEventListener('message', function(e) {
7
+ window.opener.postMessage(e.data, '*');
8
+ window.close(self);
9
+ }, false);
10
+
11
+ function getParameterByName(name, url) {
12
+ if (!url) url = window.location.href;
13
+ name = name.replace(/[\[\]]/g, "\\$&");
14
+ var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
15
+ results = regex.exec(url);
16
+ if (!results) return null;
17
+ if (!results[2]) return '';
18
+ return decodeURIComponent(results[2].replace(/\+/g, " "));
19
+ }
20
+ var origin = location.protocol + '//' + location.host + location.pathname
21
+ var countryCode = '';
22
+ var zip = '';
23
+ if(getParameterByName('countryCode')){
24
+ countryCode = '&countryCode=' + getParameterByName('countryCode');
25
+ }
26
+ if(getParameterByName('zip')){
27
+ zip = '&zip=' + getParameterByName('zip');
28
+ }
29
+
30
+ </script>
31
+ <style type="text/css">
32
+ body, div {
33
+ height: 100%!important;
34
+ display: block;
35
+ position: absolute;
36
+ width: 100%;
37
+ margin:0;
38
+ }
39
+ .page-popup {
40
+ padding: 0;
41
+ }
42
+ </style>
43
+
44
+ <script type="text/javascript">
45
+ document.write('<iframe src="<?php echo Mage::getStoreConfig('gls/parcel_shop/parcel_shop_url'); ?>?origin=' + origin + countryCode + zip + '" frameborder="0" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="auto"></iframe>');
46
+ </script>
app/design/frontend/base/default/template/gls/checkout/onepage/shipping.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ echo $this->getChildHtml('shipping_original');
3
+ echo $this->getChildHtml('gls_shipping_parcelshop');
app/design/frontend/base/default/template/gls/checkout/onepage/shipping_parcelshop.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if($this->isActive()) { ?>
2
+ <ul id="parcelshop_fields" class="form-list">
3
+ <li class="fields" style="display:none;">
4
+ <div class="fields">
5
+ <label for="shipping:parcelshop_name"><?php print $this->__('Parcelshop Name') ?></label>
6
+ <div class="input-box">
7
+ <input type="text"
8
+ id="shipping:parcelshop_name"
9
+ name="shipping[parcelshop_name]"
10
+ value=""
11
+ title="<?php print $this->__('Parcelshop Name') ?>"
12
+ class="input-text required-entry">
13
+ </div>
14
+ </div>
15
+ </li>
16
+ <li class="fields" style="display:none;">
17
+ <label for="shipping:parcelshop_id"><?php print $this->__('Parcelshop ID') ?></label>
18
+ <div class="input-box">
19
+ <input type="text"
20
+ id="shipping:parcelshop_id"
21
+ name="shipping[parcelshop_id]"
22
+ value=""
23
+ title="<?php print $this->__('Parcelshop ID') ?>"
24
+ class="input-text required-entry">
25
+ </div>
26
+ </li>
27
+ </ul>
28
+ <ul class="form-list">
29
+ <li class="control" id="parcelshopfinder_control">
30
+ <input type="checkbox"
31
+ class="checkbox packstation_checkbox"
32
+ title="<?php print $this->__('Ship to Parcelshop'); ?>"
33
+ name="shipping[parcelshop_active]"
34
+ value="1"
35
+ id="shipping:parcelshop_active">
36
+ <label id="package_announcement_label" for="shipping:parcelshop_active"> <?php print $this->__('Ship to Parcelshop') ?></label>
37
+ <button type="button" class="button" id="shipping:findGlsParcelShop" title="<?php print $this->__('Find parcel shop') ?>"><span><span><?php print $this->__('Find parcel shop') ?></span></span></button>
38
+ </li>
39
+ </ul>
40
+ <script type="text/javascript">
41
+ //<![CDATA[
42
+ var glsParcelShop = new GlsParcelShop({config: '<?php echo $this->getCountriesJson(); ?>', countryConfig: '<?php echo $this->getJsonConfig(); ?>', origin:'<?php echo Mage::helper('core/url')->getCurrentUrl(); ?>', notSelectedLabel:'<?php print $this->__('Please select a parcel shop') ?>', invalidShopLabel:'<?php print $this->__('The selected shop is not allowed for your country') ?>', billingInfoUrl:'<?php print Mage::getUrl('gls/frontend/parcelShopMapParams',array('_secure'=>true)) ?>', parcelShopFinderUrl:'<?php print Mage::getUrl('gls/frontend/parcelShopMap',array('_secure'=>true)) ?>'});
43
+ //]]>
44
+ </script>
45
+ <?php } ?>
app/design/frontend/base/default/template/gls/form/glscashondelivery.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @see Saas_Payment_Block_Form_Glscashondelivery
5
+ */
6
+ ?>
7
+ <?php if ($this->getInstructions()): ?>
8
+ <ul class="form-list checkout-agreements" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
9
+ <li>
10
+ <div class="<?php echo $this->getMethodCode() ?>-instructions-content agreement-content">
11
+ <?php echo nl2br($this->getInstructions()) ?>
12
+ </div>
13
+ </li>
14
+ </ul>
15
+ <?php endif; ?>
app/design/frontend/base/default/template/gls/logoJs.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $logoJs = '';
3
+ foreach($this->getLogos() AS $logoKey => $logoSrc){
4
+ $logoJs .= 'radio = $("s_method_synergeticagency_gls_'.$logoKey.'");';
5
+ $logoJs .= 'if(radio != undefined) { ';
6
+ $logoJs .= ' if(radio.up().hasClassName("no-display") && $("logo_'.$logoKey.'") == undefined){';
7
+ $logoJs .= ' radio.up().next("label").insert({top: new Element("img", {src: "'.$logoSrc.'", id: "logo_'.$logoKey.'"})}) ';
8
+ $logoJs .= ' }else if ($("logo_'.$logoKey.'") == undefined){';
9
+ $logoJs .= ' radio.next("label").insert({top: new Element("img", {src: "'.$logoSrc.'", id: "logo_'.$logoKey.'"})})';
10
+ $logoJs .= ' }';
11
+ $logoJs .= '}';
12
+ }
13
+
14
+ ?>
15
+ <script type="text/javascript">
16
+ //<![CDATA[
17
+ if (typeof Checkout !== 'undefined') {
18
+ Checkout.prototype.gotoSection = Checkout.prototype.gotoSection.wrap(
19
+ function (parentMethod, section, reloadProgressBlock) {
20
+ parentMethod(section, reloadProgressBlock);
21
+ var radio = '';
22
+ if (section == "shipping_method") {
23
+ try {
24
+ <?php echo $logoJs ?>
25
+ } catch (err) {
26
+ var e = new Error("An error occurred setting GLS logos");
27
+ console.log(e.toString());
28
+ }
29
+ }
30
+ }
31
+ );
32
+ }
33
+ //]]>
34
+ </script>
app/etc/modules/SynergeticAgency_Gls.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <SynergeticAgency_Gls>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </SynergeticAgency_Gls>
8
+ </modules>
9
+ </config>
app/locale/de_DE/SynergeticAgency_Gls.csv ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Basic configuration","Basiskonfiguration"
2
+ "Enabled","Aktiviert"
3
+ "Sandbox-Mode","Sandbox-Modus"
4
+ "Log requests and responses of the GLS API","Webservice-Anfragen und -Antworten protokollieren"
5
+ "Please ensure that the Magento-Log is activated","Bitte stellen Sie sicher, dass das Magento-Log ebenfalls aktiviert ist."
6
+ "In Sandbox-Mode, the GLS-plugin will connect to the GLS-Sandbox. Labels and all other processes have no effect on the GLS productive environment. Use the test mode in your development- or test-systems.","Im Sandbox-Modus verbindet sich das GLS-Plugin mit der GLS-Testumgebung. Gedruckte Label und Prozesse haben keine Auswirkung im GLS-Produktivsystem. Verwenden Sie den Testmodus z.B. für Ihre Entwicklungs- oder Test-Systeme."
7
+ "Debug mode","Debug-Modus"
8
+ "In debug mode all relevant processes are logged. Attention, the log file can become very large in debug mode!","Im Debug-Modus werden alle relevanten Prozesse geloggt. Achtung, das Logfile kann im Debug-Modus sehr groß werden!"
9
+ "When enabled, additional Connector debug information will be written into a Connector Logfile %s.","Bei Aktivierung des Connector Loggings werden zusätzliche Debuginformationen in ein Connectorlogfile %s geschrieben."
10
+ "This URL should not be changed.","Diese URL sollte standardmäßig nicht geändert werden."
11
+ "GLS-API URL","GLS-API URL"
12
+ "GLS-JSON-Config URL","GLS-JSON-Config URL"
13
+ "Please note that not all label sizes are supported in some circumstances. Default is 'A6'. For details see manual.","Please note that not all label sizes are supported in some circumstances. Default is 'A6'. For details see manual."
14
+ "Creation of the label with the GLS-ConsignmentId %s failed","Erstellung des Labels mit der GLS-ConsignmentId %s ist fehlgeschlagen"
15
+ "GLS tracking URL","GLS Tracking URL"
16
+ "GLS-API Username","GLS-API-Benutzername"
17
+ "GLS-API Password","GLS-API Passwort"
18
+ "GLS customer ID","GLS Kunden-ID"
19
+ "GLS customer ID. For details see manual.","GLS Customer-ID. Für weitere Informationen sehen Sie bitte im Benutzerhandbuch nach."
20
+ "GLS contact ID","GLS Kontakt-ID"
21
+ "GLS contact ID. For details see manual.","GLS Kontakt-ID. Für weitere Informationen sehen Sie bitte im Benutzerhandbuch nach."
22
+ "Shipment options","Sendungseinstellungen"
23
+ "Default weight","Standardgewicht"
24
+ "weight in kilogram (kg)","Gewicht in kg"
25
+ "Default GLS product","Standard-GLS-Produkt"
26
+ "For international shipments EuroBusinessParcel is chosen by default. Default product is only selected when possibile.","Für Auslandsversand wird im Standard EuroBusinessParcel ausgewählt. Das Standardprodukt wird nur ausgewählt, wenn die Sendung dies ermöglicht."
27
+ "Default GLS services","Standard-GLS-Service"
28
+ "Service gets only selected if combination is available.","Service wird nur ausgewählt, wenn Kombination möglich ist."
29
+ "Create return label","Retouren-Label erzeugen"
30
+ "Alternative shipper data","Abweichende Versenderdaten"
31
+ "Alternative shipper enabled","Abweichender Versender aktiviert"
32
+ "Name 1","Name 1"
33
+ "Name 2","Name 2"
34
+ "Name 3","Name 3"
35
+ "Street","Straße"
36
+ "Country","Land"
37
+ "ZIP code","PLZ"
38
+ "City","Stadt"
39
+ "GLS ParcelShop","GLS PaketShop"
40
+ "GLS ParcelShop enabled","GLS PaketShop aktiviert"
41
+ "URL for GLS ParcelShop service","URL für den GLS PaketShop-Service"
42
+ "BusinessParcel","BusinessParcel"
43
+ "EuroBusinessParcel","EuroBusinessParcel"
44
+ "CashService","CashService"
45
+ "Guaranteed24Service","Guaranteed24Service"
46
+ "ThinkGreenService","ThinkGreenService"
47
+ "FlexDeliveryService","FlexDeliveryService"
48
+ "E-Mail-NotificationService","InfoService"
49
+ "PrivateDeliveryService","PrivateDeliveryService"
50
+ "ShopDeliveryService","ShopDeliveryService"
51
+ "Carrier title","Titel"
52
+ "Active","Aktiviert"
53
+ "Show gls_logo","GLS-Logo anzeigen"
54
+ "Name, "Name"
55
+ "Price per order","Preis pro Bestellung"
56
+ "gls_standard_delivery","Standardversand - Zustellung in 1-2 Werktagen (nach Versand)"
57
+ "gls_express_delivery","24h-Express - Garantierte Zustellung am nächsten Werktag (nach Versand) bis 17 Uhr"
58
+ "gls_think_green_delivery","Klimaneutraler Versand - ThinkGreen, dieser Versand erfolgt klimaneutral"
59
+ "gls_foreign_countries_delivery","Europaversand - Zustellzeit je nach Zielland"
60
+ "General","Allgemein"
61
+ "Show Method if Not Applicable","Versandart anzeigen, auch wenn nicht möglich"
62
+ "Displayed Error Message","Angezeigte Fehlermeldung"
63
+ "GLS CashService","GLS Nachnahme"
64
+ "Minimum Order Total","Mindestwert für Gesamtbestellung"
65
+ "Maximum Order Total","Höchstwert für Gesamtbestellung"
66
+ "Sort Order","Reihenfolge"
67
+ "Disallow certain delivery services","Bestimmte Versandarten verbieten"
68
+ "Disallowed delivery services","Versandart verbieten"
69
+ "Ship with GLS?","Mit GLS versenden?"
70
+ "Yes","Ja"
71
+ "No","Nein"
72
+ "product","Produkt"
73
+ "Sorry, this shipment cannot be sent using GLS.","Diese Sendung kann leider nicht mit GLS versandt werden."
74
+ "Either your shop origin or the ship to country of this order is not within the supported countries.","Der Shop-Versandursprung oder das Zielland der Sendung liegt nicht in den unterstützen Ländern."
75
+ "Advice","Hinweis"
76
+ "The maximum weight per parcel is %s kg","Das Maximalgewicht pro Paket beträgt %s kg"
77
+ "The maximum cash amount is %s %d","Der maximale Nachnahmebetrag ist %s %d"
78
+ "GLS Shipment","GLS-Lieferung"
79
+ "GLS Shipments","GLS-Lieferungen"
80
+ "GLS Shipments List","Liste der GLS-Lieferungen"
81
+ "Download PDF","PDF herunterladen"
82
+ "Find ParcelShop, "PaketShop auswählen"
83
+ "Please select a ParcelShop, "Bitte wählen Sie einen PaketShop aus und teilen Sie uns mit, wen wir nach Eingang des Pakets per SMS und E-Mail benachrichtigen dürfen."
84
+ "Ship to ParcelShop, "An PaketShop liefern"
85
+ "ParcelShop name, "PaketShop-Name"
86
+ "GLS shipment list","Liste der GLS-Sendungen"
87
+ "GLS shipment ID","GLS-Sendungs-ID"
88
+ "GLS consignment ID","GLS-Sendungsnummer"
89
+ "The GLS %s has errors or is not complete","Die GLS %s ist fehlerhaft oder ist nicht komplett"
90
+ "Magento shipment is missing","Die Magento-Lieferung ist nicht vorhanden"
91
+ "Create Return Label?","Retourenlabel erzeugen?"
92
+ "Shipping date","Versanddatum"
93
+ "Select the date the parcel will be shipped","Wählen Sie das Datum des Versandtages aus"
94
+ "Select shipping date, "Versanddatum Auswahl"
95
+ "Cash amount (in %s)","Nachnahmebetrag (in %s)"
96
+ "Weight (in kg)","Gewicht (in kg)"
97
+ "Parcel #","Paket #"
98
+ "Parcel number","Paketnummer"
99
+ "GLS shipment","GLS-Lieferung"
100
+ "Services","Services"
101
+ "Shipping date","Versanddatum"
102
+ "Status","Status"
103
+ "Printed","Gedruckt"
104
+ "Not printed","Nicht gedruckt"
105
+ "GLS Label is already printed","GLS-Label wurde bereits gedruckt"
106
+ "GLS shipment can not be edited","GLS-Lieferung kann nicht bearbeitet werden"
107
+ "GLS shipment can not be saved","GLS-Lieferung kann nicht gespeichert werden"
108
+ "GLS shipment could not be created","GLS-Lieferung kann nicht erstellt werden"
109
+ "Edit GLS shipment","GLS-Lieferung bearbeiten"
110
+ "GLS shipment data","GLS-Lieferungsdaten"
111
+ "GLS shipment could not be saved","GLS-Lieferung konnte nicht gespeichert werden"
112
+ "GLS shipment successfully saved","GLS-Lieferung erfolgreich gespeichert"
113
+ "GLS shipment successfully deleted","GLS-Lieferung erfolgreich gelöscht"
114
+ "Please note the maximum weight, "Bitte beachten Sie das Maximalgewicht"
115
+ "Please note the maximum cash amount","Bitte beachten Sie den maximalen Nachnahmebetrag"
116
+ "Print GLS label","GLS-Label drucken"
117
+ "Field can not be empty, "Geben Sie bitte einen Wert an"
118
+ "The shipping date must not be in the past, "Das Versanddatum darf nicht in der Vergangenheit liegen"
119
+ "At least one parcel has an invalid weight, "Mindestens ein Paket hat ein ungültiges Gewicht"
120
+ "At least one parcel has an invalid cash on delivery amount, "Mindestens ein Paket hat einen ungültigen Nachnahmebetrag"
121
+ "At least one additional service is not allowed for the current product, "Mindestens ein gebuchter Zusatzservice ist für das aktuelle Produkt nicht erlaubt"
122
+ "The selected product is not allowed for shipments to target country, "Das ausgewählte Produkt ist für das Zielland des Versands nicht erlaubt"
123
+ "Cash on delivery isn't allowed for the selected product, "Zahlung per Nachnahme ist für das ausgewählte Produkt nicht erlaubt"
124
+ "Request has error, "Fehlerhafter Request"
125
+ "(Error-Code: %s)","(Fehlercode: %s)"
126
+ "(Exception: %s)","(Exception: %s)"
127
+ "Not set or empty","Nicht gesetzt oder leer"
128
+ "Value not allowed: ", "Wert nicht erlaubt: "
129
+ "NoGLS consignment ID available or empty in GLS-API shipment response","GLS Sendungs-ID in GLS-API shipment response nicht verfügbar oder leer"
130
+ "GLS-API Connector has caused an error: %s","GLS-API Connector hat einen Fehler verursacht: %s"
131
+ "The shipment ID is not set or found","Die Sendungs-ID ist nicht gesetzt oder bekannt"
132
+ "The label has already been printed","Das Label wurde bereits gedruckt"
133
+ "or","oder"
134
+ "The selected ParcelShop is not available for your country","Der gewählte PaketShop ist für Ihr Land nicht verfügbar"
135
+ "Version","Version"
136
+ "Return address data","Rücksendeadresse"
137
+ "This address is mandatory for return labels","Diese Adresse muss für Retourenlabels gesetzt sein."
138
+ "Available for specific countries only","Nur für ausgewählte Länder verfügbar"
139
+ "Support","Support"
140
+ "If you need assistance setting up the GLS credentials and GLS services","Wenn Sie Hilfe bei der Einrichtung der GLS-Zugangsdaten und GLS-Servicedienstleistungen benötigen"
141
+ "feel free to <b>contact</b> us.","nehmen Sie bitte mit uns <b>Kontakt</b> auf."
142
+ "To manage your GLS assignments, your account data etc. and for informations regarding your customer account, please use","Um Ihre GLS-Aufträge, Stammdaten etc. zu verwalten und Informationen zu Ihrem Kundenkonto abzurufen, nutzen Sie bitte"
143
+ "your <b>YourGLS</b> account.","Ihren <b>YourGLS</b> Account"
144
+ "No GLS ConsignmentId available or empty in GLS-API shipment response","Keine GLS ConsignmentID verfügbar oder leerer Response im GLS-Shipment"
145
+ "The label data with GLS-ConsignmentId %s obtained are not correct","Die Label-Daten zur GLS-ConsignmentId %s sind nicht korrekt"
146
+ "At least one parcel has a invalid weight","Mindestens ein Packstück enthält ein ungültiges Gewicht"
147
+ "At least one parcel has a invalid cash on delivery amount",Mindestens ein Packstück enthält ein einen ungültigen Nachnahme-Betrag"
148
+ "The shipping date may not be in the past","Das versanddatum darf nicht in der Vergangenheit liegen"
149
+ "The selected product is not allowed for shipments target country","Das gewählte Produkt ist für das Zielland nicht gültig"
150
+ "A6","A6"
151
+ "A5","A5"
152
+ "A4","A4"
153
+ "GLS shipping","GLS Versand"
154
+ "Date to ship the parcel","Versanddatum"
155
+ "Select Shipment Date","Versanddatum wählen"
156
+ "Shipping option","Versandoption"
157
+ "Packages","Packstücke"
158
+ "The maximum allowed package weight is %s kg","Das maximal zulässige Gewicht beträgt %s kg"
159
+ "The maximum allowed cash amount is %s %d","Der maximal zulässige Nachnahme-Betrag beträgt %s %d"
160
+ "Sorry, this shipment can not be sent using GLS.","Leider kann diese Sendung nicht mit GLS verschickt werden"
161
+ "Sandbox","Sandbox"
162
+ "Return Label","Retouren-Label"
163
+ "PDF","PDF"
164
+ "Parcelshop ID","PaketShop ID"
165
+ "Find parcel shop","PaketShop finden"
166
+ "Please select a parcel shop","Bitte wählen Sie einen PaketShop"
167
+ "GLS","GLS"
168
+ "Please ensure that the Magento-Log is activated. It will be logged into Magento's system.log","Bitte stellen Sie sicher, dass das Magento Log ebenfalls aktiviert ist. Die Logeinträge werden in Magento's system.log geschrieben."
169
+ "In debug mode all relevant processes are logged. Attention, the log file can become very large in debug mode! It will be logged into SynergeticAgency_Gls.log and/or SynergeticAgency_GlsApi.log","Im Debug-Modus werden alle relevanten Prozesse geloggt. Die Logdatei kann dadurch sehr groß werden. Die Logeinträge werden in SynergeticAgency_Gls.log und/oder SynergeticAgency_GlsApi.log geschrieben."
170
+ "Connector Logging","Webservice logging"
171
+ "When enabled, additional Connector debug information will be written into a Connector Logfile (SynergeticAgency_GlsApi.log). Attention, the log file can become very large!","Wenn aktiviert werdeb zusätzliche Debug-Logeinträge in eine Webservice-Logdatei (SynergeticAgency_GlsApi.log) geschrieben. Die Logdatei kann dadurch sehr groß werden."
172
+ "This URL should not be changed by default.","Diese URL sollte standardmäßig nicht geändert werden."
173
+ "The GLS-API HTTP-Authentication-Username","Der GLS-API HTTP-Authentifizierungs-Benutzername"
174
+ "The GLS-API HTTP-Authentication-Password","Das GLS-API HTTP-Authentifizierungs-Passwort"
175
+ "For international shipment EuroBusinessParcel is chosen by default. Default product is only selected when the possibility is given.",Für internationalen Versand wird EuroBusinessParcel standardmässig ausgewählt. Standard-Produkt wird nur gewählt wenn die Möglichkeit gegeben ist."
176
+ "Service gets only selected when combination is available.","Service wird nur gewählt, wenn die Kombination möglich ist."
177
+ "Label Size","Label-Größe"
178
+ "Please note that not all label sizes are supported in some circumstances. Default is 'A6'. For details see manual.","Bitte beachten Sie dass unter bestimmten Umständen nicht alle Label-Größen verfügbar sind. Standard ist 'A6'. Details können Sie im Handbuch nachlesen."
179
+ "Ship to Specific Countries","Sende nur an bestimmte Länder"
180
+ "GLS - Cash on delivery","GLS - Nachnahme"
181
+ "Title","Titel"
182
+ "New Order Status","Neuer Bestellstatus"
183
+ "Instructions","Anleitung"
js/gls/admin.js ADDED
File without changes
js/gls/frontend.js ADDED
@@ -0,0 +1,671 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var GlsParcelShop = Class.create();
2
+ GlsParcelShop.prototype = {
3
+ initialize: function (options) {
4
+
5
+ var parcelShop = this;
6
+
7
+ parcelShop.options = Object.extend({
8
+ config:'',
9
+ countryConfig:'',
10
+ origin: window.location.href,
11
+ searchButton:$('shipping:findGlsParcelShop'),
12
+ addressSelect:$('shipping-address-select'),
13
+ shippingFormButton:$('shipping-buttons-container').select('button')[0],
14
+ shippingFormFields:$('shipping-new-address-form'),
15
+ billingSwitch:$('billing:use_for_parcelshop'),
16
+ shippingSwitch:$('shipping:parcelshop_active'),
17
+ sameAsBillingSwitch:$('shipping:same_as_billing'),
18
+ shopInfoContainerId:'gls-parcel-shop-information',
19
+ notSelectedLabel: 'Please select a parcel shop',
20
+ invalidShopLabel: 'The selected shop is not allowed for your country',
21
+ billingInfoUrl:'',
22
+ parcelShopFinderUrl:'',
23
+ address : {
24
+ name:{field:$('shipping:parcelshop_name'),hidden:true},
25
+ id:{field:$('shipping:parcelshop_id'),hidden:true},
26
+ street:{field:$('shipping:street1')},
27
+ street2:{field:$('shipping:street2')},
28
+ zip:{field:$('shipping:postcode')},
29
+ city:{field:$('shipping:city')},
30
+ region: {field:$('shipping:region')},
31
+ regionid: {field:$('shipping:region_id')},
32
+ country: {field:$('shipping:country_id')}
33
+ },
34
+ isActive: false,
35
+ triggerElm:'',
36
+ popup: {
37
+ height:'800',
38
+ width:'1000',
39
+ resizable:'1'
40
+ },
41
+ //document callbacks for community developers!!!
42
+ onInitBefore: function(){
43
+ //manipulate foreign DOM elements
44
+ parcelShop.onInitDefault();
45
+ },
46
+ onInitAfter: function(){
47
+ },
48
+ onActiveBefore: function(){
49
+ //manipulate foreign DOM elements
50
+ parcelShop.onActiveBeforeDefault();
51
+ },
52
+ onActiveAfter: function(){
53
+ },
54
+ onInactiveBefore: function(){
55
+ //manipulate foreign DOM elements
56
+ parcelShop.onInactiveBeforeDefault();
57
+ },
58
+ onInactiveAfter: function(){
59
+ },
60
+ setParcelShopAddressAfter: function(){
61
+ //manipulate DOM elements
62
+ parcelShop.showParcelShopAddress();
63
+ },
64
+ mapParcelShopData:function(){
65
+ parcelShop.mapParcelShopDataDefault();
66
+ },
67
+ mapFormFields:function(){
68
+ parcelShop.setDefaultFormFieldValues();
69
+ }
70
+ },options);
71
+
72
+ parcelShop.isActive = parcelShop.options.isActive;
73
+ parcelShop.data = [];
74
+ parcelShop.history = ['addressSelect', 'billingSwitch', 'sameAsBillingSwitch', 'shippingFormButton'];
75
+
76
+ //assigning initial settings of control switches to history
77
+ if (parcelShop.options.addressSelect) {
78
+ parcelShop.history.addressSelect = parcelShop.options.addressSelect.getValue();
79
+ }
80
+ if (parcelShop.options.billingSwitch) {
81
+ parcelShop.history.billingSwitch = parcelShop.getRadioValue('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"]');
82
+ }
83
+ if (parcelShop.options.sameAsBillingSwitch) {
84
+ parcelShop.history.sameAsBillingSwitch = parcelShop.options.sameAsBillingSwitch.checked;
85
+ }
86
+
87
+ /** call onInitBefore callback **/
88
+ parcelShop.options.onInitBefore();
89
+
90
+ /** get country config into object **/
91
+ parcelShop.config = parcelShop.strToJson(parcelShop.options.config);
92
+
93
+ /** get foreign country dependency config **/
94
+ parcelShop.countryConfig = parcelShop.strToJson(parcelShop.options.countryConfig);
95
+
96
+ /** assign parcel shop relevant input field to mapping object **/
97
+ parcelShop.options.mapFormFields();
98
+
99
+ /** set status active if isActive option is true **/
100
+ if(parcelShop.isActive == true) {
101
+ parcelShop.setStatus();
102
+ }
103
+ else{
104
+ $(parcelShop.options.searchButton).hide();
105
+ }
106
+
107
+ /** observe control elements **/
108
+
109
+ /** observe billing "ship to parcel shop" radio button **/
110
+ if (parcelShop.options.billingSwitch) {
111
+ parcelShop.options.billingSwitch.observe('focus', function () {
112
+ parcelShop.history.billingSwitch = parcelShop.getRadioValue('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"]');
113
+ }.bind(this));
114
+ $$('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"]').invoke('on','change',function(){
115
+ parcelShop.triggerElm = parcelShop.options.billingSwitch;
116
+ parcelShop.setStatus();
117
+ }
118
+ );
119
+ }
120
+
121
+ /** observe shipping form "ship to parcel shop" checkbox **/
122
+ parcelShop.options.shippingSwitch.observe('change', function () {
123
+ parcelShop.triggerElm = parcelShop.options.shippingSwitch;
124
+ parcelShop.setStatus();
125
+ }.bind(this));
126
+
127
+ /** observe click event on element opening the parcel shop map **/
128
+ if (parcelShop.options.searchButton) {
129
+ parcelShop.options.searchButton.observe('click', function () {
130
+ new Ajax.Request(parcelShop.options.billingInfoUrl, {
131
+ method : 'get',
132
+ onSuccess: function(response) {
133
+ var mapParams = parcelShop.strToJson(response.responseText);
134
+ var countryCode = mapParams.country_id;
135
+ var zip = mapParams.postcode;
136
+ parcelShop.openProxy(countryCode,zip);
137
+ },
138
+ onFailure: function() { parcelShop.openProxy(); }
139
+ });
140
+ }.bind(this));
141
+ }
142
+
143
+ /** observe "same as billing" checkbox in shipping address form **/
144
+ if(parcelShop.options.sameAsBillingSwitch) {
145
+ parcelShop.options.sameAsBillingSwitch.observe('change', function () {
146
+ parcelShop.options.shippingSwitch.checked = false;
147
+ parcelShop.triggerElm = parcelShop.options.sameAsBillingSwitch;
148
+ parcelShop.history.sameAsBillingSwitch = parcelShop.options.sameAsBillingSwitch.checked;
149
+ parcelShop.setStatus();
150
+ }.bind(this));
151
+ }
152
+
153
+ /** call onInitAfter callback **/
154
+ parcelShop.options.onInitAfter();
155
+ },
156
+
157
+ /**
158
+ * figure out if parcel shop is active or not and take the according actions
159
+ * @return void
160
+ */
161
+ setStatus: function() {
162
+ var parcelShop = this;
163
+
164
+ if (parcelShop.options.shippingSwitch && parcelShop.options.billingSwitch) {
165
+ if ((parcelShop.options.shippingSwitch.checked == true || parcelShop.options.billingSwitch.checked == true) && parcelShop.isActive == false) {
166
+ parcelShop.setStatusActive();
167
+ }
168
+ if ((parcelShop.options.shippingSwitch.checked == false || parcelShop.options.billingSwitch.checked == false) && parcelShop.isActive == true) {
169
+ parcelShop.setStatusInactive();
170
+ }
171
+ }
172
+ },
173
+
174
+ /**
175
+ * do all initial operations if parcel shop form is set to active
176
+ * @return void
177
+ */
178
+ setStatusActive: function () {
179
+ var parcelShop = this;
180
+
181
+ parcelShop.isActive = true;
182
+ parcelShop.options.onActiveBefore();
183
+ parcelShop.setControlElementsStatus();
184
+ parcelShop.setAddressFieldStatus();
185
+ parcelShop.options.onActiveAfter();
186
+ },
187
+
188
+ /**
189
+ * do all initial operations if parcel shop form is set to inactive
190
+ * @return void
191
+ */
192
+ setStatusInactive: function () {
193
+ var parcelShop = this;
194
+
195
+ parcelShop.isActive = false;
196
+ parcelShop.options.onInactiveBefore();
197
+ parcelShop.setControlElementsStatus();
198
+ if(parcelShop.triggerElm == parcelShop.options.sameAsBillingSwitch){
199
+ parcelShop.showAddressFields();
200
+ }else {
201
+ parcelShop.setAddressFieldStatus();
202
+ }
203
+
204
+ parcelShop.options.onInactiveAfter();
205
+ },
206
+
207
+ /**
208
+ * set all checkout controls to correct state in dependency if parcel shop is active or not
209
+ * @return void
210
+ */
211
+ setControlElementsStatus: function () {
212
+ var parcelShop = this;
213
+
214
+ if(parcelShop.isActive == true) {
215
+
216
+ if(!parcelShop.options.address.id.value){
217
+
218
+ parcelShop.history.shippingFormButton = parcelShop.options.shippingFormButton.readAttribute('onclick');
219
+ parcelShop.options.shippingFormButton.removeAttribute('onclick');
220
+ }
221
+
222
+ if(parcelShop.options.sameAsBillingSwitch) {
223
+ parcelShop.options.sameAsBillingSwitch.checked = false;
224
+ }
225
+
226
+ if(parcelShop.getRadioValue('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"]') != parcelShop.options.billingSwitch.getValue()) {
227
+ parcelShop.history.billingSwitch = parcelShop.getRadioValue('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"]');
228
+ }
229
+
230
+ /** activate elements which can toggle active state **/
231
+ parcelShop.options.shippingSwitch.checked = true;
232
+ parcelShop.options.billingSwitch.checked = true;
233
+
234
+ /** show button to open the parcel shop finder pop up **/
235
+ parcelShop.options.searchButton.show();
236
+
237
+ /** manage the shipping address select field **/
238
+ //remember old value
239
+ if(parcelShop.options.addressSelect) {
240
+ parcelShop.history.addressSelect = parcelShop.options.addressSelect.getValue();
241
+ //empty value which should be "new address"
242
+ parcelShop.options.addressSelect.setValue('');
243
+ // set field to readonly
244
+ parcelShop.options.addressSelect.disabled = true;
245
+ parcelShop.options.addressSelect.addClassName('readonly');
246
+ //trigger magento default change actions
247
+ parcelShop.dispatchChangeEvent($(parcelShop.options.addressSelect));
248
+ }
249
+ //show the form - just for IE - should happen on change of addressSelect
250
+ parcelShop.options.shippingFormFields.show();
251
+ }
252
+ else {
253
+ if(parcelShop.history.shippingFormButton){
254
+ parcelShop.options.shippingFormButton.setAttribute('onclick',parcelShop.history.shippingFormButton);
255
+ }
256
+ /** unselect elements which can toggle active state **/
257
+ if(parcelShop.options.shippingSwitch) {
258
+ parcelShop.options.shippingSwitch.checked = false;
259
+ }
260
+ if(parcelShop.triggerElm != parcelShop.options.billingSwitch && $$('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"][value="' + parcelShop.history.billingSwitch + '"]').length) {
261
+ $$('*[name="' + parcelShop.options.billingSwitch.readAttribute('name') + '"][value="' + parcelShop.history.billingSwitch + '"]')[0].checked = true;
262
+ }
263
+ /** hide button to open the parcel shop finder pop up **/
264
+ if(parcelShop.options.searchButton) {
265
+ parcelShop.options.searchButton.hide();
266
+ }
267
+
268
+ /** set the sameAsBillingSwitch to same value it had before parcel shop was activated **/
269
+ if(parcelShop.options.sameAsBillingSwitch) {
270
+ if(parcelShop.triggerElm != parcelShop.options.sameAsBillingSwitch) {
271
+ parcelShop.options.sameAsBillingSwitch.checked = parcelShop.history.sameAsBillingSwitch;
272
+ }
273
+ }
274
+
275
+ /** manage the shipping address select field **/
276
+ if(parcelShop.options.addressSelect) {
277
+
278
+ // set field to !readonly
279
+ parcelShop.options.addressSelect.disabled = false;
280
+ parcelShop.options.addressSelect.removeClassName('readonly');
281
+ if (parcelShop.triggerElm != parcelShop.options.sameAsBillingSwitch) {
282
+ //set value to value before activation
283
+ parcelShop.options.addressSelect.setValue(parcelShop.history.addressSelect);
284
+ //trigger magento default change actions but not if same as billing is set
285
+ if (parcelShop.triggerElm != parcelShop.options.sameAsBillingSwitch) {
286
+ parcelShop.dispatchChangeEvent(parcelShop.options.addressSelect);
287
+ }
288
+ }
289
+ }
290
+ }
291
+ },
292
+
293
+ /**
294
+ * open parcel shop map pop up and listen to message event to take data from popup
295
+ * the parcel shop map is embedded with an iframe due to IE compatibility issues
296
+ * @return void
297
+ */
298
+ openProxy: function(countryCode,zip) {
299
+ var parcelShop = this;
300
+
301
+ if(typeof countryCode == 'undefined'){
302
+ if (parcelShop.options.address.country.field.value) {
303
+ countryCode = parcelShop.options.address.country.field.value;
304
+ }
305
+ else {
306
+ countryCode = parcelShop.config.id;
307
+ }
308
+ }
309
+
310
+ if(parcelShop.options.address.zip.field.value && typeof zip == 'undefined'){
311
+ zip = parcelShop.options.address.zip.field.value;
312
+ }
313
+
314
+ if(countryCode != '' && typeof countryCode != 'undefined'){
315
+ countryCode = '&countryCode=' + countryCode;
316
+ }
317
+ if(zip != '' && typeof zip != 'undefined'){
318
+ zip = '&zip=' + zip;
319
+ }
320
+
321
+ //open parcel shop finder map
322
+ var url = parcelShop.options.parcelShopFinderUrl + '?origin=' + parcelShop.options.origin + countryCode + zip;
323
+
324
+ window.open(url, 'glsParcelShopProxy', 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=' + parcelShop.options.popup.resizable +', width=' + parcelShop.options.popup.width +', height=' + parcelShop.options.popup.height);
325
+ window.addEventListener('message', function(e) {
326
+ if(typeof e.data!="undefined" && e.data[0].eventType == 'shopSelected') {
327
+ parcelShop.data = parcelShop.toJson(e.data);
328
+ parcelShop.options.mapParcelShopData();
329
+
330
+ if(parcelShop.isParcelShopDeliveryAllowed(parcelShop.data[0].eventData.address.country)){
331
+ parcelShop.setParcelShopAddress();
332
+ if(parcelShop.history.shippingFormButton){
333
+ parcelShop.options.shippingFormButton.setAttribute('onclick',parcelShop.history.shippingFormButton);
334
+ }
335
+ parcelShop.options.setParcelShopAddressAfter();
336
+ }
337
+ else{
338
+ parcelShop.options.shippingFormButton.removeAttribute('onclick');
339
+ parcelShop.options.shippingFormFields.insert(
340
+ {'top': $(parcelShop.options.shopInfoContainerId).update('<dt class="error">' + parcelShop.options.invalidShopLabel + '</dt>')}
341
+ );
342
+ $(parcelShop.options.shopInfoContainerId).update('<dt class="error">' + parcelShop.options.invalidShopLabel + '</dt>');
343
+ }
344
+ }
345
+ }, false);
346
+ },
347
+
348
+ /**
349
+ * check if parcel shop delivery is allowed for a country
350
+ * @param currentParcelShopCountry
351
+ * @returns {boolean}
352
+ */
353
+ isParcelShopDeliveryAllowed: function(currentParcelShopCountry) {
354
+ var parcelShop = this;
355
+ var allowedParcelShopCountries = [];
356
+ var isAllowed = false;
357
+
358
+ if(parcelShop.countryConfig.domestic.parcelshop == true){
359
+ allowedParcelShopCountries.push(parcelShop.config.id);
360
+ }
361
+
362
+ for (var key in parcelShop.countryConfig.foreign.countries) {
363
+ if(parcelShop.countryConfig.foreign.countries[key].parcelshop == true){
364
+ allowedParcelShopCountries.push(key);
365
+ }
366
+ }
367
+
368
+ if(allowedParcelShopCountries.indexOf(currentParcelShopCountry) != -1){
369
+ isAllowed = true;
370
+ }
371
+
372
+ return isAllowed;
373
+ },
374
+
375
+ /**
376
+ * some operations on foreign DOM elements called in the onInit callback
377
+ * @return Void
378
+ */
379
+ onInitDefault: function() {
380
+ var parcelShop = this;
381
+
382
+ /** prepend parcelshop information to shipping form **/
383
+ parcelShop.options.shippingFormFields.insert(
384
+ {'top': new Element('dl', { 'id': parcelShop.options.shopInfoContainerId}).update('<dt class="error">' + parcelShop.options.notSelectedLabel + '</dt>')}
385
+ );
386
+
387
+ /** just show information if parcel shop active, hide on init **/
388
+ $('gls-parcel-shop-information').hide();
389
+
390
+ /** move billingSwitch to nicer position **/
391
+ if($$('#co-billing-form > .fieldset > .form-list').length && parcelShop.options.billingSwitch) {
392
+ $$('#co-billing-form > .fieldset > .form-list')[0].appendChild(parcelShop.options.billingSwitch.up());
393
+ }
394
+
395
+ /** move parcel shop fields to nicer position **/
396
+ if(parcelShop.options.shippingFormFields && $('parcelshop_fields') && $('co-shipping-form')) {
397
+ $('parcelshop_fields').childElements().each(function(elm){
398
+ $('co-shipping-form').appendChild(elm);
399
+ });
400
+ }
401
+
402
+ /** move shippingSwitch to nice position **/
403
+ if(parcelShop.options.shippingFormFields && parcelShop.options.shippingSwitch) {
404
+ parcelShop.options.shippingFormFields.insert(
405
+ {'before': parcelShop.options.shippingSwitch.up()}
406
+ );
407
+ }
408
+ },
409
+ /**
410
+ * some operations on foreign DOM elements called in the onActiveBefore callback
411
+ * @return Void
412
+ */
413
+ onActiveBeforeDefault: function() {
414
+
415
+ $('shipping:street1').disabled == true;
416
+ $('shipping:street1').removeClassName('required-entry');
417
+
418
+ if($('shipping:save_in_address_book')) {
419
+ $('shipping:save_in_address_book').up().hide();
420
+ }
421
+ if($('gls-parcel-shop-information')) {
422
+ $('gls-parcel-shop-information').show();
423
+ }
424
+ },
425
+
426
+ /**
427
+ * some operations on foreign DOM elements called in the onInactiveBeforeDefault callback
428
+ * @return Void
429
+ */
430
+ onInactiveBeforeDefault: function() {
431
+ $('shipping:street1').disabled == false;
432
+
433
+ if($('shipping:save_in_address_book')) {
434
+ $('shipping:save_in_address_book').up().show();
435
+ }
436
+ $('gls-parcel-shop-information').hide();
437
+ },
438
+
439
+ /**
440
+ * parse json...
441
+ * @return {Object}
442
+ */
443
+ toJson: function(obj) {
444
+ return JSON.parse(JSON.stringify(obj, null, 2));
445
+ },
446
+
447
+ /**
448
+ * parse json...
449
+ * @return {Object}
450
+ */
451
+ strToJson: function(obj) {
452
+ return JSON.parse(obj);
453
+ },
454
+
455
+ /**
456
+ * set status of relevant fields in dependency if parcel form is active or not
457
+ * @param {String} status
458
+ * @return void
459
+ */
460
+ setAddressFieldStatus: function () {
461
+ var parcelShop = this;
462
+
463
+ for (var key in parcelShop.options.address) {
464
+ if (parcelShop.options.address.hasOwnProperty(key)) {
465
+ if(parcelShop.options.address[key].field) {
466
+ if(parcelShop.isActive == true) {
467
+
468
+ parcelShop.options.address[key].newAddressFormValue = parcelShop.options.address[key].field.getValue();
469
+ parcelShop.options.address[key].field.setValue(parcelShop.options.address[key].parcelShopFormValue);
470
+ parcelShop.options.address[key].field.readOnly = true;
471
+ if(!parcelShop.options.address[key].hidden) {
472
+ parcelShop.options.address[key].field.up().up().hide();
473
+ }
474
+ parcelShop.options.address[key].field.addClassName('readonly');
475
+ parcelShop.dispatchChangeEvent(parcelShop.options.address[key].field);
476
+ }
477
+ else {
478
+ parcelShop.options.address[key].parcelShopFormValue = parcelShop.options.address[key].field.getValue();
479
+ parcelShop.options.address[key].field.value = parcelShop.options.address[key].newAddressFormValue;
480
+ parcelShop.options.address[key].field.readOnly = false;
481
+ if(!parcelShop.options.address[key].hidden) {
482
+ parcelShop.options.address[key].field.up().up().show();
483
+ }
484
+ parcelShop.options.address[key].field.removeClassName('readonly');
485
+ parcelShop.dispatchChangeEvent(parcelShop.options.address[key].field);
486
+ }
487
+ }
488
+ }
489
+ }
490
+ },
491
+ /**
492
+ * just show the field hidden by parcel search again - let magento do everything else
493
+ * @param {String} status
494
+ * @return void
495
+ */
496
+ showAddressFields: function () {
497
+ var parcelShop = this;
498
+ for (var key in parcelShop.options.address) {
499
+ if (parcelShop.options.address.hasOwnProperty(key)) {
500
+ if(parcelShop.options.address[key].field) {
501
+ parcelShop.options.address[key].parcelShopFormValue = parcelShop.options.address[key].field.getValue();
502
+ parcelShop.options.address[key].field.readOnly = false;
503
+ if(!parcelShop.options.address[key].hidden) {
504
+ parcelShop.options.address[key].field.up().up().show();
505
+ }
506
+ parcelShop.options.address[key].field.removeClassName('readonly');
507
+ }
508
+ }
509
+ }
510
+ },
511
+
512
+ /**
513
+ * show parcel shop address in a box
514
+ * @return void
515
+ */
516
+ showParcelShopAddress: function() {
517
+ var parcelShop = this;
518
+
519
+ $('gls-parcel-shop-information').childElements().each(function(el){
520
+ $(el).remove();
521
+ });
522
+
523
+ parcelShop.options.shippingFormFields.appendChild($(parcelShop.options.shopInfoContainerId));
524
+ for (var key in parcelShop.options.address) {
525
+ if (parcelShop.options.address.hasOwnProperty(key)) {
526
+ if(parcelShop.options.address[key].field) {
527
+ switch(key) {
528
+ case 'id':
529
+ case 'region':
530
+ case 'regionid':
531
+ case 'street2':
532
+ break;
533
+ case 'country':
534
+ $('gls-parcel-shop-information').appendChild(new Element('dt', { 'class': 'gls-label '+ key}).update(parcelShop.getLabel(parcelShop.options.address[key].field.up().previous()) + ':'));
535
+ $('gls-parcel-shop-information').appendChild(new Element('dd', { 'class': 'gls-value '+ key}).update(parcelShop.options.address[key].field[parcelShop.options.address[key].field.selectedIndex].text));
536
+ break;
537
+ default:
538
+ $('gls-parcel-shop-information').appendChild(new Element('dt', { 'class': 'gls-label '+ key}).update(parcelShop.getLabel(parcelShop.options.address[key].field.up().previous()) + ':'));
539
+ $('gls-parcel-shop-information').appendChild(new Element('dd', { 'class': 'gls-value '+ key}).update(parcelShop.options.address[key].field.value));
540
+ }
541
+ }
542
+ }
543
+ }
544
+ },
545
+
546
+ /**
547
+ * set value of relevant address fields to address values taken from parcel shop finder
548
+ * @return void
549
+ */
550
+ setParcelShopAddress: function() {
551
+ var parcelShop = this;
552
+ for (var key in parcelShop.options.address) {
553
+ if (parcelShop.options.address.hasOwnProperty(key)) {
554
+ if(parcelShop.options.address[key].field) {
555
+ switch(key) {
556
+ default:
557
+ parcelShop.options.address[key].field.value = parcelShop.options.address[key].value;
558
+ parcelShop.dispatchChangeEvent(parcelShop.options.address[key].field);
559
+ }
560
+ }
561
+ }
562
+ }
563
+ },
564
+
565
+ /**
566
+ * map data from parcel shop map pop up to mapping object
567
+ * can't be done dynamic as there there can be exceptions -> street
568
+ * also names don't match...
569
+ * values are used in setParcelShopAddress()
570
+ * @return void
571
+ */
572
+ mapParcelShopDataDefault: function() {
573
+ var parcelShop = this;
574
+ parcelShop.data.map(function(item) {
575
+ //shop name
576
+ parcelShop.options.address.name.value = item.eventData.name;
577
+ //shop id
578
+ parcelShop.options.address.id.value = item.eventData.id;
579
+ //shop street
580
+ parcelShop.options.address.street.value = item.eventData.address.street + ' ' + item.eventData.address.streetNo;
581
+ //shop postal code
582
+ parcelShop.options.address.zip.value = item.eventData.address.zipCode;
583
+ //shop place
584
+ parcelShop.options.address.city.value = item.eventData.address.city;
585
+ //shop country
586
+ parcelShop.options.address.country.value = item.eventData.address.country;
587
+ });
588
+ },
589
+
590
+ /**
591
+ * setting the initial values of parcel shop address mapping object
592
+ * @return void
593
+ */
594
+ setDefaultFormFieldValues: function() {
595
+ var parcelShop = this;
596
+
597
+ for (var key in parcelShop.options.address) {
598
+ if (parcelShop.options.address.hasOwnProperty(key)) {
599
+ if(parcelShop.options.address[key].field) {
600
+ parcelShop.options.address[key].value = '';
601
+ parcelShop.options.address[key].newAddressFormValue = parcelShop.options.address[key].field.getValue();
602
+ parcelShop.options.address[key].parcelShopFormValue = '';
603
+ }
604
+ }
605
+ }
606
+ },
607
+
608
+ /**
609
+ * trigger change event. mostly needed to keep magento defaults js work
610
+ * @return Void
611
+ */
612
+ dispatchChangeEvent: function ($elm) {
613
+ var event = document.createEvent('HTMLEvents');
614
+ event.initEvent('change', true, false);
615
+ $elm.dispatchEvent(event);
616
+ },
617
+
618
+ /**
619
+ * get currently checked radio button of radio group
620
+ * @return String
621
+ */
622
+ getRadioValue: function ($elm) {
623
+ return $$($elm + ':checked').first().value;
624
+ },
625
+
626
+ /**
627
+ * ie8 compatible way to get just the label
628
+ * @return String
629
+ */
630
+ getLabel: function ($elm) {
631
+
632
+ if($elm.childElements().length > 0) {
633
+ $elm.firstDescendant().remove();
634
+ }
635
+ return $elm.innerHTML;
636
+ },
637
+
638
+
639
+ serializeForms: function () {
640
+ var parcelShop = this;
641
+
642
+ parcelShop.formsData = [];
643
+ parcelShop.options.forms.each(function(item) {
644
+ if($$(item)[0].tagName.toLowerCase() == 'form') {
645
+ parcelShop.formsData[item] = decodeURIComponent($$(item)[0].serialize());
646
+ Object.keys(parcelShop.formsData).each(function(formSelector) {
647
+ var params = parcelShop.formsData[formSelector].toQueryParams();
648
+ Object.keys(params).each(function(key) {
649
+
650
+ if(key != $(parcelShop.options.shippingSwitch).readAttribute('name') && key != $(parcelShop.options.billingSwitch).readAttribute('name')) {
651
+ Form.Element.setValue($$(formSelector + ' *[name="' + key + '"]')[0], params[key]);
652
+ }
653
+ });
654
+ });
655
+ }
656
+ });
657
+ },
658
+ restoreForms: function () {
659
+ var parcelShop = this;
660
+ Object.keys(parcelShop.formsData).each(function(formSelector) {
661
+ var params = parcelShop.formsData[formSelector].toQueryParams();
662
+ Object.keys(params).each(function(key) {
663
+
664
+ if(key != $(parcelShop.options.shippingSwitch).readAttribute('name') && key != $(parcelShop.options.billingSwitch).readAttribute('name')) {
665
+
666
+ Form.Element.setValue($$(formSelector + ' *[name="' + key + '"]')[0], params[key]);
667
+ }
668
+ });
669
+ });
670
+ }
671
+ }
lib/SynergeticAgency/GlsConnector/Connector.php ADDED
@@ -0,0 +1,1103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ # ToDo add license text here
3
+
4
+ /**
5
+ * Class to work with GLS API
6
+ *
7
+ * @category SynergetigAgency
8
+ * @package SynergeticAgency_GlsConnector_Connector
9
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
10
+ */
11
+ class SynergeticAgency_GlsConnector_Connector
12
+ {
13
+ const GLS_API_CONNECTOR_FUNC_SHIPPING = "shipments";
14
+ const GLS_API_CONNECTOR_FUNC_JSON = "shipments/configuration";
15
+
16
+ private $host;
17
+ private $schema;
18
+ private $port;
19
+ private $baseUri;
20
+ private $apiEnpointPath;
21
+ private $apiEnpointFunction;
22
+ private $glsApiUsername;
23
+ private $glsApiPassword;
24
+ private $glsApiAuthUsername;
25
+ private $glsApiAuthPassword;
26
+ private $glsApiUrl;
27
+ private $glsApiLang;
28
+ private $glsApiSandbox;
29
+
30
+ private $glsApiJsonUrl;
31
+
32
+ private $customerid;
33
+ private $contactid;
34
+
35
+ private $curl;
36
+ private $curlOpts = array();
37
+ private $curlAuthCookie = "";
38
+ private $curlResponse;
39
+ private $curlResponseHeaderSize;
40
+ private $curlResponseHeader;
41
+ private $curlResponseBody;
42
+ private $curlErrno;
43
+ private $curlConnectTimeoutMs = 10000;
44
+ private $curlTimeoutMs = 10000;
45
+ private $curlErrorRetry = 3;
46
+ private $curlErrorRetryCount = 0;
47
+ private $curlInfo;
48
+
49
+ private $currentFunction;
50
+ private $currentCall;
51
+
52
+ private $log;
53
+ private $error;
54
+
55
+ private $sleepSeconds = 0;
56
+ private $slept = 0;
57
+
58
+ private $shipment;
59
+
60
+ private $jsonConfig;
61
+
62
+ /**
63
+ *
64
+ */
65
+ function __construct(){
66
+ // init logger
67
+ $this->setLog();
68
+
69
+ $logMessage = 'entered';
70
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
71
+
72
+ $error = new SynergeticAgency_GlsConnector_Model_Error();
73
+ $this->setError( $error );
74
+
75
+ //use "GLS-API Sandbox" per default
76
+ $this->setGlsApiSandbox( true );
77
+ }
78
+
79
+ /**
80
+ * @return $this
81
+ */
82
+ public function initCurl() {
83
+ $logMessage = 'entered';
84
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
85
+
86
+ $this->curl = false;
87
+ $this->curlOpts = array();
88
+ $this->setCurl( curl_init() );
89
+ $this->setCurlOpts(
90
+ array(
91
+ CURLOPT_ENCODING => 'UTF-8',
92
+ CURLOPT_RETURNTRANSFER => true,
93
+ CURLOPT_CONNECTTIMEOUT_MS => $this->getCurlConnectTimeoutMs(),
94
+ CURLOPT_TIMEOUT_MS => $this->getCurlTimeoutMs(),
95
+ CURLINFO_HEADER_OUT => 1,
96
+ #CURLOPT_SSL_VERIFYHOST => false,
97
+ #CURLOPT_SSL_VERIFYPEER => false,
98
+
99
+ CURLOPT_HEADER => 1,
100
+ // the following basic auth will be used in the next generation of the GLS API(see also "PR178DED Web Shop eCom Plugins")
101
+ CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
102
+ CURLOPT_USERPWD => $this->getGlsApiAuthUsername() . ":" . $this->getGlsApiAuthPassword()
103
+ #CURLOPT_USERPWD => "webapi:webapi"
104
+ )
105
+ );
106
+
107
+ $this->getLog()->write( __METHOD__, __LINE__, "ATTENTION, in productive system, remove CURLOPT_SSL_VERIFYHOST and CURLOPT_SSL_VERIFYPEER from curl opt setting above", SynergeticAgency_GlsConnector_Log::ERR );
108
+
109
+ // if curl debug mode is set to true, you can debug the curl exec using
110
+ // var_export(curl_getinfo($this->curl))
111
+ #if( $this->getCurlDebugMode() === true ){
112
+ # $this->addCurlOpts(
113
+ # array(
114
+ # CURLINFO_HEADER_OUT => 1,
115
+ # )
116
+ # );
117
+ #}
118
+
119
+ #// Cookie relevant codes START
120
+ #// if curlAuthCookie is present, add curl option CURLOPT_HTTPHEADER with curlAuthCookie value
121
+ #if( $this->getCurlAuthCookie() !== "" ){
122
+ # $this->addCurlOpts(
123
+ # array(
124
+ # CURLOPT_HTTPHEADER => array( $this->getCurlAuthCookie() ),
125
+ # )
126
+ # );
127
+ #}
128
+ #// Cookie relevant codes STOP
129
+
130
+ return $this;
131
+ }
132
+
133
+
134
+
135
+ /**
136
+ * executes the request for $this->curl
137
+ */
138
+ private function curlExec(){
139
+ $logMessage = 'entered';
140
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
141
+
142
+ $this->setCurlResponse( curl_exec($this->getCurl()) );
143
+ $this->setCurlErrno( curl_errno($this->getCurl()) );
144
+
145
+ $this->setCurlResponseHeaderSize(curl_getinfo($this->getCurl(), CURLINFO_HEADER_SIZE) );
146
+ $this->setCurlResponseHeader( substr($this->getCurlResponse(), 0, $this->getCurlResponseHeaderSize()) );
147
+ $this->setCurlResponseBody( substr($this->getCurlResponse(), $this->getCurlResponseHeaderSize()) );
148
+ $this->setCurlInfo();
149
+
150
+ $logMessage = "curl_errno: " . $this->getCurlErrno();
151
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
152
+
153
+ // handle CURLE_OPERATION_TIMEOUTED or CURLE_COULDNT_RESOLVE_HOST errors
154
+ if( $this->getCurlErrorRetryCount() < $this->getCurlErrorRetry() &&
155
+ (
156
+ $this->getCurlErrno() === CURLE_OPERATION_TIMEOUTED ||
157
+ $this->getCurlErrno() === CURLE_COULDNT_RESOLVE_HOST
158
+ )
159
+ ){
160
+ $this->increaseCurlErrorRetryCount();
161
+ $function = $this->getCurrentFunction();
162
+
163
+ switch( $this->getCurlErrno() ){
164
+ case CURLE_OPERATION_TIMEOUTED:
165
+ $logMessage = 'CURLE_OPERATION_TIMEOUTED: Operation timeout (' . $this->getCurlTimeoutMs() / 1000 . "s) @ " . $function;
166
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::ALERT );
167
+ break;
168
+ case CURLE_COULDNT_RESOLVE_HOST:
169
+ $logMessage = 'CURLE_COULDNT_RESOLVE_HOST: Cannot resolve host (' . $this->getHost() . ") @ " . $function;
170
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::ALERT );
171
+ break;
172
+ }
173
+
174
+ $logMessage = 'retry no ' . $this->getCurlErrorRetryCount() . ' to execute function $this->' . $function . '} @ ' . $function;
175
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
176
+ $this->curlExec();
177
+ } else {
178
+ if($this->getCurlErrorRetryCount() === $this->getCurlErrorRetry()) {
179
+ $logMessage = 'retry curlExec failed for ' . $this->getCurlErrorRetryCount() . ' times';
180
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::EMERG );
181
+ throw new Exception( $logMessage );
182
+ }
183
+ $this->setCurlErrorRetryCount( 0 );
184
+ }
185
+
186
+ #// Cookie relevant codes START
187
+ #$this->checkCookieExpired();
188
+ #// Cookie relevant codes STOP
189
+ }
190
+
191
+
192
+ /**
193
+ * @throws Exception
194
+ */
195
+ public function createShipment(){
196
+
197
+ $logMessage = 'entered';
198
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
199
+
200
+ $this->setCurrentFunction( __FUNCTION__ );
201
+ $this->setCurrentCall( $this->getGlsApiUrl() . SynergeticAgency_GlsConnector_Connector::GLS_API_CONNECTOR_FUNC_SHIPPING );
202
+ // in the next generation of the GLS API(see also "PR178DED Web Shop eCom Plugins"), set constant GLS_API_CONNECTOR_FUNC_SHIPPING to "shipmenmts"
203
+
204
+ if( $this->getGlsApiSandbox() !== false ){
205
+ $logMessage = 'create shipment against GLS-API Sandbox(' . $this->getGlsApiUrl() . ')';
206
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::NOTICE );
207
+ $this->getShipment()->setSandbox( true );
208
+ } else {
209
+ $logMessage = 'create shipment against GLS-API productive system(' . $this->getGlsApiUrl() . ')';
210
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::NOTICE );
211
+ $this->getShipment()->setSandbox( false );
212
+ }
213
+
214
+ #echo "\n\nCURLOPT_POSTFIELDS: \n" . $this->getShipment()->toJson();
215
+ #exit();
216
+
217
+ $this->sleeper();
218
+ $this->initCurl();
219
+ $this->addCurlOpts(
220
+ array(
221
+ CURLOPT_URL => $this->getCurrentCall(),
222
+ CURLOPT_POST => true,
223
+ CURLOPT_POSTFIELDS => $this->getShipment()->toJson(),
224
+ CURLOPT_HEADER => 1,
225
+ CURLOPT_HTTPHEADER => array(
226
+ 'Content-Type: application/json',
227
+ 'Content-Length: ' . strlen( $this->getShipment()->toJson() )
228
+ ),
229
+ )
230
+ );
231
+
232
+ $this->getLog()->write( __METHOD__, __LINE__, $this->getShipment()->toJson(), SynergeticAgency_GlsConnector_Log::INFO );
233
+
234
+ curl_setopt_array( $this->getCurl(), $this->getCurlOpts() );
235
+ $this->curlExec();
236
+
237
+ // on Error, return something other than $this
238
+ if( $this->getCurlErrno() !== 0 ){
239
+ $logMessage = 'CURL ERROR NUMBER: ' . $this->getCurlErrno();
240
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::ERR );
241
+
242
+ $logMessage = '\$this->getCurlResponse(): ' . var_export( $this->getCurlResponse(), 1);
243
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
244
+
245
+ } else {
246
+ $responseArray = json_decode($this->getCurlResponseBody());
247
+
248
+ //handle HTTP-Statuscodes 2xx
249
+ $httpStausCodes2xx = array(200,201,202,203,204,205,206,207,208,226);
250
+ #if( $this->getCurlInfo( 'http_code' ) !== 200 ){
251
+ if( !in_array($this->getCurlInfo( 'http_code' ), $httpStausCodes2xx) ){
252
+ $this->getError()->setHasError( true );
253
+ if( isset($responseArray->{'errors'}) ){
254
+ if(is_array($responseArray->{'errors'})){
255
+ foreach($responseArray->{'errors'} AS $responseError ){
256
+ $errorMessage = "";
257
+ if( isset($responseError->{'exitMessage'}) ){
258
+ $errorMessage.= $responseError->{'exitMessage'} . " ";
259
+ }
260
+ if( isset($responseError->{'description'}) ){
261
+ $errorMessage.= $responseError->{'description'} . " ";
262
+ }
263
+ if( isset($responseError->{'exitCode'}) ){
264
+ $errorMessage.= "(ExitCode " . $responseError->{'exitCode'} . ", HTTP-Status: " . $this->getCurlInfo( 'http_code' ) . ")";
265
+ }
266
+
267
+ if( $errorMessage === "" ){
268
+ $errorMessage = get_class($this) . "An unknown error has occurred";
269
+ }
270
+ $this->getError()->setMessage( trim($errorMessage) );
271
+ }
272
+ }
273
+ }
274
+
275
+ #if( isset($responseArray->{'ModelState'}) ){
276
+ # $this->getError()->setModelState( $responseArray->{'ModelState'} );
277
+ #}
278
+
279
+ } else {
280
+
281
+
282
+ #echo "\n\n\n\$responseArray: " . var_export($responseArray->{'parcels'}, 1);
283
+ #exit();
284
+
285
+ if( $responseArray->{'consignmentId'} ){
286
+ $this->getShipment()->setconsignmentId( $responseArray->{'consignmentId'} );
287
+ }
288
+
289
+ if( is_array($responseArray->{'labels'}) ){
290
+ foreach( $responseArray->{'labels'} as $num => $label ){
291
+ if (base64_decode($label, true)) {
292
+ $this->getShipment()->pushLabel( $label );
293
+ }
294
+ }
295
+ }
296
+
297
+ #if (base64_decode($responseArray->{'PDF'}, true)) {
298
+ # $this->getShipment()->setPdf( $responseArray->{'PDF'} );
299
+ #}
300
+
301
+ if( is_array($responseArray->{'parcels'}) ){
302
+ foreach( $responseArray->{'parcels'} as $num => $parcel ){
303
+ #echo "\nWORK ON PARCEL NUM " . $num;
304
+ $this->getShipment()->getParcels()[$num]->setParcelNumber($parcel->parcelNumber );
305
+ $this->getShipment()->getParcels()[$num]->setTrackId($parcel->trackId );
306
+ $this->getShipment()->getParcels()[$num]->setLocation($parcel->location );
307
+
308
+ // routing is DEPRECATED
309
+ #$routing = array();
310
+ #foreach( $parcel->Routing as $key => $value){
311
+ # $routing[$key] = $parcel->Routing->{$key};
312
+ #}
313
+ #$this->getShipment()->getParcels()[$num]->setRouting( $routing );
314
+ }
315
+ }
316
+ $this->getError()->hasError( false );
317
+ #exit();
318
+ }
319
+ }
320
+ }
321
+
322
+ /**
323
+ *
324
+ */
325
+ public function loadJsonConfig(){
326
+ $logMessage = 'entered';
327
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
328
+ // in an further version of the GLS-API service, use cUrl to load the JSON-configuration
329
+ $json = file_get_contents( $this->getGlsApiJsonUrl() );
330
+ if( $this->isJson($json) ){
331
+ $this->setJsonConfig( $json );
332
+ }
333
+ }
334
+
335
+ /**
336
+ * @param $string
337
+ * @return bool
338
+ */
339
+ public function isJson($string) {
340
+ $logMessage = 'entered';
341
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
342
+ json_decode($string);
343
+ return (json_last_error() == JSON_ERROR_NONE);
344
+ }
345
+
346
+ /**
347
+ * performs a application sleep in order of configured seconds to sleep
348
+ * see also configuration
349
+ */
350
+ private function sleeper(){
351
+ $logMessage = 'entered';
352
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
353
+ if($this->slept == 0 ){
354
+ for( $i=0; $i<$this->getSleepSeconds(); $i++ ){
355
+ //echo "\n\n" . __METHOD__ . " @ line " . __LINE__ . ": " . "sleep: " . $i;
356
+ sleep(1);
357
+ }
358
+ #$this->slept = 1;
359
+ }
360
+ }
361
+
362
+
363
+ /**
364
+ * @return mixed
365
+ */
366
+ public function getHost() {
367
+ return $this->host;
368
+ }
369
+
370
+ /**
371
+ * @param $host
372
+ * @return $this
373
+ */
374
+ public function setHost($host) {
375
+ $this->host = $host;
376
+ return $this;
377
+ }
378
+
379
+ /**
380
+ * @return mixed
381
+ */
382
+ public function getSchema() {
383
+ return $this->schema;
384
+ }
385
+
386
+ /**
387
+ * @param $schema
388
+ * @return $this
389
+ */
390
+ public function setSchema($schema) {
391
+ $this->schema = $schema;
392
+ return $this;
393
+ }
394
+
395
+ /**
396
+ * @return mixed
397
+ */
398
+ public function getPort() {
399
+ return $this->port;
400
+ }
401
+
402
+ /**
403
+ * @param $port
404
+ * @return $this
405
+ */
406
+ public function setPort($port) {
407
+ $this->port = $port;
408
+ return $this;
409
+ }
410
+
411
+ /**
412
+ * @return mixed
413
+ */
414
+ public function getBaseUri() {
415
+ return $this->baseUri;
416
+ }
417
+
418
+ /**
419
+ * @param $baseUri
420
+ * @return $this
421
+ */
422
+ public function setBaseUri($baseUri) {
423
+ $this->baseUri = "/" . trim( $baseUri, "/" );
424
+ return $this;
425
+ }
426
+
427
+ /**
428
+ * @return mixed
429
+ */
430
+ public function getApiEnpointPath() {
431
+ return $this->apiEnpointPath;
432
+ }
433
+
434
+ /**
435
+ * @param $apiEnpointPath
436
+ * @return $this
437
+ */
438
+ public function setApiEnpointPath($apiEnpointPath) {
439
+ $this->apiEnpointPath = "/" . trim( $apiEnpointPath, "/" );
440
+ return $this;
441
+ }
442
+
443
+ /**
444
+ * @return mixed
445
+ */
446
+ public function getApiEnpointFunction() {
447
+ return $this->apiEnpointFunction;
448
+ }
449
+
450
+ /**
451
+ * @param $apiEnpointFunction
452
+ * @return $this
453
+ */
454
+ public function setApiEnpointFunction($apiEnpointFunction) {
455
+ $this->apiEnpointFunction = $apiEnpointFunction;
456
+ return $this;
457
+ }
458
+
459
+ /**
460
+ * @return mixed
461
+ */
462
+ public function DEPRECATED_getGlsApiUsername() {
463
+ return $this->glsApiUsername;
464
+ }
465
+
466
+ /**
467
+ * @param $glsApiUsername
468
+ * @return $this
469
+ */
470
+ public function DEPRECATED_setGlsApiUsername($glsApiUsername) {
471
+ $this->glsApiUsername = $glsApiUsername;
472
+ return $this;
473
+ }
474
+
475
+ /**
476
+ * @return mixed
477
+ */
478
+ public function DEPRECATED_getGlsApiPassword() {
479
+ return $this->glsApiPassword;
480
+ }
481
+
482
+ /**
483
+ * @param $glsApiPassword
484
+ * @return $this
485
+ */
486
+ public function DEPRECATED_setGlsApiPassword($glsApiPassword) {
487
+ $this->glsApiPassword = $glsApiPassword;
488
+ return $this;
489
+ }
490
+
491
+ /**
492
+ * @return mixed
493
+ */
494
+ public function getGlsApiAuthUsername()
495
+ {
496
+ return $this->glsApiAuthUsername;
497
+ }
498
+
499
+ /**
500
+ * @param $glsApiAuthUsername
501
+ * @return $this
502
+ */
503
+ public function setGlsApiAuthUsername($glsApiAuthUsername)
504
+ {
505
+ $this->glsApiAuthUsername = $glsApiAuthUsername;
506
+ return $this;
507
+ }
508
+
509
+ /**
510
+ * @return mixed
511
+ */
512
+ public function getGlsApiAuthPassword()
513
+ {
514
+ return $this->glsApiAuthPassword;
515
+ }
516
+
517
+ /**
518
+ * @param $glsApiAuthPassword
519
+ * @return $this
520
+ */
521
+ public function setGlsApiAuthPassword($glsApiAuthPassword)
522
+ {
523
+ $this->glsApiAuthPassword = $glsApiAuthPassword;
524
+ return $this;
525
+ }
526
+
527
+
528
+
529
+ /**
530
+ * @return mixed
531
+ */
532
+ public function getCurl() {
533
+ return $this->curl;
534
+ }
535
+
536
+ /**
537
+ * @param $curl
538
+ * @return $this
539
+ */
540
+ public function setCurl( $curl ) {
541
+ $this->curl = $curl;
542
+ return $this;
543
+ }
544
+
545
+ /**
546
+ * @return int
547
+ */
548
+ public function getCurlConnectTimeoutMs() {
549
+ return $this->curlConnectTimeoutMs;
550
+ }
551
+
552
+ /**
553
+ * @param $curlConnectTimeoutMs
554
+ * @return $this
555
+ */
556
+ public function setCurlConnectTimeoutMs($curlConnectTimeoutMs) {
557
+ $this->curlConnectTimeoutMs = $curlConnectTimeoutMs;
558
+ return $this;
559
+ }
560
+
561
+ /**
562
+ * @return int
563
+ */
564
+ public function getCurlTimeoutMs() {
565
+ return $this->curlTimeoutMs;
566
+ }
567
+
568
+ /**
569
+ * @param $curlTimeoutMs
570
+ * @return $this
571
+ */
572
+ public function setCurlTimeoutMs($curlTimeoutMs) {
573
+ $this->curlTimeoutMs = $curlTimeoutMs;
574
+ return $this;
575
+ }
576
+
577
+ /**
578
+ * @return int
579
+ */
580
+ public function getCurlErrorRetry() {
581
+ return $this->curlErrorRetry;
582
+ }
583
+
584
+ /**
585
+ * @param $curlErrorRetry
586
+ * @return $this
587
+ */
588
+ public function setCurlErrorRetry($curlErrorRetry) {
589
+ $this->curlErrorRetry = $curlErrorRetry;
590
+ return $this;
591
+ }
592
+
593
+ /**
594
+ * @return int
595
+ */
596
+ public function getCurlErrorRetryCount() {
597
+ return $this->curlErrorRetryCount;
598
+ }
599
+
600
+ /**
601
+ * @param $curlErrorRetryCount
602
+ * @return $this
603
+ */
604
+ public function setCurlErrorRetryCount($curlErrorRetryCount) {
605
+ $this->curlErrorRetryCount = $curlErrorRetryCount;
606
+ return $this;
607
+ }
608
+
609
+ /**
610
+ * @param int $increase
611
+ * @return $this
612
+ */
613
+ private function increaseCurlErrorRetryCount( $increase = 1 ){
614
+
615
+ if( $increase > 0 ){
616
+ $this->curlErrorRetryCount = $this->curlErrorRetryCount + $increase;
617
+ }
618
+
619
+ return $this;
620
+ }
621
+
622
+ /**
623
+ * @param int $reduce
624
+ * @return $this
625
+ */
626
+ private function reduceCurlErrorRetryCount( $reduce = 1 ){
627
+ if( $reduce < 0 ){
628
+ $this->curlErrorRetryCount = $this->curlErrorRetryCount - $reduce;
629
+ }
630
+
631
+ return $this;
632
+ }
633
+
634
+
635
+
636
+ /**
637
+ * @return array
638
+ */
639
+ private function getCurlOpts() {
640
+ return $this->curlOpts;
641
+ }
642
+
643
+ /**
644
+ * @param $curlOpts
645
+ * @return $this
646
+ */
647
+ private function setCurlOpts( $curlOpts ) {
648
+ $this->curlOpts = $curlOpts;
649
+ return $this;
650
+ }
651
+
652
+ /**
653
+ * @param $curlOpts
654
+ * @return $this
655
+ */
656
+ private function addCurlOpts( $curlOpts ) {
657
+ $logMessage = 'entered';
658
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
659
+
660
+ // merge the CURLOPT_HTTPHEADER values,
661
+ // because the $this->curlOpts = $this->curlOpts + (Array)$curlOpts
662
+ // will destroy the CURLOPT_HTTPHEADER values
663
+ // see also comment "do not use array_merge because of integer values of curl opt constants" below
664
+ if( isset($this->curlOpts[CURLOPT_HTTPHEADER]) && isset($curlOpts[CURLOPT_HTTPHEADER]) ){
665
+ $actualCurlOptHttpHeaders = $this->curlOpts[CURLOPT_HTTPHEADER];
666
+ $additionalCurlOptHttpHeaders = $curlOpts[CURLOPT_HTTPHEADER];
667
+ unset( $this->curlOpts[CURLOPT_HTTPHEADER] );
668
+ unset( $curlOpts[CURLOPT_HTTPHEADER] );
669
+
670
+ foreach( $actualCurlOptHttpHeaders as $key => $value ){
671
+ $this->curlOpts[CURLOPT_HTTPHEADER][] = $value;
672
+ }
673
+ foreach( $additionalCurlOptHttpHeaders as $key => $value){
674
+ $this->curlOpts[CURLOPT_HTTPHEADER][] = $value;
675
+ }
676
+ }
677
+
678
+ // do not use array_merge because of integer values of curl opt constants
679
+ $this->curlOpts = $this->curlOpts + (Array)$curlOpts;
680
+
681
+ return $this;
682
+ }
683
+
684
+ /**
685
+ * @return mixed
686
+ */
687
+ public function getCurlResponse() {
688
+ return $this->curlResponse;
689
+ }
690
+
691
+ /**
692
+ * @param $curlResponse
693
+ * @return $this
694
+ */
695
+ public function setCurlResponse($curlResponse) {
696
+ $this->curlResponse = $curlResponse;
697
+ return $this;
698
+ }
699
+
700
+ /**
701
+ * @return mixed
702
+ */
703
+ public function getCurlResponseHeaderSize() {
704
+ return $this->curlResponseHeaderSize;
705
+ }
706
+
707
+ /**
708
+ * @param $curlResponseHeaderSize
709
+ * @return $this
710
+ */
711
+ public function setCurlResponseHeaderSize($curlResponseHeaderSize) {
712
+ $this->curlResponseHeaderSize = $curlResponseHeaderSize;
713
+ return $this;
714
+ }
715
+
716
+ /**
717
+ * @return mixed
718
+ */
719
+ public function getCurlResponseHeader() {
720
+ return $this->curlResponseHeader;
721
+ }
722
+
723
+ /**
724
+ * @param $curlResponseHeader
725
+ * @return $this
726
+ */
727
+ public function setCurlResponseHeader($curlResponseHeader) {
728
+ $this->curlResponseHeader = $curlResponseHeader;
729
+ return $this;
730
+ }
731
+
732
+ /**
733
+ * @return mixed
734
+ */
735
+ public function getCurlResponseBody() {
736
+ return $this->curlResponseBody;
737
+ }
738
+
739
+ /**
740
+ * @param $curlResponseBody
741
+ * @return $this
742
+ */
743
+ public function setCurlResponseBody($curlResponseBody) {
744
+ $this->curlResponseBody = $curlResponseBody;
745
+ return $this;
746
+ }
747
+
748
+ /**
749
+ * @return mixed
750
+ */
751
+ public function getCurlErrno() {
752
+ return $this->curlErrno;
753
+ }
754
+
755
+ /**
756
+ * @param $curlErrno
757
+ * @return $this
758
+ */
759
+ public function setCurlErrno($curlErrno) {
760
+ $this->curlErrno = $curlErrno;
761
+ return $this;
762
+ }
763
+
764
+ /**
765
+ * @param $param
766
+ * @return mixed
767
+ */
768
+ public function getCurlInfo( $param ){
769
+ $returnValue = $this->curlInfo;
770
+
771
+ if( isset($returnValue[$param]) ){
772
+ $returnValue = $returnValue[$param];
773
+ }
774
+
775
+ return $returnValue;
776
+ }
777
+
778
+ /**
779
+ * @return $this
780
+ */
781
+ public function setCurlInfo() {
782
+ $this->curlInfo = curl_getinfo( $this->getCurl() );
783
+ return $this;
784
+ }
785
+
786
+ /**
787
+ * @return mixed
788
+ */
789
+ public function getCurrentFunction() {
790
+ return $this->currentFunction;
791
+ }
792
+
793
+ /**
794
+ * @param $currentFunction
795
+ * @return $this
796
+ */
797
+ public function setCurrentFunction($currentFunction) {
798
+ $this->currentFunction = $currentFunction;
799
+ return $this;
800
+ }
801
+
802
+ /**
803
+ * @return mixed
804
+ */
805
+ public function getCurrentCall() {
806
+ return $this->currentCall;
807
+ }
808
+
809
+ /**
810
+ * @param $currentCall
811
+ * @return $this
812
+ */
813
+ public function setCurrentCall($currentCall) {
814
+ $this->currentCall = $currentCall;
815
+ return $this;
816
+ }
817
+
818
+ /**
819
+ * @return null|SynergeticAgency_GlsConnector_Log
820
+ */
821
+ public function getLog() {
822
+ return $this->log;
823
+ }
824
+
825
+ /**
826
+ * @return $this
827
+ */
828
+ public function setLog() {
829
+ $this->log = new SynergeticAgency_GlsConnector_Log();
830
+ return $this;
831
+ }
832
+
833
+ /**
834
+ * @return mixed
835
+ */
836
+ public function getError() {
837
+ return $this->error;
838
+ }
839
+
840
+ /**
841
+ * @param $error
842
+ * @return $this
843
+ */
844
+ public function setError($error) {
845
+ $this->error = $error;
846
+ return $this;
847
+ }
848
+
849
+ /**
850
+ * @return int
851
+ */
852
+ public function getSleepSeconds() {
853
+ return $this->sleepSeconds;
854
+ }
855
+
856
+ /**
857
+ * @param $sleepSeconds
858
+ * @return $this
859
+ */
860
+ public function setSleepSeconds($sleepSeconds) {
861
+ $this->sleepSeconds = $sleepSeconds;
862
+ return $this;
863
+ }
864
+
865
+ /**
866
+ * @return mixed
867
+ */
868
+ public function getCustomerid() {
869
+ return $this->customerid;
870
+ }
871
+
872
+ /**
873
+ * @param $customerid
874
+ * @return $this
875
+ */
876
+ public function setCustomerid($customerid) {
877
+ $this->customerid = $customerid;
878
+ return $this;
879
+ }
880
+
881
+ /**
882
+ * @return mixed
883
+ */
884
+ public function getContactid() {
885
+ return $this->contactid;
886
+ }
887
+
888
+ /**
889
+ * @param $contactid
890
+ * @return $this
891
+ */
892
+ public function setContactid($contactid) {
893
+ $this->contactid = $contactid;
894
+ return $this;
895
+ }
896
+
897
+ /**
898
+ * @return mixed
899
+ */
900
+ public function getGlsApiUrl() {
901
+ return $this->glsApiUrl;
902
+ }
903
+
904
+ /**
905
+ * @param bool $url
906
+ * @return $this
907
+ */
908
+ public function setGlsApiUrl( $url = false ) {
909
+
910
+ $this->glsApiUrl = trim( (String)$url, "/" ) . "/";
911
+ if( $url === false ){
912
+ $port = "";
913
+ if( is_numeric($this->getPort()) ){
914
+ $port= ":" . $this->getPort();
915
+ }
916
+
917
+ $this->glsApiUrl = $this->getSchema() . "://" .
918
+ $this->getHost() .
919
+ $port .
920
+ #"/" . trim( $this->getGlsApiLang(), "/" ) .
921
+ "/" . trim( $this->getBaseUri(), "/" ) .
922
+ "/" . trim( $this->getApiEnpointPath(), "/" ) . "/";
923
+ }
924
+ return $this;
925
+ }
926
+
927
+ /**
928
+ * @return mixed
929
+ */
930
+ public function getGlsApiLang() {
931
+ return $this->glsApiLang;
932
+ }
933
+
934
+ /**
935
+ * @param $glsApiLang
936
+ * @return $this
937
+ */
938
+ public function setGlsApiLang($glsApiLang) {
939
+ $this->glsApiLang = $glsApiLang;
940
+ return $this;
941
+ }
942
+
943
+ /**
944
+ * @return mixed
945
+ */
946
+ public function getGlsApiSandbox() {
947
+ return $this->glsApiSandbox;
948
+ }
949
+
950
+ /**
951
+ * @param mixed $glsApiSandbox
952
+ */
953
+ public function setGlsApiSandbox($glsApiSandbox) {
954
+ $this->glsApiSandbox = $glsApiSandbox;
955
+ }
956
+
957
+ /**
958
+ * @return mixed
959
+ */
960
+ public function getGlsApiJsonUrl() {
961
+ return $this->glsApiJsonUrl;
962
+ }
963
+
964
+ /**
965
+ * @param $glsApiJsonUrl
966
+ * @return $this
967
+ */
968
+ public function setGlsApiJsonUrl($glsApiJsonUrl) {
969
+ $this->glsApiJsonUrl = $glsApiJsonUrl;
970
+ return $this;
971
+ }
972
+
973
+ /**
974
+ * @return mixed
975
+ */
976
+ public function getShipment() {
977
+ return $this->shipment;
978
+ }
979
+
980
+ /**
981
+ * @param $shipment
982
+ * @return $this
983
+ */
984
+ public function setShipment($shipment) {
985
+ $this->shipment = $shipment;
986
+ return $this;
987
+ }
988
+
989
+ /**
990
+ * @return mixed
991
+ */
992
+ public function getJsonConfig() {
993
+ return $this->jsonConfig;
994
+ }
995
+
996
+ /**
997
+ * @param string $jsonConfig JSON fomated string
998
+ * @return $this
999
+ */
1000
+ public function setJsonConfig( $jsonConfig ) {
1001
+ $this->jsonConfig = $jsonConfig;
1002
+ return $this;
1003
+ }
1004
+
1005
+ /**
1006
+ * @param $labelFiles
1007
+ * @return int
1008
+ */
1009
+ public function removeLabels( $labelFiles ){
1010
+ $returnValue = 0;
1011
+ foreach( $labelFiles AS $key => $labelFile ){
1012
+ if( is_writable($labelFile )){
1013
+ $returnValue = $returnValue + (Integer)unlink($labelFile);
1014
+
1015
+ }
1016
+ }
1017
+
1018
+ return $returnValue;
1019
+ }
1020
+
1021
+
1022
+ /**
1023
+ * @param array $labels Array that contains serveral labels saved on the filesystem
1024
+ * Note, that these files must be base64 decoded,
1025
+ * because the used ZEND PDF can only handle base64_decoded files
1026
+ * @param bool $target
1027
+ * @return bool|string $returnValue returns false, if something went wrong
1028
+ * returns full path of combined file
1029
+ * @throws Zend_Pdf_Exception
1030
+ */
1031
+ public function combineLabels( $labels, $target = false )
1032
+ {
1033
+
1034
+ $returnValue = false;
1035
+ $labelCount = 0;
1036
+ $labelPagesCount = 0;
1037
+ $maxLabelCount = 100;
1038
+
1039
+ // just to simulate more files than given in array $labels
1040
+ #$labels500 = array();
1041
+ #for ($i = 0; $i <= 10000; $i++) {
1042
+ # $labels500 = array_merge($labels, $labels500);
1043
+ # if (count($labels500) >= 500) {
1044
+ # break;
1045
+ # }
1046
+ #}
1047
+ #$labels = $labels500;
1048
+
1049
+ // init Zend PDF
1050
+ // Note, that ZEND PDF can only handle base64_decoded files!
1051
+ $zendPDF = new Zend_Pdf();
1052
+ $zendPDF->properties['encoding'] = "utf-8";
1053
+
1054
+ $labelMerged = new Zend_Pdf();
1055
+ $labelMerged->properties['encoding'] = "utf-8";
1056
+
1057
+ $zendPDF = new Zend_Pdf();
1058
+ $loadedLabelFiles = array();
1059
+ $firstFile = false;
1060
+ foreach ($labels AS $key => $label) {
1061
+ if($firstFile === false ){
1062
+ $firstFile = $label;
1063
+ }
1064
+
1065
+ $logMessage = "clone Label No " . ++$labelCount;
1066
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
1067
+ try {
1068
+ $loadedLabelFiles[$key] = $zendPDF::load($label);
1069
+
1070
+ // add all pages from the first PDF to our new document
1071
+ foreach ($loadedLabelFiles[$key]->pages as $page) {
1072
+ $clonedPage = clone $page;
1073
+ $labelMerged->pages[] = $clonedPage;
1074
+ $logMessage = "clone Page No " . ++$labelPagesCount . " for Label No " . $labelCount;
1075
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::INFO );
1076
+ }
1077
+ } catch (Exception $e) {
1078
+ $logMessage = $e->getMessage() . " => " . $label;
1079
+ $this->getLog()->write( __METHOD__, __LINE__, $logMessage, SynergeticAgency_GlsConnector_Log::ERR );
1080
+ }
1081
+
1082
+ if ($labelCount >= $maxLabelCount) {
1083
+ break;
1084
+ }
1085
+ }
1086
+
1087
+ // send the merged PDF document to browser
1088
+ #header('Content-type: application/pdf');
1089
+ #echo $labelMerged->render();
1090
+
1091
+ // or save it into filesystem
1092
+ if( $target !== false && file_exists(dirname($target)) ){
1093
+ $returnValue = $target;
1094
+
1095
+ } else {
1096
+ $returnValue = $firstFile . ".combined.pdf";
1097
+ }
1098
+ $labelMerged->save( $returnValue );
1099
+
1100
+ return $returnValue;
1101
+ }
1102
+
1103
+ }
lib/SynergeticAgency/GlsConnector/Log.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency_GlsConnector_Connector
23
+ * @copyright Copyright (c) 2006-2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with GLS API
29
+ *
30
+ * @category SynergetigAgency
31
+ * @package SynergeticAgency_GlsConnector_Log
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_GlsConnector_Log
35
+ {
36
+
37
+ const EMERG = 0;
38
+ const ALERT = 1;
39
+ const CRIT = 2;
40
+ const ERR = 3;
41
+ const WARN = 4;
42
+ const NOTICE = 5;
43
+ const INFO = 6;
44
+ const DEBUG = 7;
45
+
46
+ /**
47
+ * @var string
48
+ */
49
+ private $logFile = "/tmp/log/SynergeticAgency_GlsConnector_Connector.log";
50
+
51
+ /**
52
+ * @var bool
53
+ */
54
+ private $on = false;
55
+
56
+ /**
57
+ * @var bool
58
+ */
59
+ private $flat = false;
60
+
61
+ /**
62
+ * @var bool
63
+ */
64
+ private $echo = false;
65
+
66
+ /**
67
+ * @var array
68
+ */
69
+ private $logMessages = array();
70
+
71
+ /**
72
+ *
73
+ */
74
+ function __construct() {}
75
+
76
+
77
+ /**
78
+ * @param $method
79
+ * @param $line
80
+ * @param $message
81
+ * @param int $level
82
+ */
83
+ public function write( $method, $line, $message, $level = SynergeticAgency_GlsConnector_Log::DEBUG ){
84
+
85
+ $this->addLogMessage( $method, $line, $message, $level );
86
+
87
+ if(!file_exists($this->getLogFile()) ){
88
+ // suppress errors here just in case
89
+ $handle = @fopen($this->getLogFile(), "w+");
90
+ @fclose($handle);
91
+ }
92
+
93
+ if( $this->isOn() ){
94
+ if(file_exists($this->getLogFile()) && is_writable($this->getLogFile()) ){
95
+ if( $handle = fopen($this->getLogFile(), "a+") ) {
96
+ $date = date('c');
97
+
98
+ if( $this->isFlat() ){
99
+ $message = "\n" . $date . " " . $this->levelToString($level) . " (" . $level . "): " . $method . " @ Line " . $line . ": " . strip_tags( preg_replace("/\r|\n/", "", $message) );
100
+ if( $this->isEcho() ){
101
+ echo $message;
102
+ }
103
+ } else {
104
+ $message = "\n" . $date . " " . $this->levelToString($level) . " (" . $level . "): " . $method . " @ Line " . $line . ": " . $message;
105
+ if( $this->isEcho() ){
106
+ echo $message;
107
+ }
108
+ }
109
+
110
+ fwrite( $handle, $message );
111
+ fclose($handle);
112
+ }
113
+ } else {
114
+ error_log("GLS Connector: Logfile: ".$this->getLogFile() . " is Not writable!!!");
115
+ }
116
+ } else {
117
+ error_log("GLS Connector: logging is NOT activated: " . (Integer)$this->isOn());
118
+ }
119
+ }
120
+
121
+ /**
122
+ * @return $this
123
+ */
124
+ public function activate(){
125
+ $this->setOn( true );
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ *
131
+ */
132
+ public function deactivate(){
133
+ $this->setOn( false );
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * @return string
139
+ */
140
+ public function getLogFile() {
141
+ if(is_null($this->logFile)) {
142
+ // fallback
143
+ $file = join(DIRECTORY_SEPARATOR,
144
+ array(
145
+ DIRECTORY_SEPARATOR . trim(dirname(__FILE__), DIRECTORY_SEPARATOR),
146
+ "Log",
147
+ "Connector.log",
148
+ )
149
+ );
150
+ $this->setLogFile( $file );
151
+ }
152
+ return $this->logFile;
153
+ }
154
+
155
+ /**
156
+ * @param $logFile
157
+ */
158
+ public function setLogFile( $logFile ){
159
+
160
+ if( is_writable($logFile) ){
161
+ $this->logFile = $logFile;
162
+ $this->setOn( true );
163
+ } else {
164
+ if ($handle = fopen($logFile, "a")) {
165
+ fwrite( $handle, "\n\n" . date('c') . " " . $this->levelToString(SynergeticAgency_GlsConnector_Log::INFO) . " (" . SynergeticAgency_GlsConnector_Log::INFO . "): " . __METHOD__ . " @ line " . __LINE__ . ": initial creation of logfile " . $logFile . "\n\n" );
166
+ fclose($handle);
167
+ }
168
+ }
169
+ }
170
+
171
+ /**
172
+ * @return boolean
173
+ */
174
+ public function isOn() {
175
+ return $this->on;
176
+ }
177
+
178
+ /**
179
+ * @param $on
180
+ * @return $this
181
+ */
182
+ public function setOn($on) {
183
+ $this->on = $on;
184
+ return $this;
185
+ }
186
+
187
+ /**
188
+ * @return boolean
189
+ */
190
+ public function isFlat() {
191
+ return $this->flat;
192
+ }
193
+
194
+ /**
195
+ * @param $flat
196
+ * @return $this
197
+ */
198
+ public function setFlat($flat) {
199
+ $this->flat = $flat;
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * @return boolean
205
+ */
206
+ public function isEcho() {
207
+ return $this->echo;
208
+ }
209
+
210
+ /**
211
+ * @param $echo
212
+ * @return $this
213
+ */
214
+ public function setEcho($echo) {
215
+ $this->echo = $echo;
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * @return array
221
+ */
222
+ public function getLogMessages() {
223
+ return $this->logMessages;
224
+ }
225
+
226
+ /**
227
+ * @param $logMessages
228
+ * @return $this
229
+ */
230
+ public function setLogMessages( $logMessages ) {
231
+ $this->logMessages = $logMessages;
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * @param $method
237
+ * @param $line
238
+ * @param $message
239
+ * @param $level
240
+ * @return $this
241
+ */
242
+ public function addLogMessage( $method, $line, $message, $level = SynergeticAgency_GlsConnector_Log::DEBUG ) {
243
+ $cnt = count( $this->logMessages ) + 1;
244
+ $this->logMessages[$cnt]['method'] = $method;
245
+ $this->logMessages[$cnt]['line'] = $line;
246
+ $this->logMessages[$cnt]['message'] = $message;
247
+ $this->logMessages[$cnt]['level'] = $level;
248
+ return $this;
249
+ }
250
+
251
+ /**
252
+ * @param $level
253
+ * @return string
254
+ */
255
+ private function levelToString( $level ){
256
+
257
+ switch( $level ){
258
+ case $this::EMERG:
259
+ $returnValue = "EMERG";
260
+ break;
261
+ case $this::ALERT:
262
+ $returnValue = "ALERT";
263
+ break;
264
+ case $this::CRIT:
265
+ $returnValue = "CRIT";
266
+ break;
267
+ case $this::ERR:
268
+ $returnValue = "ERR";
269
+ break;
270
+ case $this::WARN:
271
+ $returnValue = "WARN";
272
+ break;
273
+ case $this::NOTICE:
274
+ $returnValue = "NOTICE";
275
+ break;
276
+ case $this::INFO:
277
+ $returnValue = "INFO";
278
+ break;
279
+ case $this::DEBUG:
280
+ $returnValue = "DEBUG";
281
+ break;
282
+ default:
283
+ $returnValue = "UNKNOWN";
284
+ break;
285
+ }
286
+
287
+ return $returnValue;
288
+ }
289
+ }
lib/SynergeticAgency/GlsConnector/Log/README.TXT ADDED
File without changes
lib/SynergeticAgency/GlsConnector/Model/Address.php ADDED
@@ -0,0 +1,562 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency_GlsConnector_Model
23
+ * @copyright Copyright (c) 2006-2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with archives
29
+ *
30
+ * @category SynergetigAgency
31
+ * @package SynergeticAgency_GlsConnector_Model
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_GlsConnector_Model_Address {
35
+
36
+
37
+ const GLS_API_ADDRESS_DELIVERY = "delivery";
38
+ const GLS_API_ADDRESS_ALTERNATIVESHIPPING = "alternativeShipper";
39
+ const GLS_API_ADDRESS_RETURN = "return";
40
+
41
+
42
+ /**
43
+ * @var array the address object converted into an array i.e. to generate correct GLS-JSON
44
+ */
45
+ private $glsArray;
46
+
47
+ /**
48
+ *
49
+ * @var string $type The available address types:
50
+ * GLS_API_ADDRESS_DELIVERY:
51
+ * required
52
+ * GLS_API_ADDRESS_ALTERNATIVESHIPPING:
53
+ * optional
54
+ * Used when the customer wants to customize the shipment address on the label.
55
+ * Does not work with “Pick&Ship Service” and Pick&Return Service”
56
+ * (both services are not implemented currently).
57
+ * GLS_API_ADDRESS_PICKUP:
58
+ * mandatory
59
+ * for shop return service (SRS)
60
+ */
61
+ private $type;
62
+
63
+ /**
64
+ * @var string $id The required id with min length of 2 to 40 chars
65
+ * This is a request payload entity
66
+ */
67
+ private $id;
68
+
69
+ /**
70
+ * @var string $name1 The required name with min length of 2 to 40 chars
71
+ * This is a request payload entity
72
+ */
73
+ private $name1;
74
+
75
+ /**
76
+ * @var string $name2 An optional name with max length of 40 chars
77
+ * This is a request payload entity
78
+ */
79
+ private $name2;
80
+
81
+ /**
82
+ * @var string $name3 An optional name with max length of 40 chars
83
+ * This is a request payload entity
84
+ */
85
+ private $name3;
86
+
87
+ /**
88
+ * @var string $street1 The required street with length of 3 to 40 chars
89
+ * This is a request payload entity
90
+ */
91
+ private $street1;
92
+
93
+ /**
94
+ * @var string $street2 The required street with length of 3 to 40 chars
95
+ * This is a request payload entity
96
+ */
97
+ private $street2;
98
+
99
+ /**
100
+ * @var string $blockNo1 The required street with length of 3 to 40 chars
101
+ * This is a request payload entity
102
+ */
103
+ private $blockNo1;
104
+
105
+ /**
106
+ * @var string $blockNo2 The required street with length of 3 to 40 chars
107
+ * This is a request payload entity
108
+ */
109
+ private $blockNo2;
110
+
111
+ /**
112
+ * @var string $country The required ISO 3166-1 numeric country with length of 3 chars
113
+ * This is a request payload entity
114
+ */
115
+ private $country;
116
+
117
+ /**
118
+ * @var string $zipCode The required zip code with length of 1 to 10 chars
119
+ * This is a request payload entity
120
+ */
121
+ private $zipCode;
122
+
123
+ /**
124
+ * @var string $city The required city with length of 2 to 40 chars
125
+ * This is a request payload entity
126
+ */
127
+ private $city;
128
+
129
+ /**
130
+ * @var string $province The required city with length of 2 to 40 chars
131
+ * This is a request payload entity
132
+ */
133
+ private $province;
134
+
135
+ /**
136
+ * @var string $contact The contact with length of 2 to 40 chars
137
+ * This field is required when SynergeticAgency_GlsConnector_Model_Services:name = GLS_API_SHOPDELIVERY is given
138
+ * This is a request payload entity
139
+ */
140
+ private $contact;
141
+
142
+ /**
143
+ * @var string $email The email with max length of 100 chars
144
+ * This field is required when SynergeticAgency_GlsConnector_Model_Services:name = GLS_API_SHOPDELIVERY is given
145
+ * When SynergeticAgency_GlsConnector_Model_Services:name = GLS_API_FLEXDELIVERYSERVICE is requested,
146
+ * either $email or $mobile has to be present
147
+ * This is a request payload entity
148
+ */
149
+ private $email;
150
+
151
+ /**
152
+ * @var string $phone An optional phone with max length of 40 chars
153
+ * This is a request payload entity
154
+ */
155
+ private $phone;
156
+
157
+ /**
158
+ * @var string $mobile The email with max length of 40 chars
159
+ * This field is required when SynergeticAgency_GlsConnector_Model_Services:name = GLS_API_SHOPDELIVERY is given
160
+ * When SynergeticAgency_GlsConnector_Model_Services:name = GLS_API_FLEXDELIVERYSERVICE is requested,
161
+ * either $email or $mobile has to be present
162
+ * This is a request payload entity
163
+ */
164
+ private $mobile;
165
+
166
+ /**
167
+ * @var string $comments An optional phone with max length of 40 chars
168
+ * This is a request payload entity
169
+ */
170
+ private $comments;
171
+
172
+
173
+ function __construct(){
174
+
175
+ }
176
+
177
+
178
+ /**
179
+ * @return array
180
+ */
181
+ private function toGlsArray(){
182
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":" . $this->getName1();
183
+ $returnValue = array();
184
+
185
+ if( $this->getId() !== NULL ) $returnValue['id'] = (string)$this->getId();
186
+ if( $this->getName1() !== NULL ) $returnValue['name1'] = (string)$this->getName1();
187
+ if( $this->getName2() !== NULL ) $returnValue['name2'] = (string)$this->getName2();
188
+ if( $this->getName3() !== NULL ) $returnValue['name3'] = (string)$this->getName3();
189
+ if( $this->getStreet1() !== NULL ) $returnValue['street1'] = (string)$this->getStreet1();
190
+ if( $this->getStreet2() !== NULL ) $returnValue['street2'] = (string)$this->getStreet2();
191
+ if( $this->getBlockNo1() !== NULL ) $returnValue['blockNo1'] = (string)$this->getBlockNo1();
192
+ if( $this->getBlockNo2() !== NULL ) $returnValue['blockNo2'] = (string)$this->getBlockNo2();
193
+ if( $this->getCountry() !== NULL ) $returnValue['country'] = (string)$this->getCountry();
194
+ if( $this->getZipCode() !== NULL ) $returnValue['zipCode'] = (string)$this->getZipCode();
195
+ if( $this->getCity() !== NULL ) $returnValue['city'] = (string)$this->getCity();
196
+ if( $this->getProvince() !== NULL ) $returnValue['province'] = (string)$this->getProvince();
197
+ if( $this->getContact() !== NULL ) $returnValue['contact'] = (string)$this->getContact();
198
+ if( $this->getEmail() !== NULL ) $returnValue['email'] = (string)$this->getEmail();
199
+ if( $this->getPhone() !== NULL ) $returnValue['phone'] = (string)$this->getPhone();
200
+ if( $this->getMobile() !== NULL ) $returnValue['mobile'] = (string)$this->getMobile();
201
+ if( $this->getComments() !== NULL ) $returnValue['comments'] = (string)$this->getComments();
202
+
203
+ #echo "\n\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":" . $this->getName1();
204
+
205
+ $this->setGlsArray( $returnValue );
206
+
207
+ return $returnValue;
208
+ }
209
+
210
+ /**
211
+ * @return array
212
+ */
213
+ public function getConstants() {
214
+ $oClass = new ReflectionClass(__CLASS__);
215
+ return $oClass->getConstants();
216
+ }
217
+
218
+ /**
219
+ * @return mixed
220
+ */
221
+ public function getGlsArray() {
222
+ return $this->glsArray;
223
+ }
224
+
225
+ /**
226
+ * @param $glsArray
227
+ * @return $this
228
+ */
229
+ public function setGlsArray($glsArray) {
230
+ $this->glsArray = $glsArray;
231
+ return $this;
232
+ }
233
+
234
+ /**
235
+ * @param $key
236
+ * @param $value
237
+ * @return $this
238
+ */
239
+ public function addGlsArrayValue( $key, $value ) {
240
+ $this->glsArray[$key] = $value;
241
+ return $this;
242
+ }
243
+
244
+ /**
245
+ * @return string
246
+ */
247
+ public function getType() {
248
+ return $this->type;
249
+ }
250
+
251
+ /**
252
+ * @param $type
253
+ * @return $this
254
+ */
255
+ public function setType($type) {
256
+ $this->type = $type;
257
+ return $this;
258
+ }
259
+
260
+ /**
261
+ * @return string
262
+ */
263
+ public function getId()
264
+ {
265
+ return $this->id;
266
+ }
267
+
268
+ /**
269
+ * @param string $id
270
+ * @return $this
271
+ */
272
+ public function setId($id)
273
+ {
274
+ $this->id = $id;
275
+ $this->toGlsArray();
276
+ return $this;
277
+ }
278
+
279
+ /**
280
+ * @return string
281
+ */
282
+ public function getName1() {
283
+ return $this->name1;
284
+ }
285
+
286
+ /**
287
+ * @param $name1
288
+ * @return $this
289
+ */
290
+ public function setName1($name1) {
291
+ //TODO: Implement filter in all setters (php filter)
292
+ $this->name1 = substr($name1,0,40);
293
+ $this->toGlsArray();
294
+ return $this;
295
+ }
296
+
297
+ /**
298
+ * @return string
299
+ */
300
+ public function getName2() {
301
+ return $this->name2;
302
+ }
303
+
304
+ /**
305
+ * @param $name2
306
+ * @return $this
307
+ */
308
+ public function setName2($name2) {
309
+ $this->name2 = substr($name2,0,40);
310
+ $this->toGlsArray();
311
+ return $this;
312
+ }
313
+
314
+ /**
315
+ * @return string
316
+ */
317
+ public function getName3() {
318
+ return $this->name3;
319
+ }
320
+
321
+ /**
322
+ * @param $name3
323
+ * @return $this
324
+ */
325
+ public function setName3($name3) {
326
+ $this->name3 = substr($name3,0,40);
327
+ $this->toGlsArray();
328
+ return $this;
329
+ }
330
+
331
+ /**
332
+ * @return string
333
+ */
334
+ public function getStreet1() {
335
+ return $this->street1;
336
+ }
337
+
338
+ /**
339
+ * @param $street1
340
+ * @return $this
341
+ */
342
+ public function setStreet1($street1) {
343
+ $this->street1 = substr($street1,0,40);
344
+ $this->toGlsArray();
345
+ return $this;
346
+ }
347
+
348
+ /**
349
+ * @return string
350
+ */
351
+ public function getStreet2() {
352
+ return $this->street2;
353
+ }
354
+
355
+ /**
356
+ * @param $street2
357
+ * @return $this
358
+ */
359
+ public function setStreet2($street2) {
360
+ $this->street2 = substr($street2,0,40);
361
+ $this->toGlsArray();
362
+ return $this;
363
+ }
364
+
365
+ /**
366
+ * @return string
367
+ */
368
+ public function getBlockNo1()
369
+ {
370
+ return $this->blockNo1;
371
+ }
372
+
373
+ /**
374
+ * @param string $blockNo1
375
+ * @return $this
376
+ */
377
+ public function setBlockNo1($blockNo1)
378
+ {
379
+ $this->blockNo1 = $blockNo1;
380
+ $this->toGlsArray();
381
+ return $this;
382
+ }
383
+
384
+ /**
385
+ * @return string
386
+ */
387
+ public function getBlockNo2()
388
+ {
389
+ return $this->blockNo2;
390
+ }
391
+
392
+ /**
393
+ * @param string $blockNo2
394
+ * @return $this
395
+ */
396
+ public function setBlockNo2($blockNo2)
397
+ {
398
+ $this->blockNo2 = $blockNo2; $this->toGlsArray();
399
+ return $this;
400
+ }
401
+
402
+ /**
403
+ * @return string
404
+ */
405
+ public function getCountry() {
406
+ return $this->country;
407
+ }
408
+
409
+ /**
410
+ * @param $country
411
+ * @return $this
412
+ */
413
+ public function setCountry( $country ) {
414
+
415
+ //$country = str_pad($country, 3, '0', STR_PAD_LEFT);
416
+ $this->country = "$country";
417
+ $this->toGlsArray();
418
+ return $this;
419
+ }
420
+
421
+ /**
422
+ * @return string
423
+ */
424
+ public function getZipCode() {
425
+ return $this->zipCode;
426
+ }
427
+
428
+ /**
429
+ * @param $zipCode
430
+ * @return $this
431
+ */
432
+ public function setZipCode($zipCode) {
433
+ $this->zipCode = $zipCode;
434
+ $this->toGlsArray();
435
+ return $this;
436
+ }
437
+
438
+ /**
439
+ * @return string
440
+ */
441
+ public function getCity() {
442
+ return $this->city;
443
+ }
444
+
445
+ /**
446
+ * @param $city
447
+ * @return $this
448
+ */
449
+ public function setCity($city) {
450
+ $this->city = $city;
451
+ $this->toGlsArray();
452
+ return $this;
453
+ }
454
+
455
+ /**
456
+ * @return string
457
+ */
458
+ public function getProvince()
459
+ {
460
+ return $this->province;
461
+ }
462
+
463
+ /**
464
+ * @param string $province
465
+ * @return $this
466
+ */
467
+ public function setProvince($province)
468
+ {
469
+ $this->province = $province;
470
+ $this->toGlsArray();
471
+ return $this;
472
+ }
473
+
474
+
475
+
476
+ /**
477
+ * @return string
478
+ */
479
+ public function getContact() {
480
+ return $this->contact;
481
+ }
482
+
483
+ /**
484
+ * @param $contact
485
+ * @return $this
486
+ */
487
+ public function setContact($contact) {
488
+ $this->contact = $contact;
489
+ $this->toGlsArray();
490
+ return $this;
491
+ }
492
+
493
+ /**
494
+ * @return string
495
+ */
496
+ public function getEmail() {
497
+ return $this->email;
498
+ }
499
+
500
+ /**
501
+ * @param $email
502
+ * @return $this
503
+ */
504
+ public function setEmail($email) {
505
+ $this->email = $email;
506
+ $this->toGlsArray();
507
+ return $this;
508
+ }
509
+
510
+ /**
511
+ * @return string
512
+ */
513
+ public function getPhone() {
514
+ return $this->phone;
515
+ }
516
+
517
+ /**
518
+ * @param $phone
519
+ * @return $this
520
+ */
521
+ public function setPhone($phone) {
522
+ $this->phone = $phone;
523
+ $this->toGlsArray();
524
+ return $this;
525
+ }
526
+
527
+ /**
528
+ * @return string
529
+ */
530
+ public function getMobile() {
531
+ return $this->mobile;
532
+ }
533
+
534
+ /**
535
+ * @param $mobile
536
+ * @return $this
537
+ */
538
+ public function setMobile($mobile) {
539
+ $this->mobile = $mobile;
540
+ $this->toGlsArray();
541
+ return $this;
542
+ }
543
+
544
+ /**
545
+ * @return string
546
+ */
547
+ public function getComments()
548
+ {
549
+ return $this->comments;
550
+ }
551
+
552
+ /**
553
+ * @param string $comments
554
+ * @return $this
555
+ */
556
+ public function setComments($comments)
557
+ {
558
+ $this->comments = $comments;
559
+ $this->toGlsArray();
560
+ return $this;
561
+ }
562
+ }
lib/SynergeticAgency/GlsConnector/Model/Error.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ # ToDo add license text here
3
+
4
+ /**
5
+ * Class to work with archives
6
+ *
7
+ * @category SynergetigAgency
8
+ * @package SynergeticAgency_GlsConnector_Model
9
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
10
+ */
11
+ class SynergeticAgency_GlsConnector_Model_Error
12
+ {
13
+
14
+ private $hasError = false;
15
+
16
+ /**
17
+ * @var
18
+ */
19
+ private $message;
20
+
21
+ /**
22
+ * @var
23
+ */
24
+ private $modelState;
25
+
26
+ /**
27
+ * @var array the error object converted into an array i.e. to generate correct GLS-JSON
28
+ */
29
+ private $glsArray;
30
+
31
+ /**
32
+ *
33
+ */
34
+ function __construct() {
35
+
36
+ }
37
+
38
+ /**
39
+ * @return array
40
+ */
41
+ private function toGlsArray() {
42
+ $returnValue = array();
43
+ return $returnValue;
44
+ }
45
+
46
+ /**
47
+ * @return array
48
+ */
49
+ public function getConstants() {
50
+ $oClass = new ReflectionClass(__CLASS__);
51
+ return $oClass->getConstants();
52
+ }
53
+
54
+ /**
55
+ * @return mixed
56
+ */
57
+ public function getGlsArray() {
58
+ return $this->glsArray;
59
+ }
60
+
61
+ /**
62
+ * @param $glsArray
63
+ * @return $this
64
+ */
65
+ public function setGlsArray($glsArray) {
66
+ $this->glsArray = $glsArray;
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * @param $key
72
+ * @param $value
73
+ * @return $this
74
+ */
75
+ public function addGlsArrayValue( $key, $value ) {
76
+ $this->glsArray[$key] = $value;
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * @return boolean
82
+ */
83
+ public function hasError() {
84
+ return $this->hasError;
85
+ }
86
+
87
+ /**
88
+ * @param $hasError
89
+ * @return $this
90
+ */
91
+ public function setHasError($hasError) {
92
+ $this->hasError = $hasError;
93
+ return $this;
94
+ }
95
+
96
+ /**
97
+ * @return mixed
98
+ */
99
+ public function getMessage() {
100
+ return $this->message;
101
+ }
102
+
103
+ /**
104
+ * @param $message
105
+ * @return $this
106
+ */
107
+ public function setMessage($message) {
108
+ $this->message = $message;
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * @return mixed
114
+ */
115
+ public function getModelState( $flat = false ) {
116
+ $returnValue = $this->modelState;
117
+
118
+ if( $flat === true ){
119
+
120
+ $returnValue = "";
121
+ if(is_array($this->modelState)) {
122
+ foreach ($this->modelState as $key => $values) {
123
+ if (is_array($values)) {
124
+ foreach ($values as $num => $message) {
125
+ $returnValue = trim($returnValue . " " . $message, " ");
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+ return $returnValue;
132
+ }
133
+
134
+ /**
135
+ * @param $modelState
136
+ * @return $this
137
+ */
138
+ public function setModelState($modelState) {
139
+ $this->modelState = $modelState;
140
+ return $this;
141
+ }
142
+
143
+
144
+ }
lib/SynergeticAgency/GlsConnector/Model/Info.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency_GlsConnector_Model
23
+ * @copyright Copyright (c) 2006-2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with archives
29
+ *
30
+ * @category SynergetigAgency
31
+ * @package SynergeticAgency_GlsConnector_Model
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_GlsConnector_Model_Info
35
+ {
36
+
37
+ /**
38
+ * @var array the info object converted into an array i.e. to generate correct GLS-JSON
39
+ */
40
+ private $glsArray;
41
+
42
+ /**
43
+ * @var string $name The required name for the info
44
+ * This is a request payload entity
45
+ */
46
+ private $name;
47
+
48
+ /**
49
+ * @var string $value The required value for the info
50
+ * This is a request payload entity
51
+ */
52
+ private $value;
53
+
54
+ /**
55
+ *
56
+ */
57
+ function __construct() {
58
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":";
59
+ #echo "\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":";
60
+ }
61
+
62
+
63
+ /**
64
+ * @return array
65
+ */
66
+ private function toGlsArray() {
67
+
68
+ $returnValue = array();
69
+
70
+ if( $this->getName() !== NULL ) $returnValue['name'] = (String)$this->getName();
71
+ if( $this->getValue() !== NULL ) $returnValue['value'] = (String)$this->getValue();
72
+
73
+ $this->setGlsArray( $returnValue );
74
+ }
75
+
76
+ /**
77
+ * @return array
78
+ */
79
+ public function getConstants() {
80
+ $oClass = new ReflectionClass(__CLASS__);
81
+ return $oClass->getConstants();
82
+ }
83
+
84
+ /**
85
+ * @return mixed
86
+ */
87
+ public function getGlsArray() {
88
+ return $this->glsArray;
89
+ }
90
+
91
+ /**
92
+ * @param $glsArray
93
+ * @return $this
94
+ */
95
+ public function setGlsArray($glsArray) {
96
+ $this->glsArray = $glsArray;
97
+ return $this;
98
+ }
99
+
100
+ /**
101
+ * @param $key
102
+ * @param $value
103
+ * @return $this
104
+ */
105
+ public function DEPRECATED_addGlsArrayValue( $key, $value ) {
106
+ $this->glsArray[$key] = $value;
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * @return string
112
+ */
113
+ public function getName()
114
+ {
115
+ return $this->name;
116
+ }
117
+
118
+ /**
119
+ * @param $name
120
+ * @return $this
121
+ */
122
+ public function setName( $name )
123
+ {
124
+ $this->name = $name;
125
+ $this->toGlsArray();
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * @return string
131
+ */
132
+ public function getValue()
133
+ {
134
+ return $this->value;
135
+ }
136
+
137
+ /**
138
+ * @param $value
139
+ * @return $this
140
+ */
141
+ public function setValue( $value )
142
+ {
143
+ $this->value = (String)$value;
144
+ $this->toGlsArray();
145
+ return $this;
146
+ }
147
+ }
lib/SynergeticAgency/GlsConnector/Model/JsonConfig.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ # ToDo add license text here
3
+
4
+ /**
5
+ * Class to work with archives
6
+ *
7
+ * @category SynergetigAgency
8
+ * @package SynergeticAgency_GlsConnector_Model
9
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
10
+ */
11
+ class SynergeticAgency_GlsConnector_Model_JsonConfig
12
+ {
13
+
14
+ /**
15
+ * @var array the service object converted into an array i.e. to generate correct GLS-JSON
16
+ */
17
+ private $glsArray;
18
+
19
+ /**
20
+ * @var string $countryCode ISO-31661 alpha 2
21
+ */
22
+ private $countryCode;
23
+
24
+
25
+ /**
26
+ *
27
+ */
28
+ function __construct() {
29
+
30
+ }
31
+
32
+ /**
33
+ * @return array
34
+ */
35
+ private function toGlsArray() {
36
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":" . $this->getShopDelivery();
37
+ $returnValue = array();
38
+
39
+ /** @var $parcel SynergeticAgency_GlsConnector_Model_Services */
40
+ if( $this->getShopDelivery() !== NULL ) $returnValue['ShopDelivery'] = $this->getShopDelivery();
41
+ if( $this->getNotificationEmail() !== NULL ) $returnValue['NotificationEmail'] = $this->getNotificationEmail();
42
+ if( $this->getDeposit() !== NULL ) $returnValue['Deposit'] = $this->getDeposit();
43
+ if( $this->getShopReturn() !== NULL ) $returnValue['ShopReturn'] = $this->getShopReturn();
44
+
45
+ #echo "\n\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":" . var_export( $returnValue, 1);
46
+
47
+ $this->setGlsArray( $returnValue );
48
+
49
+ return $returnValue;
50
+ }
51
+
52
+ /**
53
+ * @return array
54
+ */
55
+ public function getConstants() {
56
+ $oClass = new ReflectionClass(__CLASS__);
57
+ return $oClass->getConstants();
58
+ }
59
+
60
+ /**
61
+ * @return mixed
62
+ */
63
+ public function getGlsArray() {
64
+ return $this->glsArray;
65
+ }
66
+
67
+ /**
68
+ * @param $glsArray
69
+ * @return $this
70
+ */
71
+ public function setGlsArray($glsArray) {
72
+ $this->glsArray = $glsArray;
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ * @param $key
78
+ * @param $value
79
+ * @return $this
80
+ */
81
+ public function addGlsArrayValue( $key, $value ) {
82
+ $this->glsArray[$key] = $value;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * @return string
88
+ */
89
+ public function getCountryCode() {
90
+ return $this->countryCode;
91
+ }
92
+
93
+ /**
94
+ * @param string $countryCode
95
+ */
96
+ public function setCountryCode($countryCode) {
97
+ $this->countryCode = $countryCode;
98
+ }
99
+
100
+
101
+ }
lib/SynergeticAgency/GlsConnector/Model/Parcel.php ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category SynergetigAgency
22
+ * @package SynergeticAgency_GlsConnector_Model
23
+ * @copyright Copyright (c) 2006-2016 synergetic agency AG (http://agency.synergetic.ag)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Class to work with archives
29
+ *
30
+ * @category SynergetigAgency
31
+ * @package SynergeticAgency_GlsConnector_Model
32
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
33
+ */
34
+ class SynergeticAgency_GlsConnector_Model_Parcel
35
+ {
36
+
37
+ const GLS_API_PARCEL_ROUTING_PRIMARY2D = "primary2D";
38
+ const GLS_API_PARCEL_ROUTING_SECONDARY2D = "secondary2D";
39
+ const GLS_API_PARCEL_ROUTING_NATIONALREF = "nationalRef";
40
+
41
+
42
+ /**
43
+ * @var array the parcel object converted into an array i.e. to generate correct GLS-JSON
44
+ */
45
+ private $glsArray;
46
+
47
+
48
+ /**
49
+ * @var string $parcelNumber The parcel number sent in GLS-Response as numeric stringi.e. 60715018107
50
+ * This is a request payload entity
51
+ */
52
+ private $parcelNumber;
53
+
54
+ /**
55
+ * @var string $trackId The parcel tracking ID sent in GLS-Response as alphanumeric uppercase string i.e. ZHYAQHYZ
56
+ * This is a request payload entity
57
+ */
58
+ private $trackId;
59
+
60
+ /**
61
+ * @var string $location The parcel tracking URL sent in GLS-Response as full URL i.e. https://qs.gls-group.eu/track/ZHYAQHYZ
62
+ * This is a request payload entity
63
+ */
64
+ private $location;
65
+
66
+
67
+ /**
68
+ * @var float $weight The required weight with format %.2n
69
+ * This is a request payload entity
70
+ */
71
+ private $weight;
72
+
73
+ /**
74
+ * @var array $references An array of parcel based references.
75
+ * ToDo: ??? This field is required only when GLS_API_SERVICE_CASHSERVICE is given, and the delivery address country is Germany ???
76
+ * This is a request payload entity
77
+ */
78
+ private $references;
79
+
80
+ /**
81
+ * @var string $comment The optional comment with max length of 40 chars
82
+ * This is a request payload entity
83
+ */
84
+ private $comment;
85
+
86
+
87
+ /**
88
+ * @var array $services The required array containing SynergeticAgency_GlsConnector_Model_Service objects
89
+ * This is a request payload entity
90
+ */
91
+ private $services;
92
+
93
+
94
+ /**
95
+ *
96
+ */
97
+ function __construct() {
98
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":";
99
+ #echo "\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":";
100
+ }
101
+
102
+
103
+
104
+ /**
105
+ * @return array
106
+ */
107
+ private function toGlsArray() {
108
+ #echo "<br><br>Entering " . __METHOD__ . " @ line " . __LINE__ . ":";
109
+
110
+ #echo "<br>\$this->getReferences() = " . var_export($this->getReferences(), 1 ) . "";
111
+ #exit();
112
+ $returnValue = array();
113
+
114
+ if( $this->getWeight() !== NULL ) $returnValue['weight'] = $this->getWeight();
115
+ if( $this->getReferences() !== NULL ) $returnValue['references'] = $this->getReferences();
116
+ if( $this->getComment() !== NULL ) $returnValue['comment'] = $this->getComment();
117
+
118
+ if(count($this->getServices())) {
119
+ foreach ($this->getServices() AS $serviceNum => $service) {
120
+ /** @var $info SynergeticAgency_GlsConnector_Model_Service */
121
+ if ($service instanceof SynergeticAgency_GlsConnector_Model_Service) $returnValue['services'][$serviceNum] = $service->getGlsArray();
122
+ }
123
+ }
124
+
125
+ #echo "<br>Leave " . __METHOD__ . " @ line " . __LINE__ . ":" . var_export( $returnValue, 1);
126
+
127
+ #exit();
128
+
129
+ $this->setGlsArray( $returnValue );
130
+
131
+ return $returnValue;
132
+ }
133
+
134
+ /**
135
+ * @return array
136
+ */
137
+ public function getConstants() {
138
+ $oClass = new ReflectionClass(__CLASS__);
139
+ return $oClass->getConstants();
140
+ }
141
+
142
+ /**
143
+ * @return mixed
144
+ */
145
+ public function getGlsArray() {
146
+ return $this->glsArray;
147
+ }
148
+
149
+ /**
150
+ * @param $glsArray
151
+ * @return $this
152
+ */
153
+ public function setGlsArray($glsArray) {
154
+ $this->glsArray = $glsArray;
155
+ return $this;
156
+ }
157
+
158
+ /**
159
+ * @param $key
160
+ * @param $value
161
+ * @return $this
162
+ */
163
+ public function addGlsArrayValue( $key, $value ) {
164
+ $this->glsArray[$key] = $value;
165
+ return $this;
166
+ }
167
+
168
+ /**
169
+ * @return int
170
+ */
171
+ public function DEPRECATED_getNum() {
172
+ return $this->num;
173
+ }
174
+
175
+ /**
176
+ * @param $num
177
+ * @return $this
178
+ */
179
+ public function DEPRECATED_setNum($num) {
180
+ $this->num = $num;
181
+ return $this;
182
+ }
183
+
184
+ /**
185
+ * @return string
186
+ */
187
+ public function getParcelNumber()
188
+ {
189
+ return $this->parcelNumber;
190
+ }
191
+
192
+ /**
193
+ * @param $parcelNumber
194
+ * @return $this
195
+ */
196
+ public function setParcelNumber($parcelNumber)
197
+ {
198
+ $this->parcelNumber = $parcelNumber;
199
+ $this->toGlsArray();
200
+ return $this;
201
+ }
202
+
203
+ /**
204
+ * @return string
205
+ */
206
+ public function getTrackId()
207
+ {
208
+ return $this->trackId;
209
+ }
210
+
211
+ /**
212
+ * @param $trackId
213
+ * @return $this
214
+ */
215
+ public function setTrackId($trackId)
216
+ {
217
+ $this->trackId = $trackId;
218
+ $this->toGlsArray();
219
+ return $this;
220
+ }
221
+
222
+ /**
223
+ * @return string
224
+ */
225
+ public function getLocation()
226
+ {
227
+ return $this->location;
228
+ }
229
+
230
+ /**
231
+ * @param $location
232
+ * @return $this
233
+ */
234
+ public function setLocation($location)
235
+ {
236
+ $this->location = $location;
237
+ $this->toGlsArray();
238
+ return $this;
239
+ }
240
+
241
+ /**
242
+ * @return float
243
+ */
244
+ public function getWeight() {
245
+ return $this->weight;
246
+ }
247
+
248
+ /**
249
+ * @param float $weight
250
+ * @return $this
251
+ */
252
+ public function setWeight( $weight = 0.0) {
253
+ $this->weight = (Float)$weight;
254
+ $this->toGlsArray();
255
+ return $this;
256
+ }
257
+
258
+ /**
259
+ * @return string
260
+ */
261
+ public function getReferences() {
262
+ return $this->references;
263
+ }
264
+
265
+ /**
266
+ * @param array $references
267
+ * @return $this
268
+ */
269
+ public function setReferences( $references ) {
270
+
271
+ if( is_array($references) ){
272
+ $this->references = $references;
273
+ }
274
+
275
+ $this->toGlsArray();
276
+ return $this;
277
+ }
278
+
279
+ /**
280
+ * @param $reference
281
+ * @param null $referenceKey
282
+ * @return $this
283
+ */
284
+ public function pushReference( $reference, $referenceKey = NULL ) {
285
+
286
+ if( $referenceKey !== NULL && $referenceKey !== '' ){
287
+ $this->references[$referenceKey] = $reference;
288
+ } else {
289
+ $this->references[] = $reference;
290
+ }
291
+
292
+ $this->toGlsArray();
293
+ return $this;
294
+ }
295
+
296
+ /**
297
+ * @return string
298
+ */
299
+ public function getComment() {
300
+ return $this->comment;
301
+ }
302
+
303
+ /**
304
+ * @param string $comment
305
+ * @return $this
306
+ */
307
+ public function setComment( $comment = "" ) {
308
+ $this->comment = (String)$comment;
309
+ $this->toGlsArray();
310
+ return $this;
311
+ }
312
+
313
+ /**
314
+ * @return array
315
+ */
316
+ public function getServices()
317
+ {
318
+ return $this->services;
319
+ }
320
+
321
+ /**
322
+ * @param array $services array, containing SynergeticAgency_GlsConnector_Model_Service objects
323
+ * @return $this
324
+ */
325
+ public function setServices( $services )
326
+ {
327
+ if( is_array($services) ){
328
+ foreach( $services AS $key => $service){
329
+ if(get_class($service) === "SynergeticAgency_GlsConnector_Model_Service" ){
330
+ $this->services[] = $service;
331
+ }
332
+ }
333
+ }
334
+ $this->toGlsArray();
335
+ }
336
+
337
+ /**
338
+ * @param SynergeticAgency_GlsConnector_Model_Service $service
339
+ * @return $this
340
+ */
341
+ public function pushService( SynergeticAgency_GlsConnector_Model_Service $service )
342
+ {
343
+ $this->services[] = $service;
344
+ $this->toGlsArray();
345
+ return $this;
346
+ }
347
+
348
+ }
lib/SynergeticAgency/GlsConnector/Model/Service.php ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ # ToDo add license text here
3
+
4
+ /**
5
+ * Class to work with archives
6
+ *
7
+ * @category SynergetigAgency
8
+ * @package SynergeticAgency_GlsConnector_Model
9
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
10
+ */
11
+ class SynergeticAgency_GlsConnector_Model_Service
12
+ {
13
+
14
+
15
+ const GLS_API_SERVICE_CASHONDELIVERY = "cashondelivery";
16
+ const GLS_API_SERVICE_DELIVERYATWORKSERVICE = "deliveryatworkservice";
17
+ const GLS_API_SERVICE_SHOPDELIVERYSERVICE = "shopdeliveryservice";
18
+ const GLS_API_SERVICE_ADDONLIABILITYSERVICE = "addonliabilityservice";
19
+ const GLS_API_SERVICE_DEPOSITSERVICE = "depositservice";
20
+ const GLS_API_SERVICE_IDENTPINSERVICE = "identpinservice";
21
+ const GLS_API_SERVICE_INTERCOMPANYSERVICE = "intercompanyservice";
22
+ const GLS_API_SERVICE_SHOPRETURNSERVICE = "shopreturnservice";
23
+ const GLS_API_SERVICE_GUARANTEED24SERVICE = "guaranteed24service";
24
+ const GLS_API_SERVICE_FLEXDELIVERYSERVICE = "flexdeliveryservice";
25
+ const GLS_API_SERVICE_THINKGREENSERVICE = "thinkgreenservice";
26
+ const GLS_API_SERVICE_DOCUMENTRETURNSERVICE = "documentreturnservice";
27
+ const GLS_API_SERVICE_PROOFSERVICE = "proofservice";
28
+ const GLS_API_SERVICE_PRIVATEDELIVERYSERVICE = "privatedeliveryservice";
29
+ const GLS_API_SERVICE_EXWORKSSERVICE = "exworksservice";
30
+ const GLS_API_SERVICE_EXCHANGESERVICE = "exchangeservice";
31
+
32
+
33
+ /**
34
+ * @var array the service object converted into an array i.e. to generate correct GLS-JSON
35
+ */
36
+ private $glsArray;
37
+
38
+ /**
39
+ * @var string $name The required name for the service
40
+ * This is a request payload entity
41
+ */
42
+ private $name;
43
+
44
+ /**
45
+ * @var array $infos The required array containing SynergeticAgency_GlsConnector_Model_Info objects
46
+ * This is a request payload entity
47
+ */
48
+ private $infos;
49
+
50
+ /**
51
+ *
52
+ */
53
+ function __construct() {
54
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":";
55
+ #echo "\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":";
56
+ }
57
+
58
+ /**
59
+ * @return array
60
+ */
61
+ private function toGlsArray() {
62
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":";
63
+ $returnValue = array();
64
+
65
+ if( $this->getName() !== NULL ) $returnValue['name'] = $this->getName();
66
+
67
+ if(count($this->getInfos())) {
68
+ foreach ($this->getInfos() AS $infoNum => $info) {
69
+ /** @var $info SynergeticAgency_GlsConnector_Model_Info */
70
+ if ($info instanceof SynergeticAgency_GlsConnector_Model_Info) $returnValue['infos'][$infoNum] = $info->getGlsArray();
71
+ }
72
+ }
73
+
74
+ #echo "\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":" . var_export( $returnValue, 1);
75
+
76
+ $this->setGlsArray( $returnValue );
77
+
78
+ return $returnValue;
79
+ }
80
+
81
+ /**
82
+ * @return array
83
+ */
84
+ public function getConstants() {
85
+ $oClass = new ReflectionClass(__CLASS__);
86
+ return $oClass->getConstants();
87
+ }
88
+
89
+ /**
90
+ * @return mixed
91
+ */
92
+ public function getGlsArray() {
93
+ return $this->glsArray;
94
+ }
95
+
96
+ /**
97
+ * @param $glsArray
98
+ * @return $this
99
+ */
100
+ public function setGlsArray($glsArray) {
101
+ $this->glsArray = $glsArray;
102
+ return $this;
103
+ }
104
+
105
+ /**
106
+ * @param $key
107
+ * @param $value
108
+ * @return $this
109
+ */
110
+ public function DEPRECATED_addGlsArrayValue( $key, $value ) {
111
+ $this->glsArray[$key] = $value;
112
+ return $this;
113
+ }
114
+
115
+ /**
116
+ * @return string
117
+ */
118
+ public function getName()
119
+ {
120
+ return $this->name;
121
+ }
122
+
123
+ /**
124
+ * @param string $name
125
+ * @return $this
126
+ */
127
+ public function setName( $name )
128
+ {
129
+ $this->name = $name;
130
+ $this->toGlsArray();
131
+ return $this;
132
+ }
133
+
134
+ /**
135
+ * @return array
136
+ */
137
+ public function getInfos()
138
+ {
139
+ return $this->infos;
140
+ }
141
+
142
+ /**
143
+ * @param array $infos array, containing SynergeticAgency_GlsConnector_Model_SInfo objects
144
+ * @return $this
145
+ */
146
+ public function setInfos( $infos )
147
+ {
148
+ if( is_array($infos) ){
149
+ foreach( $infos AS $key => $info){
150
+ if(get_class($info) === "SynergeticAgency_GlsConnector_Model_Info" ){
151
+ $this->infos[] = $info;
152
+ }
153
+ }
154
+ }
155
+ $this->toGlsArray();
156
+
157
+ return $this;
158
+ }
159
+
160
+ /**
161
+ * @param SynergeticAgency_GlsConnector_Model_Info $info
162
+ * @return $this
163
+ */
164
+ public function pushInfo( SynergeticAgency_GlsConnector_Model_Info $info )
165
+ {
166
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":" . var_export($info, 1);
167
+
168
+ $this->infos[] = $info;
169
+ $this->toGlsArray();
170
+
171
+ #echo "\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":" . var_export( $this->infos, 1);
172
+
173
+ return $this;
174
+ }
175
+
176
+ }
lib/SynergeticAgency/GlsConnector/Model/Services.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ # ToDo add license text here
3
+
4
+ /**
5
+ * Class to work with archives
6
+ *
7
+ * @category SynergetigAgency
8
+ * @package SynergeticAgency_GlsConnector_Model
9
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
10
+ */
11
+ class SynergeticAgency_GlsConnector_Model_Services
12
+ {
13
+
14
+ /**
15
+ * @var array the service object converted into an array i.e. to generate correct GLS-JSON
16
+ */
17
+ private $glsArray;
18
+
19
+ /**
20
+ * @var string $name The required name for the service
21
+ * This is a request payload entity
22
+ */
23
+ private $name;
24
+
25
+ /**
26
+ * @var array $infos The required array containing SynergeticAgency_GlsConnector_Model_Info objects
27
+ * This is a request payload entity
28
+ */
29
+ private $infos;
30
+
31
+ /**
32
+ *
33
+ */
34
+ function __construct() {
35
+
36
+ }
37
+
38
+ /**
39
+ * @return array
40
+ */
41
+ private function toGlsArray() {
42
+ #echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":" . $this->getShopDelivery();
43
+ $returnValue = array();
44
+
45
+ /** @var $parcel SynergeticAgency_GlsConnector_Model_Services */
46
+ if( $this->getShopDelivery() !== NULL ) $returnValue['ShopDelivery'] = $this->getShopDelivery();
47
+ if( $this->getNotificationEmail() !== NULL ) $returnValue['NotificationEmail'] = $this->getNotificationEmail();
48
+ if( $this->getDeposit() !== NULL ) $returnValue['Deposit'] = $this->getDeposit();
49
+ if( $this->getShopReturn() !== NULL ) $returnValue['ShopReturn'] = $this->getShopReturn();
50
+ if( $this->getFlexDeliveryService() !== NULL ) $returnValue['FlexDelivery'] = $this->getFlexDeliveryService();
51
+ if( $this->getThinkGreenService() !== NULL ) $returnValue['ThinkGreen'] = $this->getThinkGreenService();
52
+ if( $this->getPrivateDelivery() !== NULL ) $returnValue['privateDelivery'] = $this->getPrivateDelivery();
53
+ if( $this->getGuaranteed24Service() !== NULL ) $returnValue['G24'] = $this->getGuaranteed24Service();
54
+
55
+ #echo "\n\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":" . var_export( $returnValue, 1);
56
+
57
+ $this->setGlsArray( $returnValue );
58
+
59
+ return $returnValue;
60
+ }
61
+
62
+ /**
63
+ * @return array
64
+ */
65
+ public function getConstants() {
66
+ $oClass = new ReflectionClass(__CLASS__);
67
+ return $oClass->getConstants();
68
+ }
69
+
70
+ /**
71
+ * @return mixed
72
+ */
73
+ public function getGlsArray() {
74
+ return $this->glsArray;
75
+ }
76
+
77
+ /**
78
+ * @param $glsArray
79
+ * @return $this
80
+ */
81
+ public function setGlsArray($glsArray) {
82
+ $this->glsArray = $glsArray;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * @param $key
88
+ * @param $value
89
+ * @return $this
90
+ */
91
+ public function addGlsArrayValue( $key, $value ) {
92
+ $this->glsArray[$key] = $value;
93
+ return $this;
94
+ }
95
+
96
+
97
+
98
+ /**
99
+ * @param $guaranteed24Service allowed values: true, 'true', 'Y'
100
+ * @return $this
101
+ */
102
+ public function setGuaranteed24Service($guaranteed24Service) {
103
+ $this->guaranteed24Service = NULL;
104
+ if( $guaranteed24Service === true || $guaranteed24Service === 'true' || $guaranteed24Service === 'Y' ){
105
+ $this->guaranteed24Service = 'Y';
106
+ }
107
+ $this->toGlsArray();
108
+ return $this;
109
+ }
110
+
111
+ }
lib/SynergeticAgency/GlsConnector/Model/Shipment.php ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ # ToDo add license text here
3
+
4
+ /**
5
+ * Class to work with archives
6
+ *
7
+ * @category SynergetigAgency
8
+ * @package SynergeticAgency_GlsConnector_Model
9
+ * @author PHP WebDevelopment <php.webdevelopment@synergetic.ag>
10
+ */
11
+ class SynergeticAgency_GlsConnector_Model_Shipment
12
+ {
13
+
14
+ /**
15
+ * @var string $customerId The required customer Id
16
+ * This is a request payload entity
17
+ */
18
+ private $customerId;
19
+
20
+ /**
21
+ * @var string $contactId The required contact Id
22
+ * This is a request payload entity
23
+ */
24
+ private $contactId;
25
+
26
+ /**
27
+ * @var string $shipperId The required contact Id
28
+ * This is a request payload entity
29
+ */
30
+ private $shipperId;
31
+
32
+ /**
33
+ * @var string $shipmentDate The required date of the shipment using format "YYYYMMDD" with maxlenth of 8 chars
34
+ * This is a request payload entity
35
+ */
36
+ private $shipmentDate;
37
+
38
+ /**
39
+ * @var array $references The required references
40
+ * This is a request payload entity
41
+ */
42
+ private $references;
43
+
44
+ /**
45
+ * @var string $sandbox The optional information, if the connector should use the sandbox or not
46
+ * This is a request payload entity
47
+ * Note, that the GLS-API name for this property is "system"
48
+ */
49
+ private $sandbox;
50
+
51
+ /**
52
+ * @var string $reference A optional customer given reverence with max length of 50 chars
53
+ * This is a request payload entity
54
+ */
55
+ private $reference;
56
+
57
+ /**
58
+ * @var array $addresses Container node(associated array) for all SynergeticAgency_GlsConnector_Model_Address addresses
59
+ * This is a request payload entity
60
+ */
61
+ private $addresses = array();
62
+
63
+ /**
64
+ * @var array $parcels Container node(numeric array) for all SynergeticAgency_GlsConnector_Model_Parcel parcels
65
+ * All included parcels must have the same service configuration
66
+ * At least one parcel is required
67
+ */
68
+ private $parcels = array();
69
+
70
+
71
+ /**
72
+ * @var string $labelSize The optional format of the label.
73
+ * Allowed values are: "A4", "A5", "A6"(default)
74
+ * This is a request payload entity
75
+ */
76
+ private $labelSize = "A6";
77
+
78
+
79
+ /**
80
+ * @var szring $consignmentId The shipment number
81
+ * This is a response payload entity
82
+ */
83
+ private $consignmentId;
84
+
85
+ /**
86
+ * @var string $pdf The required base64-encoded PDF including labels of all created returns.
87
+ * The labels of each parcel are on separate pages
88
+ * Labels created on the sandbox system hava a “DEMO” mark on it
89
+ * This is a request payload entity
90
+ */
91
+ #private $pdf;
92
+
93
+
94
+ /**
95
+ * @var array $labels The required base64-encoded PDF's including labels of all created returns.
96
+ * The labels of each parcel are on separate pages
97
+ * Labels created on the sandbox system hava a “DEMO” mark on it
98
+ * This is a request payload entity
99
+ */
100
+ private $labels;
101
+
102
+
103
+ /**
104
+ * @var array $labelContentLength The content length of $this->labels[n]
105
+ */
106
+ private $labelContentLength;
107
+
108
+ /**
109
+ * @var SynergeticAgency_GlsConnector_Model_Services $services Container for all SynergeticAgency_GlsConnector_Model_Services services
110
+ * The availability of services is dependent on SynergeticAgency_GlsConnector_Connector::username
111
+ */
112
+ private $services;
113
+
114
+
115
+ /**
116
+ * @var bool sets with return label or without
117
+ */
118
+ private $returnLabel = false;
119
+
120
+ /**
121
+ *
122
+ */
123
+ function __construct() {
124
+ //echo "\n\nEntering " . __METHOD__ . " @ line " . __LINE__ . ":";
125
+
126
+ $address = new SynergeticAgency_GlsConnector_Model_Address();
127
+ $address->setType( SynergeticAgency_GlsConnector_Model_Address::GLS_API_ADDRESS_DELIVERY );
128
+ $this->addAddress( $address );
129
+
130
+ //echo "\n\nLeave " . __METHOD__ . " @ line " . __LINE__ . ":";
131
+ }
132
+
133
+
134
+ /**
135
+ * converts the the GLS Web API relevant fields of this shipment model into an ECMA-404 conform JSON format
136
+ * see also "JSON Data Interchange Format" on http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf
137
+ *
138
+ * @return string
139
+ */
140
+ public function toJson(){
141
+ $returnValue = Array();
142
+
143
+ // mapping global fields
144
+ #$returnValue['customerid'] = $this->getCustomerId();
145
+ #$returnValue['contactid'] = $this->getContactId();
146
+ $returnValue['shipperId'] = $this->getShipperId();
147
+ $returnValue['shipmentDate'] = $this->getShipmentDate();
148
+ $returnValue['labelSize'] = $this->getLabelSize();
149
+
150
+ // GLS-API uses parameter "System=TEST" to define that all requests pointing to the GLS-Sandbox
151
+ // The Magento-GLS-Extension uses true|false to determine Sandbox-Mode(true) or not(false), so we have to map true to "TEST"
152
+ // On the other hand, send no parameter "System" if the productive GLS-System should be used(Sandbox-Mode(false)).
153
+ #if( $this->getSandbox() === true ){
154
+ # $returnValue['System'] = 'TEST';
155
+ #}
156
+
157
+ $returnValue['references'] = $this->getReferences();
158
+
159
+ // mapping address fields
160
+ foreach( $this->getAddresses() as $type => $address ){
161
+ /** @var $address SynergeticAgency_GlsConnector_Model_Address */
162
+ $returnValue['addresses'][$type] = $address->getGlsArray();
163
+ }
164
+
165
+ // mapping parcel fields
166
+ foreach( $this->getParcels() as $parcelNum => $parcel ){
167
+ /** @var $parcel SynergeticAgency_GlsConnector_Model_Parcel */
168
+ $returnValue['parcels'][$parcelNum] = $parcel->getGlsArray();
169
+ if($this->getReturnLabel()) {
170
+ $returnValue['returns'][$parcelNum]['weight'] = $parcel->getWeight();
171
+ }
172
+
173
+ if(count($parcel->getServices())) {
174
+ foreach ($parcel->getServices() as $serviceNum => $service) {
175
+ /** @var $parcel SynergeticAgency_GlsConnector_Model_Service */
176
+ $returnValue['parcels'][$parcelNum]['services'][$serviceNum] = $service->getGlsArray();
177
+
178
+ if (count($service->getInfos())) {
179
+ foreach ($service->getInfos() as $infoNum => $info) {
180
+ /** @var $parcel SynergeticAgency_GlsConnector_Model_Info */
181
+ $returnValue['parcels'][$parcelNum]['services'][$serviceNum]['infos'][$infoNum] = $info->getGlsArray();
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
187
+
188
+ return json_encode( $returnValue );
189
+ }
190
+
191
+
192
+ /**
193
+ * @return string
194
+ */
195
+ public function getCustomerId() {
196
+ return $this->customerId;
197
+ }
198
+
199
+ /**
200
+ * @param $customerId
201
+ * @return $this
202
+ */
203
+ public function setCustomerId($customerId) {
204
+ $this->customerId = $customerId;
205
+ #$this->setShipperId( $this->getCustomerId() . " " . $this->getContactId() );
206
+ return $this;
207
+ }
208
+
209
+ /**
210
+ * @return string
211
+ */
212
+ public function getContactId() {
213
+ return $this->contactId;
214
+ }
215
+
216
+ /**
217
+ * @param $contactId
218
+ * @return $this
219
+ */
220
+ public function setContactId($contactId) {
221
+ $this->contactId = $contactId;
222
+ #$this->setShipperId( $this->getCustomerId() . " " . $this->getContactId() );
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * @return string
228
+ */
229
+ public function getShipperId() {
230
+ return $this->shipperId;
231
+ }
232
+
233
+ /**
234
+ * @param $shipperId
235
+ * @return $this
236
+ */
237
+ public function setShipperId($shipperId) {
238
+ $this->shipperId = $shipperId;
239
+ return $this;
240
+ }
241
+
242
+ /**
243
+ * @return string
244
+ */
245
+ public function getShipmentDate() {
246
+ return $this->shipmentDate;
247
+ }
248
+
249
+ /**
250
+ * @param $shipmentDate
251
+ * @return $this
252
+ */
253
+ public function setShipmentDate($shipmentDate) {
254
+ $this->shipmentDate = $shipmentDate;
255
+ return $this;
256
+ }
257
+
258
+ /**
259
+ * @return string
260
+ */
261
+ public function getReferences() {
262
+ return $this->references;
263
+ }
264
+
265
+ /**
266
+ * @param array $references
267
+ * @return $this
268
+ */
269
+ public function setReferences( $references ) {
270
+
271
+ if( is_array($references) ){
272
+ $this->references = $references;
273
+ }
274
+ return $this;
275
+ }
276
+
277
+ /**
278
+ * @param $reference
279
+ * @param null $referenceKey
280
+ * @return $this
281
+ */
282
+ public function pushReference( $reference, $referenceKey = NULL ) {
283
+
284
+ if( $referenceKey !== NULL && $referenceKey !== '' ){
285
+ $this->references[$referenceKey] = $reference;
286
+ } else {
287
+ $this->references[] = $reference;
288
+ }
289
+
290
+ return $this;
291
+ }
292
+
293
+ /**
294
+ * @return string
295
+ */
296
+ public function getSandbox() {
297
+ return $this->sandbox;
298
+ }
299
+
300
+ /**
301
+ * @param $sandbox
302
+ * @return $this
303
+ */
304
+ public function setSandbox($sandbox) {
305
+ $this->sandbox = (Boolean)$sandbox;
306
+ return $this;
307
+ }
308
+
309
+ /**
310
+ * @return string
311
+ */
312
+ public function getReference() {
313
+ return $this->reference;
314
+ }
315
+
316
+ /**
317
+ * @param $reference
318
+ * @return $this
319
+ */
320
+ public function setReference($reference) {
321
+ $this->reference = $reference;
322
+ return $this;
323
+ }
324
+
325
+ /**
326
+ * @param mixed $type
327
+ * @return array|SynergeticAgency_GlsConnector_Model_Address
328
+ */
329
+ public function getAddresses( $type = false ) {
330
+ $returnValue = $this->addresses;
331
+
332
+ if( $type !== false && isset($this->addresses[$type]) ){
333
+ $returnValue = $this->addresses[$type];
334
+ } else if( is_array($type) ){
335
+ $returnValue = array();
336
+ foreach( $type as $k => $n ){
337
+ if( isset($this->addresses[$n]) && is_a($this->addresses[$n], SynergeticAgency_GlsConnector_Model_Address )){
338
+ $returnValue[$n] = $this->addresses[$n];
339
+ }
340
+ }
341
+ #if( count($returnValue) === 0 ){
342
+ # $returnValue = false;
343
+ #}
344
+ }
345
+ return $returnValue;
346
+ }
347
+
348
+ /**
349
+ * @param $addresses
350
+ * @return $this
351
+ */
352
+ public function setAddresses($addresses) {
353
+ $this->addresses = $addresses;
354
+ return $this;
355
+ }
356
+
357
+ /**
358
+ * @param SynergeticAgency_GlsConnector_Model_Address $address
359
+ * @return $this
360
+ */
361
+ public function addAddress( SynergeticAgency_GlsConnector_Model_Address $address) {
362
+
363
+ if( in_array ( $address->getType() , $address->getConstants() ) ){
364
+ $this->addresses[$address->getType()] = $address;
365
+ }
366
+
367
+ return $this;
368
+ }
369
+
370
+
371
+ /**
372
+ * @param mixed $num
373
+ * @return array
374
+ */
375
+ public function getParcels( $num = false ) {
376
+ $returnValue = $this->parcels;
377
+ if( $num !== false && is_numeric($num) && isset($this->parcels[$num]) ){
378
+ $returnValue = $this->parcels[$num];
379
+ } else if( is_array($num) ){
380
+ $returnValue = array();
381
+ foreach( $num as $k => $n ){
382
+ if( isset($this->parcels[$n]) && is_a($this->parcels[$n], SynergeticAgency_GlsConnector_Model_Parcel )){
383
+ $returnValue[$n] = $this->parcels[$n];
384
+ }
385
+ }
386
+ #if( count($returnValue) === 0 ){
387
+ # $returnValue = $this->parcels;
388
+ #}
389
+ }
390
+
391
+ return $returnValue;
392
+ }
393
+
394
+ /**
395
+ * @param $parcels
396
+ * @return $this
397
+ */
398
+ public function setParcels($parcels) {
399
+ $this->parcels = $parcels;
400
+ return $this;
401
+ }
402
+
403
+ /**
404
+ * @param SynergeticAgency_GlsConnector_Model_Parcel $parcel
405
+ * @return $this
406
+ */
407
+ public function setParcel( SynergeticAgency_GlsConnector_Model_Parcel $parcel) {
408
+
409
+ if( isset( $this->parcels[$parcel->getNum()] ) ){
410
+ $this->parcels[$parcel->getNum()] = $parcel;
411
+ }
412
+
413
+ return $this;
414
+ }
415
+
416
+ /**
417
+ * @param SynergeticAgency_GlsConnector_Model_Parcel $parcel
418
+ * @return $this
419
+ */
420
+ public function pushParcel( SynergeticAgency_GlsConnector_Model_Parcel $parcel ){
421
+ array_push( $this->parcels, $parcel );
422
+ return $this;
423
+ }
424
+
425
+ /**
426
+ * @return string
427
+ */
428
+ public function getLabelSize() {
429
+ return $this->labelSize;
430
+ }
431
+
432
+ /**
433
+ * @param $labelSize
434
+ * @return $this
435
+ */
436
+ public function setLabelSize($labelSize) {
437
+ $this->labelSize = $labelSize;
438
+ return $this;
439
+ }
440
+
441
+ /**
442
+ * @return string
443
+ */
444
+ public function getConsignmentId() {
445
+ return $this->consignmentId;
446
+ }
447
+
448
+ /**
449
+ * @param $consignmentId
450
+ * @return $this
451
+ */
452
+ public function setConsignmentId($consignmentId) {
453
+ $this->consignmentId = $consignmentId;
454
+ return $this;
455
+ }
456
+
457
+ /**
458
+ * @return string
459
+ */
460
+ public function getPdf() {
461
+ return $this->pdf;
462
+ }
463
+
464
+ /**
465
+ * set the base64-encoded PDF and $this->pdfContentLength
466
+ * @param string $pdf base64-encoded PDF
467
+ * @return $this
468
+ */
469
+ public function setPdf($pdf) {
470
+ $this->pdf = $pdf;
471
+ $this->setPdfContentLength( strlen($pdf) );
472
+ return $this;
473
+ }
474
+
475
+ /**
476
+ * @return array
477
+ */
478
+ public function getLabels()
479
+ {
480
+ return $this->labels;
481
+ }
482
+
483
+ /**
484
+ * @param array $labels
485
+ */
486
+ public function setLabels($labels)
487
+ {
488
+ $this->labels = $labels;
489
+ }
490
+
491
+ /**
492
+ * @param $label
493
+ * @return $this
494
+ */
495
+ public function pushLabel( $label ){
496
+ $this->pushLabelContentLength( strlen($label) );
497
+ $this->labels[] = $label;
498
+ return $this;
499
+ }
500
+
501
+ /**
502
+ * @return string
503
+ */
504
+ public function getLabelContentLength() {
505
+ return $this->labelContentLength;
506
+ }
507
+
508
+ /**
509
+ * @param $labelContentLength
510
+ * @return $this
511
+ */
512
+ public function setLabelContentLength($labelContentLength) {
513
+ $this->labelContentLength = $labelContentLength;
514
+ return $this;
515
+ }
516
+
517
+ /**
518
+ * @param $label
519
+ * @return $this
520
+ */
521
+ public function pushLabelContentLength( $label ){
522
+ $this->labelContentLength[] = $label;
523
+ return $this;
524
+ }
525
+
526
+ /**
527
+ * @return array
528
+ */
529
+ public function getServices() {
530
+ return $this->services;
531
+ }
532
+
533
+ /**
534
+ * @param $services
535
+ * @return $this
536
+ */
537
+ public function setServices($services) {
538
+ $this->services = $services;
539
+ return $this;
540
+ }
541
+
542
+ /**
543
+ * @return bool
544
+ */
545
+ public function getReturnLabel() {
546
+ return $this->returnLabel;
547
+ }
548
+
549
+ /**
550
+ * @param bool $returnlabel
551
+ * @return $this
552
+ */
553
+ public function setReturnLabel($returnlabel) {
554
+ $this->returnLabel = (bool)$returnlabel;
555
+ return $this;
556
+ }
557
+ }
package.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Official_GLS_Dispatch</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easily integrate the most common GLS dispatch services and the GLS ParcelShop finder into your shop.</summary>
10
+ <description>Official GLS dispatch extension&#xD;
11
+ &#xD;
12
+ Easily integrate the most common GLS dispatch services and the GLS ParcelShop finder into your shop.&#xD;
13
+ &#xD;
14
+ Features&#xD;
15
+ - Create labels online - for standard delivery, ShopDeliveryService or 24h-Express&#xD;
16
+ - Provide pre-printed return labels to your customers&#xD;
17
+ - ParcelShop finder to select alternative delivery address included&#xD;
18
+ - Offer CashService to your customers&#xD;
19
+ &#xD;
20
+ Supported delivery options&#xD;
21
+ - Standard delivery (domestic and Europe-wide)&#xD;
22
+ - ShopDeliveryService&#xD;
23
+ - ShopReturnService&#xD;
24
+ - 24h- Express&#xD;
25
+ - FlexDeliveryService&#xD;
26
+ - ThinkGreenService&#xD;
27
+ - CashService&#xD;
28
+ &#xD;
29
+ GLS Germany at a glance &#xD;
30
+ - Dense network&#xD;
31
+ - Separate express network&#xD;
32
+ - About 5,000 GLS ParcelShops&#xD;
33
+ - National and international parcel delivery&#xD;
34
+ - Parcel and express services&#xD;
35
+ - Numerous optional additional services&#xD;
36
+ &#xD;
37
+ Visit our website https://gls-group.eu</description>
38
+ <notes>Official GLS Dispatch Extension</notes>
39
+ <authors><author><name>synergetic PHP Webdevelopment</name><user>php_synag</user><email>phpwebdevelopment@synag.de</email></author></authors>
40
+ <date>2016-12-21</date>
41
+ <time>17:34:52</time>
42
+ <contents><target name="magecommunity"><dir name="SynergeticAgency"><dir name="Gls"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Gls"><dir name="Shipment"><dir name="Edit"><dir name="Form"><file name="Packages.php" hash="91f20e933a3bdccecd8f51cc65f64a15"/></dir><file name="Form.php" hash="130f4b5cc6cb5e35e12e8229116a8fd9"/></dir><file name="Edit.php" hash="b654dd3a6953012beeb01db0952580a4"/><dir name="Grid"><dir name="Renderer"><file name="Order.php" hash="84b8e9730bcd070f710e5b75d93d18f7"/><file name="Pdf.php" hash="271ef29c53abf26aa11d8a249f494db3"/><file name="Shipment.php" hash="336ae75186fa605a720dd9c6682249b3"/></dir></dir><file name="Grid.php" hash="c34a83ec1fd24e3329eea42c83b73fa0"/></dir><file name="Shipment.php" hash="e394cbdaee759e608ee1da17e7429bbd"/></dir><dir name="Order"><dir name="Address"><dir name="Form"><dir name="Attr"><file name="Parcelshopid.php" hash="5966474ca779e65a40e5325f377704c5"/></dir></dir></dir><dir name="Shipment"><dir name="Create"><dir name="Gls"><file name="Packages.php" hash="90e98ad4ba0cefd5a2ff7597c7282087"/></dir><file name="Gls.php" hash="1a35cf1f562363f693c8af750ca51d12"/><file name="Tracking.php" hash="c4d69cde80d2f647785ef95ca250a484"/></dir><dir name="View"><file name="Gls.php" hash="8841cb4c9ecd508e0192cf006288bed0"/><file name="Tracking.php" hash="eefb3ae8108758dc1b5212e18b62d0d9"/></dir></dir><dir name="Template"><dir name="Grid"><dir name="Renderer"><file name="Order.php" hash="57a77ece47021b109e9bb5f76fdfc0de"/></dir></dir></dir></dir></dir><dir name="System"><dir name="Config"><file name="Note.php" hash="3af47df0dff99e11650b70bff2261170"/></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Parcelshop"><file name="Map.php" hash="95e614d0f081ca946970f8d8909c8e7d"/></dir><file name="Parcelshop.php" hash="e775188503153128246fee50fc45bad5"/></dir></dir><dir name="Form"><file name="Glscashondelivery.php" hash="e58ca6fd528c47d13c92aa60e66736db"/></dir></dir><dir name="Helper"><file name="Data.php" hash="e834d2c6ad67ec140f12b90f8879287d"/><file name="Log.php" hash="ff72f850515f2543d74cdafe758ed489"/><file name="Validate.php" hash="e3fcfface1fa779e84a97af0a0d050d7"/></dir><dir name="Model"><file name="Carrier.php" hash="1fd3232606e7747c3529a7c845bace6f"/><file name="Combination.php" hash="0f98dfc1621be095a62cb5636c18d549"/><file name="Country.php" hash="6c924cb0b18c5ab1f35318dbd9ea863d"/><file name="Gls.php" hash="0b6cb1ff7208b5a42c38deb44633f2a1"/><file name="Glscashondelivery.php" hash="8d5e0ceedcef3117bffbee3417dc9e08"/><file name="Jsonimport.php" hash="0ecb8306613536a30942a6ebdaa42bad"/><file name="Observer.php" hash="9f55a620de98843f11eeb5de72336865"/><file name="Product.php" hash="e1620ee8bfd2e339ecece8395c33d6d5"/><dir name="Resource"><dir name="Combination"><file name="Collection.php" hash="116ffac74da0a67d51e33e4287e435c3"/></dir><file name="Combination.php" hash="d67846f51d288506ca37694d5cbf34f3"/><dir name="Country"><file name="Collection.php" hash="70f548294111419f8dc76e4e92890118"/></dir><file name="Country.php" hash="a7c39d638370da328f66bef5568353c6"/><dir name="Product"><file name="Collection.php" hash="84050613e4f87df08bca6717eec901b8"/></dir><file name="Product.php" hash="eb93a5f933b5fd5d19311e096cdaae9d"/><dir name="Service"><file name="Collection.php" hash="cc7226bbe64460be82c63d1f6a9bfd05"/></dir><file name="Service.php" hash="3045a8e5be427920117b17d40620922a"/><dir name="Shipment"><dir name="Address"><file name="Collection.php" hash="c168ba8ba814fed8eb595a62e0dd5cd6"/></dir><file name="Address.php" hash="64828c17296560efb133d23a98e67a84"/><file name="Collection.php" hash="ce3796ddd9e0aa4b0d3ad392a197e745"/><dir name="Parcel"><file name="Collection.php" hash="70f3a3e4f49b8ec9ff66c421c9a35085"/></dir><file name="Parcel.php" hash="68d4501a688b8ef4bec43c2407058013"/></dir><file name="Shipment.php" hash="89b7956f988bdc2c26024e02865e7d89"/></dir><file name="Service.php" hash="cfa24a5d95416a3ca07406ee3a3a2703"/><dir name="Shipment"><file name="Address.php" hash="5e027a153566768b638a444cdf23f63c"/><file name="Parcel.php" hash="c739d558e2701f19104e1774d74fd68f"/></dir><file name="Shipment.php" hash="15b89fb358f1feea203f1afe0cebc996"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Country.php" hash="5e2e353feeddf2c767c12f7a3409689e"/><file name="Labelsize.php" hash="2beaad42e6e8f2a79ec6d0d7e15c752a"/><dir name="Payment"><file name="Shippingmethods.php" hash="cd31b98704fed4c33d2529a3689634fe"/></dir><file name="Product.php" hash="069126b5ca1874c6daf8335af2720a79"/><file name="Service.php" hash="9c92af191394c848387e32a8a65a4b25"/></dir></dir></dir></dir><dir name="config"><file name="combinations.php" hash="1191f3835ce1f07a2e19321324debd10"/><file name="countries.php" hash="c2662d70b50f3ef58775f5f043eb081a"/><file name="products.php" hash="3aec24a4a21d715df3cb15384eaef141"/><file name="services.php" hash="e72398afc6ca4b59b76392613f53d11d"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Gls"><file name="ShipmentController.php" hash="08493efd89ff0c6d4ff7eed91be8e9f3"/></dir></dir><file name="FrontendController.php" hash="a82a55cb65c2bd61dd6127e429f3ea0c"/></dir><dir name="data"><dir name="synergeticagency_gls_setup"><file name="data-install-0.1.0.php" hash="aeb81a59338eb10de8e8e12393821e46"/><file name="data-upgrade-0.1.0-0.1.1.php" hash="1e38465f87e4555abaadb59d8774faf6"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="046fb0feb6b47eb742f9c28a911d804f"/><file name="config.xml" hash="ffb98fbfdafef7e73298179749ad4757"/><file name="system.xml" hash="6bbd656829b8a487e852990173d62d74"/></dir><dir name="sql"><dir name="synergeticagency_gls_setup"><file name="install-0.1.0.php" hash="7e69be89f64cb3c841a9ace948a652d2"/><file name="upgrade-0.1.0-0.1.1.php" hash="7a58bfa3872c6e2d7fadae09179278ea"/><file name="upgrade-0.1.1-0.1.2.php" hash="e497ce202e932f95c8a7413fcfd5b791"/><file name="upgrade-0.1.2-0.1.3.php" hash="af5276700bf147971111d9feb8b751f1"/><file name="upgrade-0.1.3-0.1.4.php" hash="5021f44b21fb44f7bb193e92a20d584e"/><file name="upgrade-0.1.4-0.1.5.php" hash="95f12fb87ee236b9943fde5dc189dff0"/><file name="upgrade-0.1.5-0.1.6.php" hash="44fee4ba161db67a37729e498d5bb440"/><file name="upgrade-0.1.6-0.1.7.php" hash="133605d2298bdab5f04bce6aab395d68"/><file name="upgrade-0.2.0-0.2.1.php" hash="d6810125a8567c0ef45b06547c18b985"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><dir name="synergeticagency"><file name="gls.xml" hash="6afd9de85405f93be8843e4bf9153d97"/></dir></dir><dir name="template"><dir name="gls"><dir name="sales"><dir name="order"><dir name="address"><dir name="form"><dir name="attr"><file name="parcelshopid.phtml" hash="92aa59305e96a13cd64d272ed173da72"/></dir></dir></dir><dir name="shipment"><dir name="create"><dir name="gls"><file name="packages.phtml" hash="cd792e774d40db2fa5104608ef54b69a"/></dir><file name="gls.phtml" hash="279eaa2d0e7037b4ab7b2de394b5262d"/></dir><dir name="view"><file name="gls.phtml" hash="2846d470ed6eddcd64dff4f7138db5c7"/></dir></dir></dir></dir><dir name="shipment"><file name="edit.phtml" hash="337d714acc64c64c8aa579e20770985f"/></dir><dir name="system"><dir name="config"><file name="note.phtml" hash="a11fb5e7c72366a16c5618c560a152e3"/></dir><dir name="shipping"><file name="gls_applicable_country.phtml" hash="d664e96a471211cf549d876c33211d88"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="synergeticagency"><file name="gls.xml" hash="c467b4ac1ce8da629f478872b453ed32"/></dir></dir><dir name="template"><dir name="gls"><dir name="checkout"><dir name="onepage"><file name="billing_form_additional_parcelshop.phtml" hash="54fb0c007573d1354aeb74040328d67f"/><dir name="parcelshop"><file name="map.phtml" hash="a37985a1162cb40411933f697ec9efd9"/></dir><file name="shipping.phtml" hash="c706d0e8f4a17848e18ecd7e02303edc"/><file name="shipping_parcelshop.phtml" hash="545b904931d20a047cda48dc3d0a0442"/></dir></dir><dir name="form"><file name="glscashondelivery.phtml" hash="fe641f6afe8234f1b4dd85d63c694491"/></dir><file name="logoJs.phtml" hash="44b47e92ddd06e0fbc4c0d854562ca42"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="SynergeticAgency_Gls.xml" hash="72ff227686c41d266f3ed18e2f91cc4a"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="SynergeticAgency_Gls.csv" hash="65061d39ddae8dadc7778fcfa4e0fe97"/></dir></dir></target><target name="mageweb"><dir name="js"><dir name="gls"><file name="admin.js" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="frontend.js" hash="0e3d9ddfd04850314e27db8056f5ec77"/></dir></dir></target><target name="magelib"><dir name="SynergeticAgency"><dir name="GlsConnector"><file name="Connector.php" hash="f9521143580953b482ce07bd893a963f"/><dir name="Log"><file name="README.TXT" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><file name="Log.php" hash="97bc6de9dc722d1a307b3925ea1a7035"/><dir name="Model"><file name="Address.php" hash="c7bf0afaabbd26e3bfa2348fd9ca63b4"/><file name="Error.php" hash="da50fd629c8e16565aa92d98a3b3ef1f"/><file name="Info.php" hash="7e479ae6c9f552cba9695f2d772b8bbf"/><file name="JsonConfig.php" hash="f77bd21973d025225782b808b8b46bc5"/><file name="Parcel.php" hash="1171e6366c35891727501ef71a2bdd29"/><file name="Service.php" hash="e8beafa1054f49cfda4e6c1ee92a625c"/><file name="Services.php" hash="82eda2f6f6d629b91d8f0dcc3671e7fa"/><file name="Shipment.php" hash="4a69d9082203e0994b46fa4cbf6f9e7d"/></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="gls"><file name="gls-logo.png" hash="ed21df35da7d08b0189c7b4a31e837b0"/><file name="logo_thumb.png" hash="1e4ba5cac17e639155c562c144d48cc6"/></dir></dir><file name="gls.css" hash="96f81b24658997ec162d0bc3dc787eae"/></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="gls"><file name="frontend.css" hash="93299ba580ca5729a907983bf576ccda"/></dir></dir><dir name="images"><dir name="gls"><dir name="logo"><dir name="de"><file name="express.png" hash="47e2a758ced26660de70333341911825"/><file name="foreigncountries.png" hash="7c507a078ca887d4e4be26916d776513"/><file name="standard.png" hash="47e2a758ced26660de70333341911825"/><file name="thinkgreen.png" hash="fb5d79124a0873e57b2ab0f6dcf1810f"/></dir><dir name="default"><file name="express.png" hash="fb5d79124a0873e57b2ab0f6dcf1810f"/><file name="foreigncountries.png" hash="47e2a758ced26660de70333341911825"/><file name="standard.png" hash="47e2a758ced26660de70333341911825"/><file name="thinkgreen.png" hash="47e2a758ced26660de70333341911825"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="var"><dir name="import"><dir name="gls"><dir name="json"><file name="glsconfig.json.sample" hash="0aa187478b898b69ea327f4741bbddd8"/></dir></dir></dir></dir></target></contents>
43
+ <compatible/>
44
+ <dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies>
45
+ </package>
skin/adminhtml/base/default/gls.css ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ #gls-selector legend {
3
+ font-weight: bold;
4
+ height: auto;
5
+ line-height: 16px;
6
+ overflow: visible;
7
+ visibility: visible;
8
+ width: auto;
9
+ }
skin/adminhtml/base/default/images/gls/gls-logo.png ADDED
Binary file
skin/adminhtml/base/default/images/gls/logo_thumb.png ADDED
Binary file
skin/frontend/base/default/css/gls/frontend.css ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #gls-parcel-shop-information {
2
+ padding:2%;
3
+ background:#f4f4f4;
4
+ width: 365px;
5
+ margin-bottom:5px;
6
+ }
7
+ #gls-parcel-shop-information:after {
8
+ content: ".";
9
+ clear: both;
10
+ display: block;
11
+ visibility: hidden;
12
+ height: 0px;
13
+ }
14
+
15
+ #gls-parcel-shop-information .gls-label {
16
+ float:left;
17
+ width:30%;
18
+ }
19
+ #gls-parcel-shop-information .gls-value {
20
+ float:left;
21
+ width:70%;
22
+ }
23
+ #gls-parcel-shop-information .gls-label.name {
24
+ font-weight:bold;
25
+ width:100%;
26
+ }
27
+ #gls-parcel-shop-information .gls-value.name {
28
+ margin-bottom: 10px;
29
+ padding-bottom: 5px;
30
+ border-bottom: 1px solid #cccccc;
31
+ width:100%;
32
+ }
skin/frontend/base/default/images/gls/logo/de/express.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/de/foreigncountries.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/de/standard.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/de/thinkgreen.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/default/express.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/default/foreigncountries.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/default/standard.png ADDED
Binary file
skin/frontend/base/default/images/gls/logo/default/thinkgreen.png ADDED
Binary file
var/import/gls/json/glsconfig.json.sample ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "DE": {
3
+ "domestic": {
4
+ "maxweight": 40,
5
+ "cashservice": true,
6
+ "cashmax": 2500,
7
+ "cashcurrency": "EUR",
8
+ "parcelshop": true,
9
+ "parcelshopweight": 40
10
+ },
11
+ "foreign": {
12
+ "countries": {
13
+ "AT": {
14
+ "maxweight": 50,
15
+ "parcelshop": true,
16
+ "parcelshopweight": 50
17
+ },
18
+ "BE": {
19
+ "maxweight": 50,
20
+ "parcelshop": true,
21
+ "parcelshopweight": 50
22
+ },
23
+ "PL": {
24
+ "maxweight": 50,
25
+ "parcelshop": true,
26
+ "parcelshopweight": 50
27
+ },
28
+ "DK": {
29
+ "maxweight": 50,
30
+ "parcelshop": true,
31
+ "parcelshopweight": 20
32
+ }
33
+ }
34
+ }
35
+ },
36
+ "DK": {
37
+ "domestic": {
38
+ "maxweight": 30,
39
+ "cashservice": true,
40
+ "cashmax": 5500,
41
+ "cashcurrency": "DKK",
42
+ "parcelshop": true,
43
+ "parcelshopweight": 20
44
+ },
45
+ "foreign": {
46
+ "countries": {
47
+ "AT": {
48
+ "maxweight": 50,
49
+ "parcelshop": true,
50
+ "parcelshopweight": 50
51
+ },
52
+ "BE": {
53
+ "maxweight": 50,
54
+ "parcelshop": false,
55
+ "parcelshopweight": 0
56
+ },
57
+ "PL": {
58
+ "maxweight": 50,
59
+ "parcelshop": true,
60
+ "parcelshopweight": 50
61
+ },
62
+ "DE": {
63
+ "maxweight": 50,
64
+ "parcelshop": true,
65
+ "parcelshopweight": 50
66
+ }
67
+ }
68
+ }
69
+ },
70
+ "FI": {
71
+ "domestic": {
72
+ "maxweight": 50,
73
+ "cashservice": false,
74
+ "cashmax": 0,
75
+ "cashcurrency": "",
76
+ "parcelshop": false,
77
+ "parcelshopweight": 0
78
+ },
79
+ "foreign": {
80
+ "countries": {
81
+ "DK": {
82
+ "maxweight": 50,
83
+ "parcelshop": false,
84
+ "parcelshopweight": 0
85
+ }
86
+ }
87
+ }
88
+ }
89
+ }