Eabi_DpdEE - Version 0.1.5

Version Notes

* Packing slip displays Pakipood address at the packing slip instead of customers address
* Courier call in menu displays available times now properly.

Download this release

Release Info

Developer Matis Matis
Extension Eabi_DpdEE
Version 0.1.5
Comparing to
See all releases


Version 0.1.5

Files changed (67) hide show
  1. app/code/community/Eabi/DpdEE/Block/Adminhtml/Config/Form/Field/Country.php +191 -0
  2. app/code/community/Eabi/DpdEE/Block/Order/Courier.php +243 -0
  3. app/code/community/Eabi/DpdEE/CHANGELOG.txt +3 -0
  4. app/code/community/Eabi/DpdEE/Helper/Data.php +190 -0
  5. app/code/community/Eabi/DpdEE/LICENCE.txt +1 -0
  6. app/code/community/Eabi/DpdEE/Model/Action/Carrier/Order/Courier.php +284 -0
  7. app/code/community/Eabi/DpdEE/Model/Api.php +209 -0
  8. app/code/community/Eabi/DpdEE/Model/Button/Courier.php +339 -0
  9. app/code/community/Eabi/DpdEE/Model/Config.php +44 -0
  10. app/code/community/Eabi/DpdEE/Model/Flat.php +216 -0
  11. app/code/community/Eabi/DpdEE/Model/Observer.php +119 -0
  12. app/code/community/Eabi/DpdEE/Model/Post.php +536 -0
  13. app/code/community/Eabi/DpdEE/Model/Source/Label/Position.php +70 -0
  14. app/code/community/Eabi/DpdEE/Model/Source/Service.php +72 -0
  15. app/code/community/Eabi/DpdEE/etc/config.xml +211 -0
  16. app/code/community/Eabi/DpdEE/etc/system.xml +690 -0
  17. app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-install-0.1.0.php +50 -0
  18. app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.0-0.1.1.php +50 -0
  19. app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.1-0.1.2.php +51 -0
  20. app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.2-0.1.3.php +66 -0
  21. app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.3-0.1.4.php +80 -0
  22. app/code/community/Eabi/Postoffice/Block/Adminhtml/Config/Form/Field/Remove.php +104 -0
  23. app/code/community/Eabi/Postoffice/Block/Config/Rebuildbutton.php +121 -0
  24. app/code/community/Eabi/Postoffice/Helper/Countrycode.php +389 -0
  25. app/code/community/Eabi/Postoffice/Helper/Data.php +489 -0
  26. app/code/community/Eabi/Postoffice/Model/Carrier/Abstract.php +1016 -0
  27. app/code/community/Eabi/Postoffice/Model/Carrier/Result.php +45 -0
  28. app/code/community/Eabi/Postoffice/Model/Carriermodule.php +210 -0
  29. app/code/community/Eabi/Postoffice/Model/Mysql4/Carriermodule.php +45 -0
  30. app/code/community/Eabi/Postoffice/Model/Mysql4/Carriermodule/Collection.php +44 -0
  31. app/code/community/Eabi/Postoffice/Model/Mysql4/Office.php +45 -0
  32. app/code/community/Eabi/Postoffice/Model/Mysql4/Office/Collection.php +44 -0
  33. app/code/community/Eabi/Postoffice/Model/Office.php +152 -0
  34. app/code/community/Eabi/Postoffice/Model/Orderview.php +130 -0
  35. app/code/community/Eabi/Postoffice/Model/Source/Sendevent.php +61 -0
  36. app/code/community/Eabi/Postoffice/Model/Updater.php +63 -0
  37. app/code/community/Eabi/Postoffice/controllers/Adminhtml/PostofficeController.php +342 -0
  38. app/code/community/Eabi/Postoffice/controllers/IndexController.php +177 -0
  39. app/code/community/Eabi/Postoffice/etc/config.xml +233 -0
  40. app/code/community/Eabi/Postoffice/sql/eabi_postoffice_setup/mysql4-install-0.1.0.php +116 -0
  41. app/code/community/Eabi/Postoffice/sql/eabi_postoffice_setup/mysql4-upgrade-0.1.0-0.1.1.php +51 -0
  42. app/code/community/Eabi/Postoffice/sql/eabi_postoffice_setup/mysql4-upgrade-0.1.1-0.1.2.php +49 -0
  43. app/design/adminhtml/default/default/layout/eabi_dpdee.xml +14 -0
  44. app/design/adminhtml/default/default/layout/eabi_postoffice.xml +81 -0
  45. app/design/adminhtml/default/default/template/eabi_dpdee/order/courier.phtml +38 -0
  46. app/design/adminhtml/default/default/template/eabi_postoffice/shipping_method_form.phtml +109 -0
  47. app/design/frontend/base/default/layout/eabi_dpdee.xml +4 -0
  48. app/design/frontend/base/default/layout/eabi_postoffice.xml +79 -0
  49. app/design/frontend/base/default/template/eabi_postoffice/available.phtml +107 -0
  50. app/design/frontend/base/default/template/eabi_postoffice/multishipping.phtml +136 -0
  51. app/design/frontend/base/default/template/eabi_postoffice/shipping.phtml +145 -0
  52. app/design/frontend/base/default/template/eabi_postoffice/tracking/popup.phtml +183 -0
  53. app/etc/modules/Eabi_DpdEE.xml +45 -0
  54. app/etc/modules/Eabi_Postoffice.xml +48 -0
  55. app/locale/en_US/Eabi_DpdEE.csv +47 -0
  56. app/locale/en_US/Eabi_Postoffice.csv +42 -0
  57. app/locale/et_EE/Eabi_DpdEE.csv +46 -0
  58. app/locale/et_EE/Eabi_Postoffice.csv +42 -0
  59. app/locale/fi_FI/Eabi_Postoffice.csv +42 -0
  60. app/locale/hu_HU/Eabi_Postoffice.csv +42 -0
  61. app/locale/lt_LT/Eabi_Postoffice.csv +42 -0
  62. app/locale/ru_RU/Eabi_DpdEE.csv +46 -0
  63. app/locale/ru_RU/Eabi_Postoffice.csv +42 -0
  64. app/locale/sv_SE/Eabi_Postoffice.csv +48 -0
  65. js/eabi_js/eabi_dpdee.js +211 -0
  66. package.xml +28 -0
  67. skin/adminhtml/default/default/eabi_dpdee.css +61 -0
app/code/community/Eabi/DpdEE/Block/Adminhtml/Config/Form/Field/Country.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Displays list of countries at the shipping modules configuration field.</p>
36
+ * <p>Number of countries are unlimited and if more than one of the same country exist in the list, then last country declaration overrrides previous one.</p>
37
+ * <p>Each country declaration contains following:</p>
38
+ * <ul>
39
+ <li>Base shipping price</li>
40
+ <li>Additional price for each Kilogram. (data is taken from products weight field)</li>
41
+ <li>Free shipping starts from price (Without VAT). Free shipping is disabled when this field is left empty.</li>
42
+ </ul>
43
+ *
44
+ * @author Matis
45
+ */
46
+ class Eabi_DpdEE_Block_Adminhtml_Config_Form_Field_Country extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
47
+
48
+ public function __construct() {
49
+
50
+ $this->addColumn('country_id', array(
51
+ 'label' => $this->_getDpdHelper()->__('Country'),
52
+ 'style' => 'width:120px',
53
+ 'type' => 'select',
54
+ 'source_model' => 'adminhtml/system_config_source_country',
55
+ /* 'class' => 'validate-code',*/
56
+ ));
57
+ $this->addColumn('base_price', array(
58
+ 'label' => $this->_getDpdHelper()->__('Base shipping price'),
59
+ 'style' => 'width:120px',
60
+ 'class' => 'validate-number',
61
+ ));
62
+ $this->addColumn('kg_price', array(
63
+ 'label' => $this->_getDpdHelper()->__('Price per additional 10kg over base 10kg'),
64
+ 'style' => 'width:120px',
65
+ 'class' => 'validate-number',
66
+ ));
67
+ $this->addColumn('free_shipping_from', array(
68
+ 'label' => $this->_getDpdHelper()->__('Free shipping from price'),
69
+ 'style' => 'width:120px',
70
+ ));
71
+ $this->_addAfter = false;
72
+ $this->_addButtonLabel = $this->_getDpdHelper()->__('Add shipping country');
73
+ parent::__construct();
74
+
75
+ }
76
+
77
+
78
+
79
+ /**
80
+ * Add a column to array-grid
81
+ *
82
+ * @param string $name
83
+ * @param array $params
84
+ */
85
+ public function addColumn($name, $params) {
86
+ $this->_columns[$name] = array(
87
+ 'label' => empty($params['label']) ? 'Column' : $params['label'],
88
+ 'size' => empty($params['size']) ? false : $params['size'],
89
+ 'style' => empty($params['style']) ? null : $params['style'],
90
+ 'class' => empty($params['class']) ? null : $params['class'],
91
+ 'type' => empty($params['type']) ? null : $params['type'],
92
+ 'source_model' => empty($params['source_model']) ? null : $params['source_model'],
93
+ 'renderer' => false,
94
+ );
95
+ if ((!empty($params['renderer'])) && ($params['renderer'] instanceof Mage_Core_Block_Abstract)) {
96
+ $this->_columns[$name]['renderer'] = $params['renderer'];
97
+ }
98
+ }
99
+
100
+
101
+
102
+ /**
103
+ * Since select menus are not supported and renderer does not work when single quotes are included in the select value list
104
+ * then we need to override this method to support select dropdowns
105
+ *
106
+ * @param string $columnName
107
+ * @return string
108
+ */
109
+ protected function _renderCellTemplate($columnName) {
110
+ if (empty($this->_columns[$columnName])) {
111
+ throw new Exception('Wrong column name specified.');
112
+ }
113
+ $column = $this->_columns[$columnName];
114
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
115
+
116
+ if ($column['renderer']) {
117
+ return $column['renderer']->setInputName($inputName)->setColumnName($columnName)->setColumn($column)
118
+ ->toHtml();
119
+ }
120
+
121
+ if (isset($column['type']) && $column['type']) {
122
+ if ($column['type'] == 'select') {
123
+ $html = '<select name="' . $inputName . '" value="#{' . $columnName . '}" ' .
124
+ ($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
125
+ (isset($column['class']) ? $column['class'] : 'input-text') . '"' .
126
+ (isset($column['style']) ? ' style="' . $column['style'] . '"' : '') . '/>';
127
+
128
+ $options = Mage::getModel($column['source_model'])->toOptionArray();
129
+ foreach ($options as $option) {
130
+ $html .= '<option value="' . htmlspecialchars($option['value']);
131
+ $html .= '" ';
132
+ $html .= '>';
133
+ $html .= htmlspecialchars($option['label'], ENT_QUOTES, 'UTF-8');
134
+ $html .= '</option>';
135
+ }
136
+ $html .= '</select>';
137
+
138
+
139
+ return $html;
140
+ }
141
+ }
142
+
143
+ return '<input type="text" name="' . $inputName . '" value="#{' . $columnName . '}" ' .
144
+ ($column['size'] ? 'size="' . $column['size'] . '"' : '') . ' class="' .
145
+ (isset($column['class']) ? $column['class'] : 'input-text') . '"'.
146
+ (isset($column['style']) ? ' style="'.$column['style'] . '"' : '') . '/>';
147
+ }
148
+
149
+
150
+
151
+ /**
152
+ * Because JS Prototype Template engine does not support html select value updates, then we need to override
153
+ * toHtml method in order to set select values manually after page load.
154
+ *
155
+ * @return string
156
+ */
157
+ protected function _toHtml() {
158
+ $this->setHtmlId('_'. uniqid());
159
+ if (!$this->_isPreparedToRender) {
160
+ $this->_prepareToRender();
161
+ $this->_isPreparedToRender = true;
162
+ }
163
+ if (empty($this->_columns)) {
164
+ throw new Exception('At least one column must be defined.');
165
+ }
166
+ return parent::_toHtml().<<<JS
167
+ <script type="text/javascript">
168
+ // <![CDATA[
169
+ document.observe('dom:loaded', function() {
170
+ $$('#grid{$this->getHtmlId()} select').each(function(iterator) {
171
+ iterator.setValue(iterator.readAttribute('value'));
172
+ });
173
+ });
174
+ // ]]>
175
+ </script>
176
+ JS;
177
+ }
178
+
179
+
180
+
181
+
182
+ /**
183
+ *
184
+ * @return Eabi_DpdEE_Helper_Data
185
+ */
186
+ protected function _getDpdHelper() {
187
+ return Mage::helper('eabi_dpdee');
188
+ }
189
+
190
+
191
+ }
app/code/community/Eabi/DpdEE/Block/Order/Courier.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Renders HTML block which allows to call DPD courier to pick up shipment.</p>
36
+ * <p>Template is located at <b>eabi_dpdee/order/courier.phtml</b> in adminhtml theme folder</p>
37
+ * <p>Information that can be sent to courier:</p>
38
+ * <ul>
39
+ <li>Merchant can pick suitable date from available list when courier should come</li>
40
+ <li>Merchant can pick suitable time-range from available list for the selected date</li>
41
+ <li>Merchant can specify how many envelopes, parcels, pallets should be picked up</li>
42
+ <li>Merchant can leave comment for the courier</li>
43
+ <li>By default one checked order equals one parcel</li>
44
+ </ul>
45
+ *
46
+ * @author Matis
47
+ */
48
+ class Eabi_DpdEE_Block_Order_Courier extends Mage_Core_Block_Template {
49
+ protected $_dateFormat = 'yyyy-MM-dd';
50
+ protected $_timeFormat = 'HHmm';
51
+ protected $_timeFormatNice = 'HH:mm';
52
+
53
+ protected $_availableDates;
54
+ protected $_apiResult;
55
+
56
+ public function _construct() {
57
+ $this->setTemplate('eabi_dpdee/order/courier.phtml');
58
+ parent::_construct();
59
+ }
60
+
61
+ public function getHtmlId() {
62
+ return 'eabi_carrier_order_courier_box';
63
+ }
64
+
65
+
66
+
67
+
68
+
69
+ /**
70
+ * <p>Fetches list of available pickup dates from DPD server and returns it as HTML select string</p>
71
+ * @return string
72
+ */
73
+ public function getAvailableDates() {
74
+ if ($this->_availableDates) {
75
+ return $this->_availableDates;
76
+ }
77
+ $showOnlyDates = false;
78
+ $datesResult = $this->_getDpdHelper()->getApi($this->getStoreId(), $this->getCode())->getCourierCollectionTimes();
79
+ $this->_apiResult = $datesResult;
80
+ $dateObj = null;
81
+
82
+ $resultString = '';
83
+ // $resultString .= '<pre>'.htmlspecialchars(print_r($datesResult, true)).'</pre>';
84
+ $resultString .= '<select name="Po_Date" id="Po_date" onchange="updateDpdEeTimes(this);">';
85
+ $resultString .= '<option value="-">'.$this->_getDpdHelper()->__(' - select pickup date - ').'</option>';
86
+
87
+ foreach ($datesResult['Po_date'] as $dateString) {
88
+ if (is_null($dateObj)) {
89
+ $dateObj = new Zend_Date($dateString, $this->_dateFormat);
90
+ }
91
+ $dateObj->set($dateString, $this->_dateFormat);
92
+ if ($dateObj->isToday() && !$showOnlyDates) {
93
+ //today
94
+ $resultString .= $this->_getDateInputLabel($this->_getDpdHelper()->__('Today'), $dateString);
95
+ } else if ($dateObj->isTomorrow() && !$showOnlyDates) {
96
+ //tomorrow
97
+ $resultString .= $this->_getDateInputLabel($this->_getDpdHelper()->__('Tomorrow'), $dateString);
98
+ } else {
99
+ //other dates
100
+ $resultString .= $this->_getDateInputLabel($dateString, $dateString);
101
+ }
102
+ }
103
+ $resultString .= '</select>';
104
+
105
+ //do availabletimes as well
106
+ $this->_availableDates = $resultString;
107
+ return $this->_availableDates;
108
+ }
109
+
110
+
111
+ /**
112
+ * <p>Fetches available pickup times from DPD server and returns it as json encoded object</p>
113
+ * <p>Format:</p>
114
+ * <pre>
115
+ * array(
116
+ * '2013-12-24' => 'html select menu with available time ranges',
117
+ * '2013-12-25' => 'html select menu with available time ranges',
118
+ * ....
119
+ * );
120
+ * </pre>
121
+ * @return string
122
+ */
123
+ public function getAvailabeTimes() {
124
+ if (!$this->_apiResult) {
125
+ $this->getAvailableDates();
126
+ }
127
+ $availableTimes = array();
128
+ $timeDateObject = null;
129
+ //array key is date, content is html with select menu
130
+ $availableTimes["-"] = $this->_getDpdHelper()->__('Select pickup date first');
131
+ foreach ($this->_apiResult['Po_date'] as $key => $dateString) {
132
+ $timeFrom = $this->_normalizeTime($this->_apiResult['Po_time_from'][$key]);
133
+ $timeTo = $this->_normalizeTime($this->_apiResult['Po_time_til'][$key]);
134
+ $timeWindow = $this->_normalizeTime($this->_apiResult['Minimal_time_window'][$key]);
135
+ $availableTimes[$dateString] = $this->_getTimeSelectMenu($timeFrom, $timeTo, $timeWindow);
136
+ }
137
+ return json_encode($availableTimes);
138
+ }
139
+
140
+ /**
141
+ * <p>Normalizes DPD times to Zend_Date objects.</p>
142
+ * <p>For example 930 should be displayed as 09:30 and 9 should be displayed as 09:00</p>
143
+ * @param string $input
144
+ * @return Zend_Date
145
+ */
146
+ protected function _normalizeTime($input) {
147
+ if (strlen($input) === 1) {
148
+ $input = '0'.$input .'00';
149
+ }
150
+ if (strlen($input) === 2) {
151
+ $input = $input .'00';
152
+ }
153
+ if (strlen($input) === 3) {
154
+ $input = '0'.$input;
155
+ }
156
+ $date = new Zend_Date($input, $this->_timeFormat);
157
+ $date->setTimezone('ETC/GMT+0');
158
+ return $date;
159
+ }
160
+
161
+
162
+ /**
163
+ * <p>Takes earliest possible time, latest possible time, minimum allowed timewindow and renders it into one select menu with pickup time ranges.</p>
164
+ * <p>All arguments have to be within same date.</p>
165
+ * <p>Pickup time ranges are always displayed within narrowest possible timewindow.</p>
166
+ * @param Zend_Date $timeFrom earliest time possible
167
+ * @param Zend_Date $timeTo latest time possible
168
+ * @param Zend_Date $timeWindow minimal allowed time between start and end time.
169
+ * @return string HTML select menu
170
+ */
171
+ protected function _getTimeSelectMenu(Zend_Date $timeFrom, Zend_Date $timeTo, Zend_Date $timeWindow) {
172
+ $position = $timeFrom->get('H');
173
+ $result = '<select name="Po_Time" id="Po_Time">';
174
+ do {
175
+ $endTime = clone $timeFrom;
176
+ $endTime->add($timeWindow);
177
+ if ($timeTo->isEarlier($endTime)) {
178
+ $timeDisplay = htmlspecialchars(ltrim($timeFrom->get($this->_timeFormat), '0') . '-' . ltrim($timeTo->get($this->_timeFormat), '0'));
179
+ $timeDisplayNice = htmlspecialchars($timeFrom->get($this->_timeFormatNice) . '-' . $timeTo->get($this->_timeFormatNice));
180
+ } else {
181
+ $timeDisplay = htmlspecialchars(ltrim($timeFrom->get($this->_timeFormat), '0') . '-' . ltrim($endTime->get($this->_timeFormat), '0'));
182
+ $timeDisplayNice = htmlspecialchars($timeFrom->get($this->_timeFormatNice) . '-' . $endTime->get($this->_timeFormatNice));
183
+ }
184
+ $result .= '<option value="' . $timeDisplay . '">' . $timeDisplayNice . '</option>';
185
+ $timeFrom->setTimestamp($timeFrom->getTimestamp() + 60 * 60);
186
+ } while ($timeFrom->get(Zend_Date::HOUR_SHORT) + $timeWindow->get(Zend_Date::HOUR_SHORT) <= $timeTo->get(Zend_Date::HOUR_SHORT));
187
+ $result .= '</select>';
188
+ return $result;
189
+ }
190
+
191
+ protected function _getDateInputLabel($label, $value) {
192
+ return '<option value="'. htmlspecialchars($value).'" >'. htmlspecialchars($label).'</option>';
193
+ }
194
+
195
+ /**
196
+ * <p>Returns shipping method code that this courier HTML block is used by.</p>
197
+ * @return string
198
+ */
199
+ public function getCode() {
200
+ if (!$this->getData('code')) {
201
+ return 'eabidpdee';
202
+ }
203
+ return $this->getData('code');
204
+ }
205
+
206
+ /**
207
+ * <p>Returns default envelope quantity</p>
208
+ * @return string
209
+ */
210
+ public function getEnvelopeQty() {
211
+ return '0';
212
+ }
213
+
214
+
215
+ /**
216
+ * <p>Returns default parcel quantity</p>
217
+ * @return string
218
+ */
219
+ public function getParcelQty() {
220
+ return '1';
221
+
222
+ }
223
+
224
+
225
+ /**
226
+ * <p>Returns default pallet quantity</p>
227
+ * @return string
228
+ */
229
+ public function getPalletQty() {
230
+ return '0';
231
+
232
+ }
233
+
234
+ /**
235
+ *
236
+ * @return Eabi_DpdEE_Helper_Data
237
+ */
238
+ protected function _getDpdHelper() {
239
+ return Mage::helper('eabi_dpdee');
240
+ }
241
+
242
+
243
+ }
app/code/community/Eabi/DpdEE/CHANGELOG.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ 0.1.1
2
+ - Initial release
3
+
app/code/community/Eabi/DpdEE/Helper/Data.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Helper class for DPD shipping method related actions</p>
36
+ *
37
+ * @author Matis Halmann
38
+ */
39
+ class Eabi_DpdEE_Helper_Data extends Mage_Core_Helper_Abstract {
40
+ protected $_apis = array();
41
+
42
+ /**
43
+ * <p>Gets cached DPD API instance for specified Magento store id and shipping method code.</p>
44
+ * @param string $storeId store id to fetch the api for
45
+ * @param string $code shipping method code to fetch the api for
46
+ * @return Eabi_DpdEE_Model_Api
47
+ */
48
+ public function getApi($storeId = null, $code = 'eabidpdee') {
49
+ if ($storeId === null) {
50
+ $storeId = Mage::app()->getStore($storeId)->getId();
51
+ }
52
+ if (isset($this->_apis[$code]) && isset($this->_apis[$code][$storeId])) {
53
+ return $this->_apis[$code][$storeId];
54
+ }
55
+ if (!isset($this->_apis[$code])) {
56
+ $this->_apis[$code] = array();
57
+ }
58
+ $api = Mage::getModel('eabi_dpdee/api');
59
+ $api->setStore($storeId);
60
+ $api->setCode($code);
61
+ $this->_apis[$code][$storeId] = $api;
62
+ return $this->_apis[$code][$storeId];
63
+ }
64
+
65
+
66
+ /**
67
+ * Returns true if shipping method used in the order belongs to DPD carrier
68
+ * @param Mage_Sales_Model_Order $order
69
+ */
70
+ public function isShippingMethodApplicable(Mage_Sales_Model_Order $order) {
71
+ return strpos($order->getShippingMethod(), 'eabidpdee') === 0;
72
+ }
73
+
74
+
75
+
76
+ /**
77
+ * <p>Converts DPD op=pudo Opening Times into human readable format.</p>
78
+ * <ul>
79
+ <li><b>Input: 1:11:0:16:0,2:7:30:20:0,3:7:30:20:0,4:7:30:20:0,5:7:30:20:0,6:7:30:20:0,7:8:0:16:0</b></li>
80
+ <li><b>Result: (E-R 7:30-20; L 8-16; P 11-16)</b></li>
81
+ </ul>
82
+ *
83
+ * @param string $dpdOpeningDescription DPD Openings description
84
+ * @param Zend_Locale $locale Locale which is used to print out weekday names
85
+ * @return string
86
+ */
87
+ public function getOpeningsDescriptionFromTerminal($dpdOpeningDescription, $locale = null) {
88
+ $openingTimeFormat = 'H:m';
89
+ $displayTimeFormat = 'H:mm';
90
+
91
+ if (!$locale) {
92
+ $locale = Mage::app()->getLocale()->getLocaleCode();
93
+ }
94
+
95
+ //days start from monday
96
+ $passThruOrder = array('2', '3', '4', '5', '6', '7', '1');
97
+
98
+ /*
99
+ * Format: array key = weekday name
100
+ */
101
+ $openingDescriptions = array();
102
+
103
+ //we need these in order to get times in normalized manner
104
+ $startTime = new Zend_Date(0, Zend_Date::TIMESTAMP);
105
+ $endTime = new Zend_Date(0, Zend_Date::TIMESTAMP);
106
+
107
+ //here are comma separeted opening times
108
+ $openings = explode(',', $dpdOpeningDescription);
109
+ /*
110
+ * Format:
111
+ * <weekday>:<starth>:<startm>:<endh>:<endm>
112
+ * 1=sunday
113
+ * 2=monday
114
+ * ...
115
+ * 7=saturday
116
+ *
117
+ */
118
+ foreach ($openings as $opening) {
119
+ $openTimePartials = explode(':', $opening);
120
+ $startTime->set($openTimePartials[1].':'.$openTimePartials[2], $openingTimeFormat);
121
+ $endTime->set($openTimePartials[3].':'.$openTimePartials[4], $openingTimeFormat);
122
+
123
+ if (!isset($openingDescriptions[(string)$openTimePartials[0]])) {
124
+ $openingDescriptions[(string)$openTimePartials[0]] = array();
125
+ }
126
+ $openingDescriptions[(string)$openTimePartials[0]][] = str_replace(':00', '', $startTime->get($displayTimeFormat)) .'-'. str_replace(':00', '', $endTime->get($displayTimeFormat));
127
+
128
+ }
129
+
130
+
131
+ /*
132
+ * Format:
133
+ * array key = day of week digit
134
+ * array value = all opening times for that day separated by comma
135
+ */
136
+ $finalOpeningDescriptions = array();
137
+ $previusOpeningStatement = false;
138
+ $previusWeekdayName = false;
139
+ $firstElement = false;
140
+
141
+
142
+ foreach ($passThruOrder as $dayOfWeekDigit) {
143
+ $startTime->set($dayOfWeekDigit - 1, Zend_Date::WEEKDAY_DIGIT);
144
+
145
+ $weekDayName = $startTime->get(Zend_Date::WEEKDAY_NARROW, $locale);
146
+ if ($firstElement === false) {
147
+ $firstElement = $previusWeekdayName;
148
+ }
149
+ if (isset($openingDescriptions[$dayOfWeekDigit])) {
150
+
151
+ $openingStatement = str_replace('0-0', '0-24', implode(',', $openingDescriptions[$dayOfWeekDigit]));
152
+ } else {
153
+ $openingStatement = '';
154
+ }
155
+
156
+ if ($previusOpeningStatement !== false && $previusOpeningStatement != $openingStatement) {
157
+ //we have a change
158
+ if ($firstElement != $previusWeekdayName) {
159
+ $finalOpeningDescriptions[] = $firstElement.'-'.$previusWeekdayName.' '.$previusOpeningStatement;
160
+ } else {
161
+ $finalOpeningDescriptions[] = $previusWeekdayName.' '.$previusOpeningStatement;
162
+ }
163
+
164
+
165
+ $firstElement = false;
166
+ }
167
+ $previusOpeningStatement = $openingStatement;
168
+ $previusWeekdayName = $weekDayName;
169
+
170
+ }
171
+ if ($previusOpeningStatement !== false) {
172
+ if ($previusOpeningStatement !== '') {
173
+ //we have a change
174
+ if (!$firstElement) {
175
+ $finalOpeningDescriptions[] = $previusWeekdayName . ' ' . $previusOpeningStatement;
176
+ } else {
177
+ $finalOpeningDescriptions[] = $firstElement . '-' . $previusWeekdayName . ' ' . $previusOpeningStatement;
178
+ }
179
+ }
180
+ }
181
+
182
+ if (count($finalOpeningDescriptions)) {
183
+ return '('.implode('; ', $finalOpeningDescriptions).')';
184
+ }
185
+ return '';
186
+ }
187
+
188
+
189
+ }
190
+
app/code/community/Eabi/DpdEE/LICENCE.txt ADDED
@@ -0,0 +1 @@
 
1
+ http://opensource.org/licenses/osl-3.0.php
app/code/community/Eabi/DpdEE/Model/Action/Carrier/Order/Courier.php ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Renders button at the Magento Administrators Sales Order Grid, which allows to call DPD courier.</p>
35
+ * <p>Button is displayed when order shipping method is DPD and parcel data is sent to DPD server.</p>
36
+ *
37
+ * @see Eabi_DpdEE_Block_Order_Courier
38
+ * @author Matis
39
+ * @deprecated since version 0.1.4
40
+ */
41
+ class Eabi_DpdEE_Model_Action_Carrier_Order_Courier extends Eabi_Livehandler_Model_Action_Abstract {
42
+
43
+ /**
44
+ * <p>Unique code that identifies this button. Matches button name at Magento admin &gt; System &gt; Configuration &gt; Eabi Livehandler &gt; Admin Order Grid Helper configuration menu</p>
45
+ * @var string
46
+ */
47
+ protected $_code = 'eabi_dpdee__action_carrier_order_courier';
48
+
49
+ /**
50
+ * <p>Label displayed on this action button.</p>
51
+ * <p>Default: <b>Order courier to pick up goods</b></p>
52
+ * @var string
53
+ */
54
+ protected $_label;
55
+
56
+ public function __construct() {
57
+ $this->_label = Mage::helper('adminhtml')->__('Order courier to pick up goods');
58
+ /* @var $salesHelper Mage_Sales_Helper_Data */
59
+ $salesHelper = Mage::helper('sales');
60
+ $this->_longOnClick = <<<EOT
61
+
62
+ return eabi_dpdJsObject.submit();
63
+
64
+ EOT;
65
+
66
+
67
+ }
68
+
69
+
70
+
71
+
72
+ /**
73
+ * <p>From version 0.1.4 this button is never displayed</p>
74
+ * <p>Should display when:</p>
75
+ * <ul>
76
+ <li>Order is using DPD shipping method</li>
77
+ <li>Order is fully paid or payment method is COD</li>
78
+ <li>Courier pickup is allowed from the settings</li>
79
+ <li>Automatic data sending is allowed and data is sent to DPD server</li>
80
+ <li>Order has not yet been picked up by courier</li>
81
+ </ul>
82
+ * @param Mage_Sales_Model_Order $order
83
+ * @return bool
84
+ */
85
+ public function canDisplay(Mage_Sales_Model_Order $order) {
86
+ return false;
87
+ /* @var $shippingMethodModel Eabi_DpdEE_Model_Post */
88
+ $shippingMethodModel = null;
89
+ $res = $this->_getDpdHelper()->isShippingMethodApplicable($order) && $this->_getOfficeHelper()->canSendData($order, $shippingMethodModel)
90
+ && $shippingMethodModel->isDataSent($order);
91
+ if ($res) {
92
+ if ($shippingMethodModel->isPickedUpByCourier($order) !== false) {
93
+ return false;
94
+ }
95
+
96
+ $dpdBlock = Mage::getSingleton('core/layout')
97
+ ->createBlock('eabi_dpdee/order_courier')
98
+ ->setCode('eabidpdee')
99
+ ->setStoreId($order->getStore()->getId())
100
+ ;
101
+
102
+ $this->_onClick = <<<EOT
103
+ if (typeof(eabi_dpdJsObject) === 'undefined') {
104
+ eabi_dpdJsObject = new EabiDpdEE('eabi_{$this->_code}', null, null, null, function(endResult) { if (!endResult['Po_Date'] || endResult['Po_Date'] == '-') { return false; } return endResult; });
105
+ }
106
+ eabi_dpdJsObject.update({$this->_toJson($dpdBlock->toHtml())}, {$this->_toJson($order->getId())}, sales_order_grid_massactionJsObject);
107
+ EOT;
108
+ }
109
+ return $res;
110
+ }
111
+
112
+ /**
113
+ *
114
+ * @return Eabi_DpdEE_Helper_Data
115
+ */
116
+ protected function _getDpdHelper() {
117
+ return Mage::helper('eabi_dpdee');
118
+ }
119
+ /**
120
+ *
121
+ * @return Eabi_Postoffice_Helper_Data
122
+ */
123
+ protected function _getOfficeHelper() {
124
+ return Mage::helper('eabi_postoffice');
125
+ }
126
+
127
+
128
+ /**
129
+ * <p>Sends courier call pickup goods action to DPD server and returns information about its status.</p>
130
+ * <p>Available POST params:</p>
131
+ * <ul>
132
+ <li><b>order_ids</b> - comma separated list of Magento Order IDs on which courier pickup call should be executed.</li>
133
+ <li><b>Po_remark</b> - Note to sent to courier</li>
134
+ <li><b>Po_Date</b> - Date when courier should pick up goods. Format: YYYY-MM-DD</li>
135
+ <li><b>Po_Time</b> - Time range when courier should pick up goods. Format: HMM-HMM (timefrom-timetill)</li>
136
+ <li><b>Po_envelope_qty</b> - Number of envelopes courier should pick up</li>
137
+ <li><b>Po_parcel_qty</b> - Number of parcels courier should pick up</li>
138
+ <li><b>Po_pallet_qty</b> - Number of pallets courier should pick up</li>
139
+ </ul>
140
+ * <p>If supplied orders are not applicable for DPD courier call, then exception is thrown.</p>
141
+ * @param Mage_Sales_Model_Order $order
142
+ * @param array $params assoc array of post params
143
+ * @return boolean|array
144
+ */
145
+ public function performDesiredAction(Mage_Sales_Model_Order $order, array $params) {
146
+ try {
147
+ $failedOrderIds = array();
148
+ //order_ids => comma separated list of orders
149
+ $orders = $this->_getOrders($params['order_ids']);
150
+
151
+ //validate if submitted orders can be called for courier.....
152
+ foreach ($orders as $testOrder) {
153
+ if (!$this->_isHandleableOrder($testOrder)) {
154
+ $failedOrderIds[] = $testOrder->getIncrementId();
155
+ }
156
+ }
157
+
158
+ //if not, then list the invalid ids with error message
159
+ if (count($failedOrderIds)) {
160
+ Mage::throwException($this->_getDpdHelper()->__('Courier cannot be called for orders %s', implode(', ', $failedOrderIds)));
161
+ }
162
+
163
+ $prefix = Eabi_DpdEE_Model_Post::ORDER_COMMENT_START_PREFIX;
164
+
165
+ //send the data
166
+ $api = $this->_getDpdHelper()->getApi($order->getStore()->getId());
167
+
168
+ $orderSendData = array(
169
+ 'Po_remark' => isset($params['Po_remark'])?$params['Po_remark']:'',
170
+ 'Po_type' => 'PO',
171
+ 'Po_Date' => $params['Po_Date'],
172
+ 'Po_Time_from' => $this->_getTimeFrom($params['Po_Time']),
173
+ 'Po_Time_til' => $this->_getTimeTil($params['Po_Time']),
174
+ 'Po_envelope_qty' => $params['Po_envelope_qty'],
175
+ 'Po_parcel_qty' => $params['Po_parcel_qty'],
176
+ 'Po_pallet_qty' => $params['Po_pallet_qty'],
177
+ 'Sh_envelope_qty' => $params['Po_envelope_qty'],
178
+ 'Sh_parcel_qty' => $params['Po_parcel_qty'],
179
+ 'Sh_pallet_qty' => $params['Po_pallet_qty'],
180
+ 'Sh_pudo' => 'false',
181
+ );
182
+
183
+ $orderSendResult = $api->autoSendData($orderSendData);
184
+
185
+ //if validation passed
186
+ foreach ($orders as $testOrder) {
187
+ //mark each order as courier called
188
+ $newOrderData = array(
189
+ 'courier_call_id' => $orderSendResult['DPD_OrderID'],
190
+ );
191
+ $this->_getOfficeHelper()->setDataToOrder($testOrder, $newOrderData, $prefix);
192
+
193
+ }
194
+ $courierArrivalDate = $orderSendData['Po_Date'];
195
+ $courierArrivalTime = $orderSendData['Po_Time_from'].' '.$this->_getDpdHelper()->__('and').' '.$orderSendData['Po_Time_til'];
196
+
197
+ } catch (Mage_Core_Exception $e) {
198
+ $result = array(
199
+ 'errors' => array($e->getMessage()),
200
+ 'needs_reload' => false,
201
+ 'is_action_error' => false,
202
+ );
203
+ return $result;
204
+ } catch (Exception $e) {
205
+ $result = array(
206
+ 'errors' => array($this->_getDpdHelper()->__('Cannot call courier.')),
207
+ 'needs_reload' => true,
208
+ 'is_action_error' => false,
209
+ );
210
+ return $result;
211
+ }
212
+ $result = array(
213
+ 'messages' => array($this->_getDpdHelper()->__('Courier comes to pick up your shipment on %1$s between %2$s', $courierArrivalDate, $courierArrivalTime)),
214
+ 'needs_reload' => true,
215
+ 'is_action_error' => false,
216
+ );
217
+ return $result;
218
+ }
219
+
220
+ /**
221
+ *
222
+ * @param string $input
223
+ * @return string
224
+ */
225
+ protected function _getTimeFrom($input) {
226
+ $parts = explode('-', $input);
227
+ return str_replace('00', '', $parts[0]);
228
+ }
229
+ protected function _getTimeTil($input) {
230
+ $parts = explode('-', $input);
231
+ return str_replace('00', '', $parts[1]);
232
+ }
233
+
234
+ /**
235
+ * Returns true, if courier can be called for this order.
236
+ * @param Mage_Sales_Model_Order $order
237
+ * @return boolean
238
+ */
239
+ protected function _isHandleableOrder(Mage_Sales_Model_Order $order) {
240
+ $shippingMethodModel = null;
241
+ $res = $this->_getDpdHelper()->isShippingMethodApplicable($order) && $this->_getOfficeHelper()->canSendData($order, $shippingMethodModel);
242
+ if ($res) {
243
+ if ($shippingMethodModel->isPickedUpByCourier($order) !== false) {
244
+ return false;
245
+ }
246
+ }
247
+ return $res;
248
+
249
+ }
250
+
251
+ /**
252
+ * Fetches an array of Mage_Sales_Model_Order from comma separated string
253
+ * @param string $inputCsv
254
+ * @return array
255
+ * @throws Exception if input CSV is malformed or order does not exist
256
+ */
257
+ protected function _getOrders($inputCsv) {
258
+ $orderIds = explode(',', $inputCsv);
259
+ $orders = array();
260
+ foreach ($orderIds as $orderId) {
261
+ $order = $this->_getOrderModel()->load(trim($orderId));
262
+ if (!$order || !$order->getId()) {
263
+ throw new Exception($this->_getDpdHelper()->__('Order does not exist'));
264
+ }
265
+ $orders[] = $order;
266
+ }
267
+ return $orders;
268
+ }
269
+
270
+
271
+ /**
272
+ *
273
+ * @return Mage_Sales_Model_Order
274
+ */
275
+ protected function _getOrderModel() {
276
+ return Mage::getModel('sales/order');
277
+
278
+ }
279
+
280
+
281
+
282
+
283
+ }
284
+
app/code/community/Eabi/DpdEE/Model/Api.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Wrapper class for communicating with DPD API</p>
36
+ * <p>Each request is prefilled with username, password, return address data whenever possible.</p>
37
+ * <p>Each response is json_decoded to assoc array and Exception is thrown when response error code is else than integer 0</p>
38
+ *
39
+ * @author Matis
40
+ */
41
+ class Eabi_DpdEE_Model_Api extends Varien_Object {
42
+
43
+
44
+
45
+ /**
46
+ * Retrieve information from carrier configuration
47
+ *
48
+ * @param string $field
49
+ * @return mixed
50
+ */
51
+ public function getConfigData($field) {
52
+ if (!$this->getCode()) {
53
+ return false;
54
+ }
55
+ $path = 'carriers/'.$this->getCode().'/'.$field;
56
+ return Mage::getStoreConfig($path, $this->getStore());
57
+ }
58
+
59
+
60
+ /**
61
+ * <p>Fetches list of parcel terminals from DPD API. (op=pudo)</p>
62
+ * <p>This function can be used without DPD API account.</p>
63
+ * <p>Parcel terminals are included in 'data' array key.</p>
64
+ * @return array
65
+ */
66
+ public function getOfficeList() {
67
+ $body = @$this->_getRequest();
68
+ return $body;
69
+ }
70
+
71
+
72
+ /**
73
+ * <p>Fetches available courier collection times. (op=date)</p>
74
+ * @param array $requestData
75
+ * @return array
76
+ */
77
+ public function getCourierCollectionTimes(array $requestData = array()) {
78
+ $details = array(
79
+ 'op' => 'date',
80
+ 'Po_postal' => $this->getConfigData('return_postcode'),
81
+ 'Po_country' => strtolower($this->getConfigData('return_country')),
82
+ 'Po_type' => isset($requestData['Po_type'])?strtolower($requestData['Po_type']):'po',
83
+ );
84
+ if ($details['Po_country'] == 'ee') {
85
+ //documentation required 'eesti' as supplied country
86
+ //in order to use same api in other countries, we change it to 'eesti' only for estonia
87
+ //probably in the future all countries require only iso-3166 code
88
+ $details['Po_country'] = 'eesti';
89
+ }
90
+ foreach ($details as $key => $detail) {
91
+ $requestData[$key] = $detail;
92
+ }
93
+ $requestResult = $this->_getRequest($requestData);
94
+ return $requestResult;
95
+
96
+ }
97
+
98
+ /**
99
+ * <p>Send parcel data to DPD server, prefills with return data from Magento configuration.</p>
100
+ * @param array $requestData
101
+ * @return array
102
+ */
103
+ public function autoSendData(array $requestData) {
104
+ $returnDetails = array(
105
+ 'op' => 'order',
106
+ 'Po_name' => $this->getConfigData('return_name'),
107
+ 'Po_company' => $this->getConfigData('return_company'),
108
+ 'Po_street' => $this->getConfigData('return_street'),
109
+ 'Po_postal' => $this->getConfigData('return_postcode'),
110
+ 'Po_country' => strtolower($this->getConfigData('return_country')),
111
+ 'Po_city' => $this->getConfigData('return_citycounty'),
112
+ 'Po_contact' => $this->getConfigData('return_name'),
113
+ 'Po_phone' => $this->getConfigData('return_phone'),
114
+ //po-remark
115
+ 'Po_email' => $this->getConfigData('return_email'),
116
+ 'Po_show_on_label' => $this->getConfigData('po_show_on_label')?'true':'false',
117
+ 'Po_save_address' => $this->getConfigData('po_save_address')?'true':'false',
118
+ // 'Po_type' => $this->getConfigData('senddata_service'),
119
+ 'LabelsPosition' => $this->getConfigData('label_position'),
120
+
121
+ );
122
+
123
+ foreach ($returnDetails as $key => $returnDetail) {
124
+ $requestData[$key] = $returnDetail;
125
+ }
126
+ if (!isset($requestData['Po_type'])) {
127
+ $requestData['Po_type'] = $this->getConfigData('senddata_service');
128
+ }
129
+
130
+ $requestResult = $this->_getRequest($requestData);
131
+ return $requestResult;
132
+ }
133
+
134
+
135
+ /**
136
+ * <p>Determines if courier has been called to pick up the packages.</p>
137
+ * <p>If courier has been called to fetch packages and courier pickup time from has not yet been reached, then it returns array consisting following elements:</p>
138
+ * <ul>
139
+ <li>UNIX timestamp when courier pickup should start</li>
140
+ <li>UNIX timestamp when courier pickup should end</li>
141
+ </ul>
142
+ * <p>On every other scenario this function returns boolean false</p>
143
+ * @return boolean|array
144
+ */
145
+ public function isCourierComing() {
146
+ $pickupTime = $this->getConfigData('courier_pickup_time');
147
+ $time = time();
148
+ if ($pickupTime) {
149
+ $pickupTime = explode(',', $pickupTime);
150
+ }
151
+ if ($pickupTime[0] >= $time) {
152
+ return $pickupTime;
153
+ }
154
+ return false;
155
+ }
156
+
157
+
158
+
159
+ /**
160
+ * <p>Sends actual request to DPD API, prefills with username and password and json decodes the result.</p>
161
+ * <p>Default operation (op=pudo), on such scenario username and password is not sent.</p>
162
+ * <p>If return error code is else than 0, then exception is thrown.</p>
163
+ * @param array $params
164
+ * @param string $url
165
+ * @return array
166
+ */
167
+ protected function _getRequest($params = array('op' => 'pudo'), $url = null) {
168
+ if (!$url) {
169
+ $url = $this->getConfigData('api_url');
170
+ }
171
+ if (isset($params['op']) && $params['op'] != 'pudo') {
172
+ $params['User_login'] = $this->getConfigData('sendpackage_username');
173
+ $params['User_password'] = $this->getConfigData('sendpackage_password');
174
+ }
175
+ $client = new Zend_Http_Client($url);
176
+ $options = array(
177
+ 'timeout' => $this->getConfigData('http_request_timeout')>10?$this->getConfigData('http_request_timeout'):10,
178
+ );
179
+ $client->setConfig($options);
180
+ $client->setParameterPost($params);
181
+ $resp = $client->request(Zend_Http_Client::POST);
182
+ $decodeResult = @json_decode($resp->getBody(), true);
183
+ if (!is_array($decodeResult) || !isset($decodeResult['Error_code'])
184
+ || $decodeResult['Error_code'] !== 0) {
185
+ Mage::throwException($this->_getDpdHelper()->__('DPD request failed with response: %s', print_r($decodeResult, true)));
186
+ }
187
+ return $decodeResult;
188
+ }
189
+
190
+
191
+
192
+ /**
193
+ *
194
+ * @return Eabi_DpdEE_Helper_Data
195
+ */
196
+ protected function _getDpdHelper() {
197
+ return Mage::helper('eabi_dpdee');
198
+ }
199
+
200
+ /**
201
+ *
202
+ * @return Eabi_Postoffice_Helper_Data
203
+ */
204
+ protected function _getOfficeHelper() {
205
+ return Mage::helper('eabi_postoffice');
206
+ }
207
+
208
+
209
+ }
app/code/community/Eabi/DpdEE/Model/Button/Courier.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Renders button at the Magento Administrators Sales Order Grid, which allows to call DPD courier.</p>
36
+ * <p>Button is displayed when order shipping method is DPD and parcel data is sent to DPD server.</p>
37
+ *
38
+ * @see Eabi_DpdEE_Block_Order_Courier
39
+ * @author Matis
40
+ */
41
+ class Eabi_DpdEE_Model_Button_Courier extends Eabi_Livehandler_Model_Adminhtml_Gridmanager {
42
+ protected $_id = 'eabi_dpdee__button_courier';
43
+ protected $_shippingMethodCode;
44
+
45
+ public function _construct() {
46
+ parent::_construct();
47
+ $this->_init('eabi_dpdee/button_courier');
48
+
49
+ //check if auto send is enabled and courier call is enabled
50
+ $this->_shippingMethodCode = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_PARCEL_TERMINAL;
51
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($this->_shippingMethodCode);
52
+ if (!$shippingMethodModel || !$shippingMethodModel->getConfigData('active')) {
53
+ $this->_shippingMethodCode = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_FLAT;
54
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($this->_shippingMethodCode);
55
+ }
56
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)
57
+ && $shippingMethodModel->getConfigData('active')
58
+ && $shippingMethodModel->getConfigData('senddata_enable')
59
+ && $shippingMethodModel->getConfigData('courier_enable')
60
+ ) {
61
+ $this->addActionButton($this->_id, $this->_getDpdHelper()->__('Order courier to pick up goods'), 'return false;');
62
+ }
63
+
64
+ }
65
+
66
+
67
+ /**
68
+ *
69
+ * @param string $currentJs
70
+ * @return string
71
+ */
72
+ protected function _getAdditionalJs($currentJs) {
73
+ if (!count($this->_actionButtons)) {
74
+ return '';
75
+ }
76
+ $js = <<<JS
77
+ var eabi_dpdJsObject = new EabiDpdEE('{$this->_id}', null, function(infoBox) {
78
+ new Ajax.Request(action_url, {
79
+ method: 'post',
80
+ parameters: {},
81
+ asynchronous: false,
82
+ evalJSON: 'force',
83
+ onSuccess: function(transport){
84
+ var ul = new Element('ul', {'class': 'messages'});
85
+ if (transport.responseJSON.errors) {
86
+ transport.responseJSON.errors.each(function(message) {
87
+ ul.insert({bottom: '<li class="success-msg">' + message + '</li>'});
88
+ });
89
+ }
90
+ if (transport.responseJSON.messages) {
91
+ transport.responseJSON.messages.each(function(message) {
92
+ ul.insert({bottom: '<li class="success-msg">' + message + '</li>'});
93
+ });
94
+ }
95
+ if (transport.responseJSON.errors || transport.responseJSON.messages) {
96
+ infoBox.update(ul);
97
+ }
98
+ if (transport.responseJSON.html) {
99
+ infoBox.update(transport.responseJSON.html);
100
+ }
101
+ },
102
+ onFailure: function(transport){
103
+ alert('Request failed, check your error logs');
104
+ }
105
+ });
106
+
107
+ }, null, function(endResult) { if (!endResult['Po_Date'] || endResult['Po_Date'] == '-') { return false; } return endResult; });
108
+ $('{$this->_id}').observe('click', function(event) {
109
+ var submitResult;
110
+ eabi_dpdJsObject.update('');
111
+
112
+ submitResult = eabi_dpdJsObject.submit(action_url, function(json, infoBox) {
113
+ var ul = new Element('ul', {'class': 'messages'});
114
+ if (json.errors || json.messages) {
115
+ if (json.errors) {
116
+ json.errors.each(function(message) {
117
+ ul.insert({bottom: '<li class="success-msg">' + message + '</li>'});
118
+ });
119
+ }
120
+ if (json.messages) {
121
+ json.messages.each(function(message) {
122
+ ul.insert({bottom: '<li class="success-msg">' + message + '</li>'});
123
+ });
124
+ }
125
+
126
+ infoBox.update(ul);
127
+
128
+ } else {
129
+ if (json.html) {
130
+ eabi_dpdJsObject.update(json.html, 'dummy', null);
131
+ }
132
+
133
+ }
134
+
135
+
136
+ });
137
+
138
+
139
+
140
+ });
141
+
142
+ JS;
143
+ return $js;
144
+ }
145
+
146
+
147
+ /**
148
+ * <p>Sends DPD courier call request from press of Call Courier Button to server and returns the result in following format:</p>
149
+ * <pre>
150
+ $result = array(
151
+ 'messages' => array of successmessages (optional),
152
+ 'errors' => array of error messages (optional),
153
+ 'html' => html to be replaced in Courier call infobox,
154
+ 'needs_reload' => false (not used),
155
+ 'is_action_error' => false (not used),
156
+ );
157
+ *
158
+ * </pre>
159
+ * <p></p>
160
+ * @param array $params posted Parameters from request
161
+ * @return boolean|array
162
+ */
163
+ public function service($params) {
164
+ if (!count($this->_actionButtons)) {
165
+ //if no button available, do nothing when request is received
166
+ return array();
167
+ }
168
+ try {
169
+ $api = $this->_getDpdHelper()->getApi(Mage_Core_Model_App::ADMIN_STORE_ID);
170
+ //TODO: time check
171
+ //
172
+ $isCourierComing = $api->isCourierComing();
173
+ if (isset($params['Po_Date']) && $params['Po_Date'] != '-' && !$isCourierComing) {
174
+ //send the data
175
+
176
+ $orderSendData = array(
177
+ 'Po_remark' => isset($params['Po_remark']) ? $params['Po_remark'] : '',
178
+ 'Po_type' => 'PO',
179
+ 'Po_Date' => $params['Po_Date'],
180
+ 'Po_Time_from' => $this->_getTimeFrom($params['Po_Time']),
181
+ 'Po_Time_til' => $this->_getTimeTil($params['Po_Time']),
182
+ 'Po_envelope_qty' => $params['Po_envelope_qty'],
183
+ 'Po_parcel_qty' => $params['Po_parcel_qty'],
184
+ 'Po_pallet_qty' => $params['Po_pallet_qty'],
185
+ 'Sh_envelope_qty' => $params['Po_envelope_qty'],
186
+ 'Sh_parcel_qty' => $params['Po_parcel_qty'],
187
+ 'Sh_pallet_qty' => $params['Po_pallet_qty'],
188
+ 'Sh_pudo' => 'false',
189
+ );
190
+
191
+ $orderSendResult = $api->autoSendData($orderSendData);
192
+
193
+ $courierArrivalDate = $orderSendData['Po_Date'];
194
+ $courierArrivalTime = $orderSendData['Po_Time_from'] . ' ' . $this->_getDpdHelper()->__('and') . ' ' . $orderSendData['Po_Time_til'];
195
+
196
+
197
+ //set the config data for courier pickup time
198
+ $pickupTimeFrom = new Zend_Date(0, Zend_Date::TIMESTAMP);
199
+ $pickupTimeFrom->setTimezone('Europe/Tallinn');
200
+ $pickupTimeFrom->set($orderSendData['Po_Date'], 'yyyy-MM-dd');
201
+
202
+ //we need this shitty way, because setting time directly with one format definition results in wrong timestamp
203
+ if (strlen($orderSendData['Po_Time_from']) > 2) {
204
+ $pickupTimeFrom->add(substr($orderSendData['Po_Time_from'], strlen($orderSendData['Po_Time_from']) - 2), Zend_Date::MINUTE);
205
+ } else {
206
+ $pickupTimeFrom->add($orderSendData['Po_Time_from'], 'H');
207
+ }
208
+
209
+ // . '-' . $this->_getTimeFrom($params['Po_Time'], false)
210
+ $pickupTimeTill = new Zend_Date(0, Zend_Date::TIMESTAMP);
211
+ $pickupTimeTill->setTimezone('Europe/Tallinn');
212
+ $pickupTimeTill->set($orderSendData['Po_Date'] , 'yyyy-MM-dd');
213
+
214
+ if (strlen($orderSendData['Po_Time_til']) > 2) {
215
+ $pickupTimeTill->add(substr($orderSendData['Po_Time_til'], strlen($orderSendData['Po_Time_til']) - 2), Zend_Date::MINUTE);
216
+ } else {
217
+ $pickupTimeTill->add($orderSendData['Po_Time_til'], 'H');
218
+ }
219
+
220
+
221
+
222
+ $configTimeStamp = $pickupTimeFrom->get(Zend_Date::TIMESTAMP) . ',' . $pickupTimeTill->get(Zend_Date::TIMESTAMP);
223
+ $this->_getEabi()->setConfigData('carriers/eabidpdee/courier_pickup_time', $configTimeStamp, 'default', 0, true);
224
+ } else {
225
+ if (!$isCourierComing) {
226
+ $dpdBlock = Mage::getSingleton('core/layout')
227
+ ->createBlock('eabi_dpdee/order_courier')
228
+ ->setCode(Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_PARCEL_TERMINAL)
229
+ ->setStoreId(Mage_Core_Model_App::ADMIN_STORE_ID)
230
+ ;
231
+
232
+ $result = array(
233
+ 'needs_reload' => true,
234
+ 'is_action_error' => false,
235
+ 'html' => $dpdBlock->toHtml(),
236
+ );
237
+ return $result;
238
+ } else {
239
+ $dateFormatIso = Mage::app()->getLocale()
240
+ ->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
241
+
242
+ $pickupTimeFrom = new Zend_Date($isCourierComing[0], Zend_Date::TIMESTAMP);
243
+ $pickupTimeTill = new Zend_Date($isCourierComing[1], Zend_Date::TIMESTAMP);
244
+ $pickupTimeFrom->setTimezone('Europe/Tallinn');
245
+ $pickupTimeTill->setTimezone('Europe/Tallinn');
246
+ $courierArrivalDate = $pickupTimeFrom->get($dateFormatIso);
247
+ $courierArrivalTime = $pickupTimeFrom->get(Zend_Date::HOUR_SHORT) . ' ' . $this->_getDpdHelper()->__('and') . ' ' . $pickupTimeTill->get(Zend_Date::HOUR_SHORT);
248
+ }
249
+ }
250
+ } catch (Mage_Core_Exception $e) {
251
+ $result = array(
252
+ 'errors' => array($e->getMessage()),
253
+ 'needs_reload' => false,
254
+ 'is_action_error' => false,
255
+ );
256
+ return $result;
257
+ } catch (Exception $e) {
258
+ $result = array(
259
+ 'errors' => array($this->_getDpdHelper()->__('Cannot call courier.').$e->__toString()),
260
+ 'needs_reload' => true,
261
+ 'is_action_error' => false,
262
+ );
263
+ return $result;
264
+ }
265
+ $result = array(
266
+ 'messages' => array($this->_getDpdHelper()->__('Courier comes to pick up your shipment on %1$s between %2$s', $courierArrivalDate, $courierArrivalTime)),
267
+ 'needs_reload' => true,
268
+ 'is_action_error' => false,
269
+ );
270
+ return $result;
271
+ }
272
+
273
+
274
+ /**
275
+ * <p>Gets Time from from timefrom-timetill construct</p>
276
+ * @param string $input
277
+ * @param bool $removeMinutesIfZero when true 900 will be converted to 9
278
+ * @return string
279
+ */
280
+ protected function _getTimeFrom($input, $removeMinutesIfZero = true) {
281
+ $parts = explode('-', $input);
282
+ if ($removeMinutesIfZero) {
283
+ return str_replace('00', '', $parts[0]);
284
+ } else {
285
+ return $parts[0];
286
+ }
287
+ }
288
+
289
+ /**
290
+ * <p>Gets Time till from timefrom-timetill construct</p>
291
+ * @param string $input
292
+ * @param bool $removeMinutesIfZero when true 900 will be converted to 9
293
+ * @return string
294
+ */
295
+ protected function _getTimeTil($input, $removeMinutesIfZero = true) {
296
+ $parts = explode('-', $input);
297
+ if ($removeMinutesIfZero) {
298
+ return str_replace('00', '', $parts[1]);
299
+ } else {
300
+ return $parts[1];
301
+ }
302
+ }
303
+
304
+
305
+ /**
306
+ *
307
+ * @return Eabi_DpdEE_Helper_Data
308
+ */
309
+ protected function _getDpdHelper() {
310
+ return Mage::helper('eabi_dpdee');
311
+ }
312
+ /**
313
+ *
314
+ * @return Eabi_Postoffice_Helper_Data
315
+ */
316
+ protected function _getOfficeHelper() {
317
+ return Mage::helper('eabi_postoffice');
318
+ }
319
+
320
+ /**
321
+ * <p>Wrapper json_encode in order to make it easier to use in heredoc syntax</p>
322
+ * @param mixed $input
323
+ * @return string
324
+ */
325
+ protected function _toJson($input) {
326
+ return json_encode($input);
327
+ }
328
+
329
+ /**
330
+ *
331
+ * @return Eabi_Livehandler_Helper_Data
332
+ */
333
+ protected function _getEabi() {
334
+ return Mage::helper('eabi');
335
+ }
336
+
337
+
338
+
339
+ }
app/code/community/Eabi/DpdEE/Model/Config.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Configuration variables proxy class</p>
35
+ *
36
+ * @author Matis
37
+ */
38
+ class Eabi_DpdEE_Model_Config {
39
+
40
+ const SHIPPING_METHOD_CODE_PARCEL_TERMINAL = 'eabidpdee';
41
+ const SHIPPING_METHOD_CODE_FLAT = 'eabidpdeeflat';
42
+
43
+ }
44
+
app/code/community/Eabi/DpdEE/Model/Flat.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Represents DPD courier shipping method.</p>
36
+ * <p>Extra order data is stored under specialized order comment</p>
37
+ * <p>Can perform following business actions:</p>
38
+ * <ul>
39
+ <li>Calculate shipping price based on country and weight</li>
40
+ <li>Send information about shipment data to DPD server.</li>
41
+ <li>Display tracking link to user when tracking code is added to the shipment.</li>
42
+ <li>Call courier to pick up the shipment that was ordered using this carrier.</li>
43
+ <li>Print out packing slip PDF from Order view.</li>
44
+ </ul>
45
+ *
46
+ * @author Matis
47
+ */
48
+ class Eabi_DpdEE_Model_Flat extends Eabi_DpdEE_Model_Post {
49
+ protected $_code = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_FLAT;
50
+ protected $_parent_code = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_PARCEL_TERMINAL;
51
+
52
+ /**
53
+ * Automatic data sending is defined in Parcel terminal module configuration
54
+ * @return bool
55
+ */
56
+ public function isAutoSendAvailable() {
57
+ return (bool)$this->_getDpdHelper()->getApi($this->getStore(), $this->_parent_code)->getConfigData('senddata_enable');
58
+ }
59
+
60
+
61
+ /**
62
+ * <p>Sends parcel data to DPD server for specified order</p>
63
+ * @param Mage_Sales_Model_Order $order
64
+ * @param type $selectedOfficeId not applicable.
65
+ * @return array comma separated parcel numbers in array key of 'barcode'
66
+ */
67
+ public function autoSendData(Mage_Sales_Model_Order $order, $selectedOfficeId) {
68
+ $shippingAddress = $order->getShippingAddress();
69
+ $requestData = array(
70
+ 'Sh_name' => $shippingAddress->getName(),
71
+ 'Sh_company' => $shippingAddress->getCompany(),
72
+ 'Sh_street' => $shippingAddress->getStreetFull(),
73
+ 'Sh_postal' => $shippingAddress->getPostcode(),
74
+ 'Sh_country' => strtolower($shippingAddress->getCountryId()),
75
+ 'Sh_city' => $shippingAddress->getCity(),
76
+ 'Sh_contact' => $shippingAddress->getName(),
77
+ 'Sh_phone' => $shippingAddress->getTelephone(),
78
+ 'Po_remark' => $this->_getRemark($order),
79
+ 'Sh_remark' => '',
80
+ 'Sh_pudo' => 'false',
81
+ 'Sh_parcel_qty' => $this->_getNumberOfPackagesForOrder($order),
82
+ 'Sh_cust_reference' => $order->getIncrementId(),
83
+ );
84
+ if ($shippingAddress->getRegion()) {
85
+ $requestData['Sh_city'] = $shippingAddress->getCity() . ', ' . $shippingAddress->getRegion();
86
+ }
87
+
88
+
89
+ $requestResult = $this->_getDpdHelper()->getApi($this->getStore(), $this->_parent_code)
90
+ ->autoSendData($requestData);
91
+
92
+ $this->_setDataToOrder($order, $requestResult);
93
+
94
+ //on failure return false
95
+ //is success
96
+ return array('barcode' => '##'. implode(',', $requestResult['Parcel_numbers']).'##');
97
+ }
98
+
99
+
100
+
101
+ /**
102
+ * <p>This carrier has no parcel terminal selection feature, so one entry must still be added with shipping method title defined for this carrier.</p>
103
+ * @return array single office element
104
+ */
105
+ public function getOfficeList() {
106
+ //we have only one item to insert here
107
+ $result = array();
108
+ $result[] = array(
109
+ 'place_id' => 1,
110
+ 'name' => $this->getConfigData('title'),
111
+ 'city' => '',
112
+ 'county' => '',
113
+ 'description' => '',
114
+ 'country' => '',
115
+ 'zip' => '',
116
+ 'group_sort' => 0,
117
+ );
118
+ return $result;
119
+ }
120
+
121
+ /**
122
+ * <p>Returns carrier title specified for this shipping method.</p>
123
+ * @param Eabi_Postoffice_Model_Office $office
124
+ * @return string
125
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getTerminalTitle()
126
+ */
127
+ public function getTerminalTitle(Eabi_Postoffice_Model_Office $office) {
128
+ return htmlspecialchars($this->getConfigData('title'));
129
+ }
130
+
131
+
132
+ /**
133
+ * <p>Returns carrier title specified for this shipping method.</p>
134
+ * @param Eabi_Postoffice_Model_Office $office
135
+ * @return string
136
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getAdminTerminalTitle()
137
+ */
138
+ public function getAdminTerminalTitle(Eabi_Postoffice_Model_Office $office) {
139
+ return htmlspecialchars($this->getConfigData('title'));
140
+ }
141
+
142
+ /**
143
+ * <p>Indicates if specified order has been picked up by courier.</p>
144
+ * <p>Should return the following</p>
145
+ * <ul>
146
+ <li><b>true</b> - If the order has been picked up by courier</li>
147
+ <li><b>false</b> - If the order has not been picked up by courier</li>
148
+ <li><b>null</b> - If courier pickup is not applicable to specified order</li>
149
+ </ul>
150
+ * @param Mage_Sales_Model_Order $order
151
+ * @return null|bool
152
+ */
153
+ public function isPickedUpByCourier(Mage_Sales_Model_Order $order) {
154
+ $api = $this->_getDpdHelper()->getApi($this->getStore()->getId(), $this->_parent_code);
155
+ if (!$api->getConfigData('courier_enable')) {
156
+ return null;
157
+ }
158
+ $orderData = $this->getDataFromOrder($order);
159
+ if (isset($orderData['courier_call_id']) && $orderData['courier_call_id']) {
160
+ return true;
161
+ }
162
+ return false;
163
+ }
164
+
165
+ /**
166
+ * <p>Nullifies address id from query, because in every country there needs to be available 'parcel-terminal'</p>
167
+ * @param int $groupId
168
+ * @param int $addressId
169
+ * @return array
170
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getTerminals()
171
+ */
172
+ public function getTerminals($groupId = null, $addressId = null) {
173
+ //fetching entry needs to be independendent of country
174
+ return parent::getTerminals($groupId, null);
175
+ }
176
+
177
+
178
+ /**
179
+ * <p>Nullifies address id from query, because in every country there needs to be available 'parcel-terminal'</p>
180
+ * @param int $addressId
181
+ * @return array
182
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getGroups()
183
+ */
184
+ public function getGroups($addressId = null) {
185
+ return parent::getGroups(null);
186
+
187
+ }
188
+
189
+
190
+
191
+ /**
192
+ * Gets the config data from this instance and if not existent, then tries to fetch it from parent instance.
193
+ *
194
+ * @param string $field
195
+ * @return mixed
196
+ */
197
+ public function getConfigData($field) {
198
+ if (empty($this->_code)) {
199
+ return false;
200
+ }
201
+ $path = 'carriers/'.$this->_code.'/'.$field;
202
+ $value = $this->_getConfigDataOverride($field, $this->_code);
203
+ // $value = Mage::getStoreConfig($path, $this->getStore());
204
+ if ($value === false || $value === null) {
205
+ $path = 'carriers/'.$this->_parent_code.'/'.$field;
206
+ return $this->_getConfigDataOverride($field, $this->_parent_code);
207
+ // return Mage::getStoreConfig($path, $this->getStore());
208
+ } else {
209
+ return $value;
210
+ }
211
+ }
212
+
213
+
214
+
215
+
216
+ }
app/code/community/Eabi/DpdEE/Model/Observer.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Holds all Mage::dispatchEvent() actions</p>
36
+ *
37
+ * @author Matis
38
+ */
39
+ class Eabi_DpdEE_Model_Observer {
40
+
41
+
42
+ /**
43
+ * <p>Adds tracking numbers to orders created with DPD right after shipment is first time saved</p>
44
+ * <p>If parcel data is not sent to server, then tracking numbers will not be created, even if data is sent to server after creation of shipment</p>
45
+ * @param Varien_Event_Observer $observer
46
+ */
47
+ public function addTrackingToShipment($observer) {
48
+ /* @var $shipment Mage_Sales_Model_Order_Shipment */
49
+ $shipment = $observer->getEvent()->getShipment();
50
+ if ($shipment
51
+ && $this->_getDpdHelper()->isShippingMethodApplicable($shipment->getOrder())) {
52
+ //add the tracks here.....
53
+ $dataSavedToOrder = $this->_getOfficeHelper()->getDataFromOrder($shipment->getOrder(), Eabi_DpdEE_Model_Post::ORDER_COMMENT_START_PREFIX);
54
+ if (isset($dataSavedToOrder['Parcel_numbers'])) {
55
+ $this->_addTracksToShipment($shipment, $dataSavedToOrder['Parcel_numbers']);
56
+ }
57
+
58
+ }
59
+ }
60
+
61
+
62
+ /**
63
+ * <p>Adds tracking numbers to shipment, when it is known that we are dealing with DPD order</p>
64
+ * <p>If tracks with same carrier code as order shipping method carrier code have already been added, then this function does nothing</p>
65
+ * @param Mage_Sales_Model_Order_Shipment $shipment shipment, to add the tracking numbers for
66
+ * @param array $trackingNumbers array of DPD tracking numbers
67
+ */
68
+ protected function _addTracksToShipment(Mage_Sales_Model_Order_Shipment $shipment, array $trackingNumbers) {
69
+ /* @var $shippingMethodInstance Eabi_Postoffice_Model_Carrier_Abstract */
70
+ $shippingMethodInstance = $this->_getOfficeHelper()->getShippingMethodInstance($shipment->getOrder()->getIncrementId());
71
+ $trackExists = false;
72
+ if ($shippingMethodInstance) {
73
+ $oldTracks = $shipment->getAllTracks();
74
+ foreach ($oldTracks as $oldTrack) {
75
+ if ($oldTrack->getCarrierCode() == $shippingMethodInstance->getCarrierCode()) {
76
+ $trackExists = true;
77
+ }
78
+ }
79
+ if (!$trackExists) {
80
+ foreach ($trackingNumbers as $trackingNumber) {
81
+ $track = $this->_getTrackingModel()
82
+ ->setNumber($trackingNumber)
83
+ ->setCarrierCode($shippingMethodInstance->getCarrierCode())
84
+ ->setTitle($shippingMethodInstance->getConfigData('title'))
85
+ ->setShipment($shipment);
86
+ $track->save();
87
+ }
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ *
94
+ * @return Mage_Sales_Model_Order_Shipment_Track
95
+ */
96
+ protected function _getTrackingModel() {
97
+ return Mage::getModel('sales/order_shipment_track');
98
+ }
99
+
100
+
101
+ /**
102
+ *
103
+ * @return Eabi_DpdEE_Helper_Data
104
+ */
105
+ protected function _getDpdHelper() {
106
+ return Mage::helper('eabi_dpdee');
107
+ }
108
+
109
+ /**
110
+ *
111
+ * @return Eabi_Postoffice_Helper_Data
112
+ */
113
+ protected function _getOfficeHelper() {
114
+ return Mage::helper('eabi_postoffice');
115
+ }
116
+
117
+
118
+
119
+ }
app/code/community/Eabi/DpdEE/Model/Post.php ADDED
@@ -0,0 +1,536 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Represents DPD parcel terminal shipping method.</p>
36
+ * <p>Extra order data is stored under specialized order comment</p>
37
+ * <p>Can perform following business actions:</p>
38
+ * <ul>
39
+ <li>Calculate shipping price based on country and weight</li>
40
+ <li>Display list of user selectable parcel terminals, which is auto updated.</li>
41
+ <li>Send information about shipment data to DPD server.</li>
42
+ <li>Display tracking link to user when tracking code is added to the shipment.</li>
43
+ <li>Call courier to pick up the shipment that was ordered using this carrier.</li>
44
+ <li>Print out packing slip PDF from Order view.</li>
45
+ </ul>
46
+ *
47
+ * @author matishalmann
48
+ */
49
+ class Eabi_DpdEE_Model_Post extends Eabi_Postoffice_Model_Carrier_Abstract {
50
+
51
+ protected $_code = Eabi_DpdEE_Model_Config::SHIPPING_METHOD_CODE_PARCEL_TERMINAL;
52
+
53
+ /**
54
+ * If order comment starts with prefix marked here and is not visible on the frontend, then it is considered as extra data order comment.
55
+ */
56
+ const ORDER_COMMENT_START_PREFIX = '-----EABI_DPDEE-----';
57
+
58
+
59
+ /**
60
+ * <p>%s in the URL is replaced with tracking number.</p>
61
+ * @var string
62
+ */
63
+ protected $_tracking_url = 'https://tracking.dpd.de/cgi-bin/delistrack?typ=1&lang=en&pknr=%s';
64
+
65
+
66
+
67
+ /**
68
+ * <p>If disable shipping by product comment is allowed and product's short description in shopping cart contains html comment &lt;!-- no dpd_ee_module --&gt; then it returns false.</p>
69
+ * @param Mage_Shipping_Model_Rate_Request $request
70
+ * @return boolean true if this method is available.
71
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::_isAvailable()
72
+ */
73
+ protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
74
+ $productItem = true;
75
+ if ($this->getConfigData('checkitems') == 1) {
76
+ $productItem = true;
77
+ if ($request->getAllItems()) {
78
+ foreach ($request->getAllItems() as $item) {
79
+ $custom = Mage::getModel('catalog/product')->load($item->getProduct()->getId());
80
+ $desc = $custom->getShortDescription();
81
+ if (stristr($desc, '<!-- no dpd_ee_module -->')) {
82
+ $productItem = false;
83
+ break;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ if (!$productItem) {
89
+ return false;
90
+ }
91
+ return true;
92
+ }
93
+
94
+
95
+ /**
96
+ * <p>Attemps to calculate shipping price from price-country shipping price matrix.</p>
97
+ * <p>If unsuccessful, then default handling fee is returned.</p>
98
+ * <p>If shipping calculation mode is set Per Item, then price will be multiplied by number of packages</p>
99
+ * @param Mage_Shipping_Model_Rate_Request $request
100
+ * @param double $price
101
+ * @return double
102
+ */
103
+ public function _calculateAdditionalShippingPrice(Mage_Shipping_Model_Rate_Request $request, $price) {
104
+ $shippingMatrix = $this->_decodeShippingMatrix($this->getConfigDataForThis('handling_fee_country'));
105
+ if ($request->getDestCountryId() && isset($shippingMatrix[$request->getDestCountryId()])) {
106
+ //free price?
107
+ if ($shippingMatrix[$request->getDestCountryId()]['free_shipping_from'] !== '') {
108
+ if ($request->getPackageValueWithDiscount() >= $shippingMatrix[$request->getDestCountryId()]['free_shipping_from']) {
109
+ return 0;
110
+ }
111
+ }
112
+ //subtraction is required because edges are 0-10,10.00001-20,....,....
113
+ $packageWeight = $request->getPackageWeight() - 0.000001;
114
+ $weightSet = 10;
115
+ //we need to have price per every kg, where
116
+ //0-10kg consists only base price
117
+ //10,1-20kg equals base price + extra price
118
+ //20,1-30kg equals base price + extra price * 2
119
+ $extraWeightCost = max(floor($packageWeight / $weightSet) * $shippingMatrix[$request->getDestCountryId()]['kg_price'], 0);
120
+
121
+ $handlingFee = $shippingMatrix[$request->getDestCountryId()]['base_price'];
122
+ if ($this->getConfigData('handling_action') == 'P') {
123
+ $handlingFee = ($this->_getOfficeHelper()->getNumberOfPackagesFromItemWeights($request->getEabiProductWeights(), $this->getConfigData('max_package_weight')) - $this->getFreeBoxes()) * $handlingFee;
124
+ }
125
+ $handlingFee += $extraWeightCost;
126
+
127
+ return $handlingFee;
128
+ }
129
+ return $price;
130
+ }
131
+
132
+
133
+ /**
134
+ * <p>Decodes json encoded string to assoc array (array keys are country ISO codes) and returns in following format:</p>
135
+ * <ul>
136
+ <li><code>country_id</code> - Country ISO code, also array key for this element</li>
137
+ <li><code>base_price</code> - base shipping price up to 10kg</li>
138
+ <li><code>kg_price</code> - additional shipping price for each 10kg</li>
139
+ <li><code>free_shipping_from</code> - when and if to apply free shipping</li>
140
+ </ul>
141
+ * @param string $input
142
+ * @return array
143
+ */
144
+ protected function _decodeShippingMatrix($input) {
145
+ $shippingMatrix = @unserialize($input);
146
+ $result = array();
147
+ if (!is_array($shippingMatrix)) {
148
+ return $result;
149
+ }
150
+ foreach ($shippingMatrix as $countryDefinition) {
151
+ $result[$countryDefinition['country_id']] = $countryDefinition;
152
+ }
153
+ return $result;
154
+ }
155
+
156
+
157
+
158
+ /**
159
+ * <p>Fetches one line long human readable parcel terminal description from DPD Pudo instance</p>
160
+ * @param array $parcelT
161
+ * @return string
162
+ */
163
+ protected function _getDescription($parcelT) {
164
+ if (!isset($parcelT['Pudo_worktime']) || !$parcelT['Pudo_worktime']) {
165
+ return trim($parcelT['Sh_street'] . ' ' . $parcelT['Sh_city'] . ' ' . $parcelT['Sh_postal']. ', ' . $parcelT['Sh_country']. ' '.$parcelT['Sh_phone']);
166
+ } else {
167
+ return trim($parcelT['Sh_street'] . ' ' . $parcelT['Sh_city'] . ' ' . $parcelT['Sh_postal']. ', ' . $parcelT['Sh_country']. ' '.$parcelT['Sh_phone']
168
+ .' '.$this->_getDpdHelper()->getOpeningsDescriptionFromTerminal($parcelT['Pudo_worktime'], Zend_Locale::getLocaleToTerritory(strtoupper($parcelT['Sh_country']))));
169
+ }
170
+ }
171
+
172
+
173
+
174
+
175
+ /**
176
+ *
177
+ * If the barcode function is available globally
178
+ * @return boolean
179
+ */
180
+ public function isBarcodeFunctionAvailable() {
181
+
182
+ return $this->isAutoSendAvailable();
183
+ }
184
+
185
+ /**
186
+ * <p>Sends parcel data to DPD server for specified order and selected parcel terminal id.</p>
187
+ * @param Mage_Sales_Model_Order $order
188
+ * @param type $selectedOfficeId
189
+ * @return array comma separated parcel numbers in array key of 'barcode'
190
+ */
191
+ public function autoSendData(Mage_Sales_Model_Order $order, $selectedOfficeId) {
192
+ $shippingAddress = $order->getShippingAddress();
193
+ $selectedOffice = $this->getTerminal($selectedOfficeId);
194
+ $requestData = array(
195
+ 'Sh_name' => $shippingAddress->getName(),
196
+ 'Sh_company' => '',
197
+ 'Sh_street' => $this->_getStreetFromDescription($selectedOffice),
198
+ 'Sh_postal' => $selectedOffice->getZipCode(),
199
+ 'Sh_country' => strtolower($selectedOffice->getCountry()),
200
+ 'Sh_city' => $selectedOffice->getCity(),
201
+ 'Sh_contact' => $selectedOffice->getName(),
202
+ 'Sh_phone' => $this->_getPhoneFromDescription($selectedOffice),
203
+ 'Po_remark' => $this->_getRemark($order),
204
+ 'Sh_remark' => '',
205
+ 'Sh_pudo' => 'true',
206
+ 'Sh_pudo_id' => $selectedOfficeId,
207
+ 'Sh_parcel_qty' => $this->_getNumberOfPackagesForOrder($order),
208
+ 'Sh_cust_reference' => $order->getIncrementId(),
209
+ );
210
+
211
+ $phoneNumbers = $this->_getDialCodeHelper()->separatePhoneNumberFromCountryCode($shippingAddress->getTelephone(), $shippingAddress->getCountryId());
212
+ $requestData['Sh_notify_phone_code'] = $phoneNumbers['dial_code'];
213
+ $requestData['Sh_notify_contact_phone'] = $phoneNumbers['phone_number'];
214
+ $requestResult = $this->_getDpdHelper()->getApi($this->getStore(), $this->_code)
215
+ ->autoSendData($requestData);
216
+
217
+ $this->_setDataToOrder($order, $requestResult);
218
+
219
+ //on failure return false
220
+ //is success
221
+ return array('barcode' => '##'. implode(',', $requestResult['Parcel_numbers']).'##');
222
+ }
223
+
224
+
225
+
226
+ /**
227
+ * <p>Returns empty string</p>
228
+ * @param Mage_Sales_Model_Order $order
229
+ * @return string
230
+ */
231
+ protected function _getRemark($order) {
232
+ return '';
233
+ }
234
+
235
+
236
+ /**
237
+ * <p>Returns true if parcel data is sent to DPD server for specified order.</p>
238
+ * @param Mage_Sales_Model_Order $order
239
+ * @return boolean
240
+ */
241
+ public function isDataSent(Mage_Sales_Model_Order $order) {
242
+ $orderData = $this->getDataFromOrder($order);
243
+ if (isset($orderData['DPD_OrderID'])) {
244
+ return true;
245
+ }
246
+ return false;
247
+ }
248
+
249
+ /**
250
+ * <p>Returns packing slip URL if data is sent or false otherwise.</p>
251
+ * @param Mage_Sales_Model_Order $order
252
+ * @return boolean|string
253
+ */
254
+ public function getBarcode(Mage_Sales_Model_Order $order) {
255
+ if (!$this->isBarcodeFunctionAvailable()) {
256
+ return false;
257
+ }
258
+
259
+ $orderData = $this->getDataFromOrder($order);
260
+ if (isset($orderData['PDF_URL']) && $orderData['PDF_URL']) {
261
+ return $orderData['PDF_URL'];
262
+ }
263
+ return false;
264
+ }
265
+
266
+ /**
267
+ * <p>Returns Packing slip PDF file, which can be echoed to browser for current order if one exists.</p>
268
+ * @param Mage_Sales_Model_Order $order
269
+ * @return string
270
+ */
271
+ public function getBarcodePdf(Mage_Sales_Model_Order $order) {
272
+ $orderData = $this->getDataFromOrder($order);
273
+ if (isset($orderData['PDF_URL']) && $orderData['PDF_URL']) {
274
+ return file_get_contents(urldecode($orderData['PDF_URL']));
275
+ }
276
+ }
277
+
278
+
279
+
280
+
281
+ /**
282
+ * <p>Attempts to decode extra data stored within order commetns and return it as array.</p>
283
+ * @param Mage_Sales_Model_Order $order
284
+ * @return array
285
+ */
286
+ public function getDataFromOrder(Mage_Sales_Model_Order $order) {
287
+ return $this->_getOfficeHelper()->getDataFromOrder($order, self::ORDER_COMMENT_START_PREFIX);
288
+ }
289
+
290
+ /**
291
+ * <p>Sets extra data to order and creates specialized order comment for it when neccessary.</p>
292
+ * @param Mage_Sales_Model_Order $order
293
+ * @param array $data
294
+ * @return array
295
+ */
296
+ public function _setDataToOrder(Mage_Sales_Model_Order $order, $data = array()) {
297
+ return $this->_getOfficeHelper()->setDataToOrder($order, $data, self::ORDER_COMMENT_START_PREFIX);
298
+ }
299
+
300
+
301
+
302
+
303
+
304
+ /**
305
+ * <p>Returns array of parcel terminals from DPD server or boolean false if fetching failed.</p>
306
+ * @return array|boolean
307
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getOfficeList()
308
+ */
309
+ public function getOfficeList() {
310
+ $body = $this->_getDpdHelper()->getApi($this->getStore(), $this->_code)->getOfficeList();
311
+ if (!$body || !is_array($body) || !isset($body['data'])) {
312
+ return false;
313
+ }
314
+ $result = array();
315
+ foreach ($body['data'] as $remoteParcelTerminal) {
316
+ $result[] = array(
317
+ 'place_id' => $remoteParcelTerminal['Sh_pudo_id'],
318
+ 'name' => $remoteParcelTerminal['Pudo_name'],
319
+ 'city' => trim($remoteParcelTerminal['Sh_city']),
320
+ 'county' => '',
321
+ 'description' => $this->_getDescription($remoteParcelTerminal),
322
+ 'country' => $remoteParcelTerminal['Sh_country'],
323
+ 'zip' => $remoteParcelTerminal['Sh_postal'],
324
+ 'group_sort' => $this->getGroupSort($remoteParcelTerminal['Sh_city']),
325
+ );
326
+
327
+ }
328
+ if (count($result) == 0) {
329
+ return false;
330
+ }
331
+ return $result;
332
+ }
333
+
334
+
335
+
336
+ /**
337
+ * <p>Returns parcel terminal name when short names are enabled.</p>
338
+ * <p>Returns parcel terminal name with address, telephone, opening times when short names are disabled.</p>
339
+ * @param Eabi_Postoffice_Model_Office $office
340
+ * @return string
341
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getTerminalTitle()
342
+ */
343
+ public function getTerminalTitle(Eabi_Postoffice_Model_Office $office) {
344
+ if ($this->getConfigData('shortname')) {
345
+ return htmlspecialchars($office->getName());
346
+ }
347
+ return htmlspecialchars($office->getName() . ' (' . $office->getDescription().')');
348
+ }
349
+
350
+
351
+ /**
352
+ * <p>Returns parcel terminal name when short names are enabled.</p>
353
+ * <p>Returns parcel terminal name with address, telephone, opening times when short names are disabled.</p>
354
+ * @param Eabi_Postoffice_Model_Office $office
355
+ * @return string
356
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getAdminTerminalTitle()
357
+ */
358
+ public function getAdminTerminalTitle(Eabi_Postoffice_Model_Office $office) {
359
+ if ($this->getConfigData('shortname')) {
360
+ return htmlspecialchars($office->getGroupName().' - '.$office->getName());
361
+ }
362
+ return htmlspecialchars($office->getGroupName().' - '.$office->getName() . ' ' . $office->getDescription());
363
+ }
364
+
365
+
366
+ /**
367
+ *
368
+ * @param Eabi_Postoffice_Model_Office $selectedOffice
369
+ * @return type
370
+ */
371
+ private function _getStreetFromDescription(Eabi_Postoffice_Model_Office $selectedOffice) {
372
+ $zip = $selectedOffice->getZipCode();
373
+ $encoding = 'UTF-8';
374
+ return trim(mb_substr($selectedOffice->getDescription(), 0, mb_strpos($selectedOffice->getDescription(), $zip, 0, $encoding), $encoding));
375
+ }
376
+
377
+ /**
378
+ *
379
+ * @param Eabi_Postoffice_Model_Office $selectedOffice
380
+ * @return string|array
381
+ */
382
+ private function _getPhoneFromDescription(Eabi_Postoffice_Model_Office $selectedOffice) {
383
+ $zip = $selectedOffice->getZipCode();
384
+ $country = $selectedOffice->getCountry();
385
+ $matches = array();
386
+ $isMatched = preg_match('/(?s:[\+][0-9]+)/', $selectedOffice->getDescription(), $matches);
387
+ if ($isMatched) {
388
+ return $matches[0];
389
+ }
390
+ return '';
391
+ }
392
+
393
+
394
+ /**
395
+ * <p>Groups parcel terminals by following rules:</p>
396
+ * <ul>
397
+ <li>In Estonia parcel terminals from Tallinn, Tartu, Pärnu are displayed first respectively and remaining parcel terminals are displayed in alphabetical order.</li>
398
+ <li>In Latvia parcel terminals from Riga, Daugavpils, Liepaja, Jelgava, Jurmala are displayed first respectively and remaining parcel terminals are displayed in alphabetical order.</li>
399
+ <li>In Lithuania parcel terminals from Vilnius, Kaunas, Klaipeda, Siauliai, Alytus are displayed first respectively and remaining parcel terminals are displayed in alphabetical order.</li>
400
+ </ul>
401
+ * @param string $group_name
402
+ * @return int
403
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getGroupSort()
404
+ */
405
+ public function getGroupSort($group_name) {
406
+ $group_name = trim(strtolower($group_name));
407
+ $sorts = array(
408
+ //Estonia
409
+ 'tallinn' => 20,
410
+ 'tartu' => 19,
411
+ 'pärnu' => 18,
412
+
413
+ //Latvia
414
+ 'riga' => 20,
415
+ 'daugavpils' => 19,
416
+ 'liepaja' => 18,
417
+ 'jelgava' => 17,
418
+ 'jurmala' => 16,
419
+
420
+
421
+ //Lithuania
422
+ 'vilnius' => 20,
423
+ 'kaunas' => 19,
424
+ 'klaipeda' => 18,
425
+ 'siauliai' => 17,
426
+ 'alytus' => 16,
427
+
428
+ );
429
+ if (isset($sorts[$group_name]) && $this->getConfigData('sort_offices')) {
430
+ return $sorts[$group_name];
431
+ }
432
+ if (strpos($group_name, '/') > 0 && $this->getConfigData('sort_offices')) {
433
+ return 0;
434
+ }
435
+ return 0;
436
+ }
437
+
438
+ /**
439
+ * <p>Indicates if specified order has been picked up by courier.</p>
440
+ * <p>Should return the following</p>
441
+ * <ul>
442
+ <li><b>true</b> - If the order has been picked up by courier</li>
443
+ <li><b>false</b> - If the order has not been picked up by courier</li>
444
+ <li><b>null</b> - If courier pickup is not applicable to specified order</li>
445
+ </ul>
446
+ * @param Mage_Sales_Model_Order $order
447
+ * @return null|bool
448
+ */
449
+ public function isPickedUpByCourier(Mage_Sales_Model_Order $order) {
450
+ if (!$this->getConfigData('courier_enable')) {
451
+ return null;
452
+ }
453
+ $orderData = $this->getDataFromOrder($order);
454
+ if (isset($orderData['courier_call_id']) && $orderData['courier_call_id']) {
455
+ return true;
456
+ }
457
+ return false;
458
+ }
459
+
460
+
461
+ /**
462
+ * <p>Returns number or parcels for the order according to Maximum Package Weight defined in DPD settings</p>
463
+ * @param Mage_Sales_Model_Order $order
464
+ * @return int
465
+ * @see Eabi_Postoffice_Helper_Data::getNumberOfPackagesFromItemWeights()
466
+ */
467
+ protected function _getNumberOfPackagesForOrder(Mage_Sales_Model_Order $order) {
468
+ $productWeights = array();
469
+ foreach ($order->getAllVisibleItems() as $orderItem) {
470
+ /* @var $orderItem Mage_Sales_Model_Order_Item */
471
+ for ($i = 0; $i < ($orderItem->getQtyOrdered() - $orderItem->getQtyRefunded()); $i++) {
472
+ $productWeights[] = $orderItem->getWeight();
473
+ }
474
+
475
+ }
476
+ return $this->_getOfficeHelper()->getNumberOfPackagesFromItemWeights($productWeights, $this->getConfigData('max_package_weight'));
477
+ }
478
+
479
+
480
+ /**
481
+ * Gets config data only for this instance
482
+ * @param string $field
483
+ * @return mixed
484
+ */
485
+ public function getConfigDataForThis($field) {
486
+ if (empty($this->_code)) {
487
+ return false;
488
+ }
489
+ $path = 'carriers/'.$this->_code.'/'.$field;
490
+ return Mage::getStoreConfig($path, $this->getStore());
491
+ }
492
+
493
+ /**
494
+ * <p>Override this function in order to return senddata_event always manual, when http_request_timeout is greater than 10 seconds</p>
495
+ * @param string $field
496
+ * @return mixed
497
+ */
498
+ public function getConfigData($field) {
499
+ if (empty($this->_code)) {
500
+ return false;
501
+ }
502
+ return $this->_getConfigDataOverride($field, $this->_code);
503
+ }
504
+
505
+ /**
506
+ * <p>Override is performed here</p>
507
+ * @param string $field
508
+ * @param string $code
509
+ * @return string
510
+ * @see Eabi_DpdEE_Model_Post::getConfigData()
511
+ */
512
+ protected function _getConfigDataOverride($field, $code) {
513
+ if ($field == 'senddata_event') {
514
+ $timeout = Mage::getStoreConfig('carriers/'.$code.'/http_request_timeout', $this->getStore());
515
+ if ($timeout > 10) {
516
+ return 'manual';
517
+ }
518
+ }
519
+ $path = 'carriers/'.$code.'/'.$field;
520
+ return Mage::getStoreConfig($path, $this->getStore());
521
+ }
522
+
523
+
524
+ /**
525
+ *
526
+ * @return Eabi_DpdEE_Helper_Data
527
+ */
528
+ protected function _getDpdHelper() {
529
+ return Mage::helper('eabi_dpdee');
530
+ }
531
+
532
+
533
+
534
+
535
+ }
536
+
app/code/community/Eabi/DpdEE/Model/Source/Label/Position.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Source model of all possible DPD Packing slip label positions</p>
36
+ *
37
+ * @author Matis
38
+ */
39
+ class Eabi_DpdEE_Model_Source_Label_Position {
40
+
41
+ public function toOptionArray() {
42
+ $options = array();
43
+
44
+
45
+ $positions = array(
46
+ '1234',
47
+ '4123',
48
+ '3412',
49
+ '3421',
50
+ );
51
+ foreach ($positions as $position) {
52
+ $options[] = array(
53
+ 'label' => $this->_getDpdHelper()->__('Position: %s', $position),
54
+ 'value' => $position,
55
+ );
56
+ }
57
+
58
+
59
+ return $options;
60
+ }
61
+
62
+ /**
63
+ *
64
+ * @return Eabi_DpdEE_Helper_Data
65
+ */
66
+ protected function _getDpdHelper() {
67
+ return Mage::helper('eabi_dpdee');
68
+ }
69
+ }
70
+
app/code/community/Eabi/DpdEE/Model/Source/Service.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+
34
+ /**
35
+ * <p>Source model of all possible DPD API service codes</p>
36
+ *
37
+ * @author Matis
38
+ */
39
+ class Eabi_DpdEE_Model_Source_Service {
40
+
41
+ public function toOptionArray() {
42
+ $options = array();
43
+ $options[] = array(
44
+ 'label' => $this->_getDpdHelper()->__('Pickup Order only'),
45
+ 'value' => 'PO',
46
+ );
47
+ $options[] = array(
48
+ 'label' => $this->_getDpdHelper()->__('Labels Only'),
49
+ 'value' => 'LO',
50
+ );
51
+ $options[] = array(
52
+ 'label' => $this->_getDpdHelper()->__('Full Order'),
53
+ 'value' => 'FO',
54
+ );
55
+ $options[] = array(
56
+ 'label' => $this->_getDpdHelper()->__('Collection Request'),
57
+ 'value' => 'CR',
58
+ );
59
+
60
+ return $options;
61
+
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @return Eabi_DpdEE_Helper_Data
67
+ */
68
+ protected function _getDpdHelper() {
69
+ return Mage::helper('eabi_dpdee');
70
+ }
71
+ }
72
+
app/code/community/Eabi/DpdEE/etc/config.xml ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+
35
+
36
+ <config>
37
+ <modules>
38
+ <Eabi_DpdEE>
39
+ <version>0.1.5</version>
40
+ </Eabi_DpdEE>
41
+ </modules>
42
+
43
+
44
+ <frontend>
45
+ <layout>
46
+ <updates>
47
+ <eabi_dpdee>
48
+ <file>eabi_dpdee.xml</file>
49
+ </eabi_dpdee>
50
+ </updates>
51
+ </layout>
52
+ <translate>
53
+ <modules>
54
+ <eabi_dpdee>
55
+ <files>
56
+ <default>Eabi_DpdEE.csv</default>
57
+ </files>
58
+ </eabi_dpdee>
59
+ </modules>
60
+ </translate>
61
+ </frontend>
62
+
63
+ <adminhtml>
64
+ <layout>
65
+ <updates>
66
+ <eabi_dpdee>
67
+ <file>eabi_dpdee.xml</file>
68
+ </eabi_dpdee>
69
+ </updates>
70
+ </layout>
71
+ <translate>
72
+ <modules>
73
+ <eabi_dpdee>
74
+ <files>
75
+ <default>Eabi_DpdEE.csv</default>
76
+ </files>
77
+ </eabi_dpdee>
78
+ </modules>
79
+ </translate>
80
+ <events>
81
+ <sales_order_shipment_save_after>
82
+ <observers>
83
+ <eabi_dpdee_add_tracking_number>
84
+ <type>model</type>
85
+ <class>Eabi_DpdEE_Model_Observer</class>
86
+ <method>addTrackingToShipment</method>
87
+ </eabi_dpdee_add_tracking_number>
88
+ </observers>
89
+ </sales_order_shipment_save_after>
90
+ </events>
91
+
92
+ </adminhtml>
93
+
94
+ <admin>
95
+
96
+ <translate>
97
+ <modules>
98
+ <eabi_dpdee>
99
+ <files>
100
+ <default>Eabi_DpdEE.csv</default>
101
+ </files>
102
+ </eabi_dpdee>
103
+ </modules>
104
+ </translate>
105
+ <routers>
106
+ <eabi_dpdee>
107
+ <use>admin</use>
108
+ <args>
109
+ <module>Eabi_DpdEE</module>
110
+ <frontName>eabi_dpdee</frontName>
111
+ </args>
112
+ </eabi_dpdee>
113
+ </routers>
114
+
115
+ </admin>
116
+
117
+ <global>
118
+ <models>
119
+ <eabi_dpdee>
120
+ <class>Eabi_DpdEE_Model</class>
121
+ </eabi_dpdee>
122
+ </models>
123
+ <blocks>
124
+ <eabi_dpdee>
125
+ <class>Eabi_DpdEE_Block</class>
126
+ </eabi_dpdee>
127
+ </blocks>
128
+ <resources>
129
+ <eabi_dpdee_setup>
130
+ <setup>
131
+ <module>Eabi_DpdEE</module>
132
+ </setup>
133
+ <connection>
134
+ <use>core_setup</use>
135
+ </connection>
136
+ </eabi_dpdee_setup>
137
+ <eabi_dpdee_write>
138
+ <setup>
139
+ <module>Eabi_DpdEE</module>
140
+ </setup>
141
+ <connection>
142
+ <use>core_write</use>
143
+ </connection>
144
+ </eabi_dpdee_write>
145
+ <eabi_dpdee_read>
146
+ <setup>
147
+ <module>Eabi_DpdEE</module>
148
+ </setup>
149
+ <connection>
150
+ <use>core_read</use>
151
+ </connection>
152
+ </eabi_dpdee_read>
153
+ </resources>
154
+ <helpers>
155
+ <eabi_dpdee>
156
+ <class>Eabi_DpdEE_Helper</class>
157
+ </eabi_dpdee>
158
+ </helpers>
159
+
160
+
161
+ </global>
162
+ <default>
163
+ <carriers>
164
+ <eabidpdee>
165
+ <active>0</active>
166
+ <title>DPD Pakipoodi</title>
167
+ <max_package_weight>20</max_package_weight>
168
+ <sort_offices>1</sort_offices>
169
+ <shortname>1</shortname>
170
+ <drop_menu_selection>1</drop_menu_selection>
171
+ <disable_session>1</disable_session>
172
+ <model>eabi_dpdee/post</model>
173
+ <update_interval>1440</update_interval>
174
+ <sallowspecific>1</sallowspecific>
175
+ <specificcountry>EE,LV,LT</specificcountry>
176
+ <courier_enable>1</courier_enable>
177
+ <api_url>http://www.pakivedu.ee/rpc/gateway</api_url>
178
+ <handling_fee>4.90</handling_fee>
179
+ <handling_fee_country><![CDATA[a:3:{s:18:"_1388439524852_852";a:4:{s:10:"country_id";s:2:"EE";s:10:"base_price";s:4:"4.90";s:8:"kg_price";s:1:"0";s:18:"free_shipping_from";s:0:"";}s:17:"_1388442604053_53";a:4:{s:10:"country_id";s:2:"LV";s:10:"base_price";s:5:"12.90";s:8:"kg_price";s:1:"0";s:18:"free_shipping_from";s:0:"";}s:18:"_1388709088932_932";a:4:{s:10:"country_id";s:2:"LT";s:10:"base_price";s:5:"13.90";s:8:"kg_price";s:1:"0";s:18:"free_shipping_from";s:0:"";}}]]></handling_fee_country>
180
+ <senddata_service>LO</senddata_service>
181
+ <po_save_address>0</po_save_address>
182
+ <label_position>1234</label_position>
183
+ <return_country>EE</return_country>
184
+ <senddata_event>manual</senddata_event>
185
+ <enable_cod>0</enable_cod>
186
+ <use_per_item_weight>1</use_per_item_weight>
187
+ <po_show_on_label>0</po_show_on_label>
188
+ <http_request_timeout>60</http_request_timeout>
189
+
190
+ </eabidpdee>
191
+ <eabidpdeeflat>
192
+ <active>0</active>
193
+ <title>DPD kulleriga koju või tööle</title>
194
+ <max_package_weight>31.5</max_package_weight>
195
+ <drop_menu_selection>1</drop_menu_selection>
196
+ <disable_session>1</disable_session>
197
+ <model>eabi_dpdee/flat</model>
198
+ <update_interval>1440</update_interval>
199
+ <sallowspecific>1</sallowspecific>
200
+ <specificcountry>EE,LV,LT</specificcountry>
201
+ <handling_action>O</handling_action>
202
+ <handling_fee>7.97</handling_fee>
203
+ <handling_fee_country><![CDATA[a:3:{s:18:"_1388700940288_288";a:4:{s:10:"country_id";s:2:"EE";s:10:"base_price";s:3:"5.8";s:8:"kg_price";s:4:"1.28";s:18:"free_shipping_from";s:0:"";}s:18:"_1388700961178_178";a:4:{s:10:"country_id";s:2:"LV";s:10:"base_price";s:5:"10.38";s:8:"kg_price";s:4:"3.15";s:18:"free_shipping_from";s:0:"";}s:18:"_1388700962221_221";a:4:{s:10:"country_id";s:2:"LT";s:10:"base_price";s:5:"11.75";s:8:"kg_price";s:4:"3.85";s:18:"free_shipping_from";s:0:"";}}]]></handling_fee_country>
204
+ <enable_cod>0</enable_cod>
205
+ <use_per_item_weight>1</use_per_item_weight>
206
+
207
+ </eabidpdeeflat>
208
+ </carriers>
209
+ </default>
210
+
211
+ </config>
app/code/community/Eabi/DpdEE/etc/system.xml ADDED
@@ -0,0 +1,690 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+
35
+
36
+ <config>
37
+ <sections>
38
+ <carriers>
39
+ <groups>
40
+ <eabidpdee translate="label" module="eabi_dpdee">
41
+ <label>DPD - Pakivedu.ee - Pakipood</label>
42
+ <sort_order>198</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <comment><![CDATA[
47
+ <a href="http://www.e-abi.ee" target="_blank"><IMG border="0" src="http://www.e-abi.ee/skin/frontend/default/electronics3/images/logo-web.png"></a>
48
+ <div style="margin-top:4px;margin-bottom:4px; color:gray;"></div>
49
+ <div style="margin-top:4px;"><b>Aktsiamaailm OÜ, <a href="mailto:info@e-abi.ee">info@e-abi.ee</a></b></div>
50
+ <hr /><br />
51
+ ]]>
52
+ </comment>
53
+ <fields>
54
+ <active translate="label">
55
+ <label>Enabled</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>adminhtml/system_config_source_yesno</source_model>
58
+ <sort_order>1</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </active>
63
+ <title translate="label">
64
+ <label>Title</label>
65
+ <frontend_type>text</frontend_type>
66
+ <sort_order>2</sort_order>
67
+ <show_in_default>1</show_in_default>
68
+ <show_in_website>1</show_in_website>
69
+ <show_in_store>1</show_in_store>
70
+ </title>
71
+
72
+ <handling_fee translate="label">
73
+ <label>Price</label>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>10</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ </handling_fee>
80
+ <handling_fee_country translate="label comment">
81
+ <label>Price per country</label>
82
+ <frontend_type>text</frontend_type>
83
+ <frontend_model>eabi_dpdee/adminhtml_config_form_field_country</frontend_model>
84
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
85
+ <sort_order>11</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <comment>If country is not listed here, but this method is available, then general handling fee is applied</comment>
90
+ </handling_fee_country>
91
+ <shortname translate="label">
92
+ <label>Show short office names</label>
93
+ <frontend_type>select</frontend_type>
94
+ <source_model>adminhtml/system_config_source_yesno</source_model>
95
+ <sort_order>20</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ <comment>Yes: Shows only office name&lt;br/&gt;No: Shows office name and address</comment>
100
+ </shortname>
101
+ <sort_offices translate="label comment">
102
+ <label>Sort offices by priority</label>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>adminhtml/system_config_source_yesno</source_model>
105
+ <sort_order>30</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ <comment>Yes: Offices from bigger cities will be in front&lt;br/&gt;No: Offices are sorted alphabetically&lt;br/&gt;&lt;b&gt;changing this setting requires rebuild&lt;/b&gt;</comment>
110
+ </sort_offices>
111
+
112
+ <checkitems translate="label">
113
+ <label>Disable this carrier if product's short description contains HTML comment &amp;lt;!-- no dpd_ee_module --&amp;gt;</label>
114
+ <frontend_type>select</frontend_type>
115
+ <source_model>adminhtml/system_config_source_yesno</source_model>
116
+ <sort_order>40</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>1</show_in_store>
120
+ </checkitems>
121
+ <max_package_weight translate="label">
122
+ <label>Maximum allowed package weight for this carrier</label>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>50</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ </max_package_weight>
129
+
130
+ <handling_action translate="label comment">
131
+ <label>Handling action</label>
132
+ <frontend_type>select</frontend_type>
133
+ <source_model>shipping/source_handlingAction</source_model>
134
+ <sort_order>60</sort_order>
135
+ <show_in_default>1</show_in_default>
136
+ <show_in_website>1</show_in_website>
137
+ <show_in_store>1</show_in_store>
138
+ <comment>Per Order: Shipping cost equals Shipping price&lt;br/&gt;Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price</comment>
139
+ </handling_action>
140
+
141
+ <enable_free_shipping translate="label">
142
+ <label>Enable free shipping</label>
143
+ <frontend_type>select</frontend_type>
144
+ <source_model>adminhtml/system_config_source_yesno</source_model>
145
+ <sort_order>70</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ </enable_free_shipping>
150
+ <free_shipping_from translate="label">
151
+ <label>Free shipping subtotal</label>
152
+ <frontend_type>text</frontend_type>
153
+ <sort_order>80</sort_order>
154
+ <show_in_default>1</show_in_default>
155
+ <show_in_website>1</show_in_website>
156
+ <show_in_store>1</show_in_store>
157
+ </free_shipping_from>
158
+
159
+ <senddata_enable translate="label">
160
+ <label>Auto send data to DPD server</label>
161
+ <frontend_type>select</frontend_type>
162
+ <source_model>adminhtml/system_config_source_yesno</source_model>
163
+ <sort_order>1000</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ <comment>Only if the order has been paid for or the order is COD</comment>
168
+ </senddata_enable>
169
+ <courier_enable translate="label">
170
+ <label>Allow courier pickup</label>
171
+ <frontend_type>select</frontend_type>
172
+ <source_model>adminhtml/system_config_source_yesno</source_model>
173
+ <sort_order>1001</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>1</show_in_store>
177
+ <comment>Only if the order has been paid for or the order is COD</comment>
178
+ </courier_enable>
179
+
180
+
181
+ <sendpackage_username translate="label">
182
+ <label>DPD Self service username</label>
183
+ <frontend_type>text</frontend_type>
184
+ <sort_order>1010</sort_order>
185
+ <show_in_default>1</show_in_default>
186
+ <show_in_website>1</show_in_website>
187
+ <show_in_store>1</show_in_store>
188
+ <depends>
189
+ <senddata_enable>1</senddata_enable>
190
+ </depends>
191
+ <validate>required-entry</validate>
192
+ </sendpackage_username>
193
+ <sendpackage_password translate="label">
194
+ <label>DPD Self-service password</label>
195
+ <frontend_type>password</frontend_type>
196
+ <sort_order>1020</sort_order>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>1</show_in_store>
200
+ <depends>
201
+ <senddata_enable>1</senddata_enable>
202
+ </depends>
203
+ <validate>required-entry</validate>
204
+ </sendpackage_password>
205
+
206
+ <senddata_event translate="label">
207
+ <label>When to send parcel data</label>
208
+ <frontend_type>select</frontend_type>
209
+ <source_model>eabi_postoffice/source_sendevent</source_model>
210
+ <sort_order>1030</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ <depends>
215
+ <senddata_enable>1</senddata_enable>
216
+ </depends>
217
+ <validate>required-entry</validate>
218
+ </senddata_event>
219
+ <http_request_timeout translate="label">
220
+ <label>Http request timeout</label>
221
+ <comment>If timeout is greater than 10 seconds, then parcel data can only be sent manually. This field with the limitation will be removed latest 17th of February</comment>
222
+ <frontend_type>text</frontend_type>
223
+ <sort_order>1031</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>0</show_in_website>
226
+ <show_in_store>0</show_in_store>
227
+ <depends>
228
+ <senddata_enable>1</senddata_enable>
229
+ </depends>
230
+ <validate>required-entry validate-digits</validate>
231
+ </http_request_timeout>
232
+
233
+ <return_name translate="label">
234
+ <label>Pickup address name</label>
235
+ <frontend_type>text</frontend_type>
236
+ <sort_order>1050</sort_order>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <show_in_store>1</show_in_store>
240
+ <depends>
241
+ <senddata_enable>1</senddata_enable>
242
+ </depends>
243
+ <validate>required-entry</validate>
244
+ </return_name>
245
+ <return_company translate="label">
246
+ <label>Pickup address company</label>
247
+ <frontend_type>text</frontend_type>
248
+ <sort_order>1060</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>1</show_in_website>
251
+ <show_in_store>1</show_in_store>
252
+ <depends>
253
+ <senddata_enable>1</senddata_enable>
254
+ </depends>
255
+ <validate>required-entry</validate>
256
+ </return_company>
257
+ <return_email translate="label">
258
+ <label>Pickup address e-mail</label>
259
+ <frontend_type>text</frontend_type>
260
+ <sort_order>1070</sort_order>
261
+ <show_in_default>1</show_in_default>
262
+ <show_in_website>1</show_in_website>
263
+ <show_in_store>1</show_in_store>
264
+ <validate>required-entry validate-email</validate>
265
+ <depends>
266
+ <senddata_enable>1</senddata_enable>
267
+ </depends>
268
+ </return_email>
269
+ <return_phone translate="label">
270
+ <label>Pickup address phone</label>
271
+ <frontend_type>text</frontend_type>
272
+ <sort_order>1080</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>1</show_in_store>
276
+ <depends>
277
+ <senddata_enable>1</senddata_enable>
278
+ </depends>
279
+ <validate>required-entry</validate>
280
+ </return_phone>
281
+ <return_street translate="label">
282
+ <label>Pickup address street</label>
283
+ <frontend_type>text</frontend_type>
284
+ <sort_order>1090</sort_order>
285
+ <show_in_default>1</show_in_default>
286
+ <show_in_website>1</show_in_website>
287
+ <show_in_store>1</show_in_store>
288
+ <depends>
289
+ <senddata_enable>1</senddata_enable>
290
+ </depends>
291
+ <validate>required-entry</validate>
292
+ </return_street>
293
+ <return_citycounty translate="label">
294
+ <label>Pickup address city, county</label>
295
+ <frontend_type>text</frontend_type>
296
+ <sort_order>1100</sort_order>
297
+ <show_in_default>1</show_in_default>
298
+ <show_in_website>1</show_in_website>
299
+ <show_in_store>1</show_in_store>
300
+ <depends>
301
+ <senddata_enable>1</senddata_enable>
302
+ </depends>
303
+ <validate>required-entry</validate>
304
+ </return_citycounty>
305
+ <return_postcode translate="label">
306
+ <label>Pickup address zip code</label>
307
+ <frontend_type>text</frontend_type>
308
+ <sort_order>1110</sort_order>
309
+ <show_in_default>1</show_in_default>
310
+ <show_in_website>1</show_in_website>
311
+ <show_in_store>1</show_in_store>
312
+ <depends>
313
+ <senddata_enable>1</senddata_enable>
314
+ </depends>
315
+ <validate>required-entry</validate>
316
+ </return_postcode>
317
+ <return_country translate="label">
318
+ <label>Pickup address country</label>
319
+ <frontend_type>select</frontend_type>
320
+ <source_model>adminhtml/system_config_source_country</source_model>
321
+ <sort_order>1120</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
+ <depends>
326
+ <senddata_enable>1</senddata_enable>
327
+ </depends>
328
+ <validate>required-entry</validate>
329
+ </return_country>
330
+
331
+ <po_show_on_label translate="label">
332
+ <label>Show pickup address on packing label</label>
333
+ <frontend_type>select</frontend_type>
334
+ <source_model>adminhtml/system_config_source_yesno</source_model>
335
+ <sort_order>1130</sort_order>
336
+ <show_in_default>1</show_in_default>
337
+ <show_in_website>1</show_in_website>
338
+ <show_in_store>1</show_in_store>
339
+ </po_show_on_label>
340
+ <!--po_save_address translate="label">
341
+ <label>Save address for current customer</label>
342
+ <frontend_type>select</frontend_type>
343
+ <source_model>adminhtml/system_config_source_yesno</source_model>
344
+ <sort_order>1140</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>1</show_in_website>
347
+ <show_in_store>1</show_in_store>
348
+ </po_save_address-->
349
+ <label_position translate="label">
350
+ <label>Labels position on packing slip</label>
351
+ <frontend_type>select</frontend_type>
352
+ <source_model>eabi_dpdee/source_label_position</source_model>
353
+ <sort_order>1150</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <show_in_store>1</show_in_store>
357
+ </label_position>
358
+ <api_url translate="label">
359
+ <label>Api URL</label>
360
+ <frontend_type>text</frontend_type>
361
+ <sort_order>1160</sort_order>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>0</show_in_website>
364
+ <show_in_store>0</show_in_store>
365
+ <comment><![CDATA[<ul><li><b>Live:</b> http://www.pakivedu.ee/rpc/gateway</li><li><b>Test:</b> http://dpd.surflink.ee/rpc/gateway/</li></ul>]]></comment>
366
+ <depends>
367
+ <senddata_enable>1</senddata_enable>
368
+ </depends>
369
+ <validate>required-entry</validate>
370
+ </api_url>
371
+
372
+
373
+
374
+ <showmethod translate="label">
375
+ <label>Show method if not applicable</label>
376
+ <frontend_type>select</frontend_type>
377
+ <sort_order>10000</sort_order>
378
+ <source_model>adminhtml/system_config_source_yesno</source_model>
379
+ <show_in_default>1</show_in_default>
380
+ <show_in_website>1</show_in_website>
381
+ <show_in_store>1</show_in_store>
382
+ </showmethod>
383
+ <specificerrmsg translate="label">
384
+ <label>Error message displayed to the user</label>
385
+ <frontend_type>textarea</frontend_type>
386
+ <sort_order>10100</sort_order>
387
+ <show_in_default>1</show_in_default>
388
+ <show_in_website>1</show_in_website>
389
+ <show_in_store>1</show_in_store>
390
+ </specificerrmsg>
391
+ <sallowspecific translate="label">
392
+ <label>Ship to applicable countries</label>
393
+ <frontend_type>select</frontend_type>
394
+ <sort_order>10110</sort_order>
395
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
396
+ <show_in_default>1</show_in_default>
397
+ <show_in_website>1</show_in_website>
398
+ <show_in_store>1</show_in_store>
399
+ </sallowspecific>
400
+ <specificcountry translate="label">
401
+ <label>Ship to Specific countries</label>
402
+ <frontend_type>multiselect</frontend_type>
403
+ <sort_order>10120</sort_order>
404
+ <source_model>adminhtml/system_config_source_country</source_model>
405
+ <depends>
406
+ <sallowspecific>1</sallowspecific>
407
+ </depends>
408
+ <show_in_default>1</show_in_default>
409
+ <show_in_website>1</show_in_website>
410
+ <show_in_store>1</show_in_store>
411
+ </specificcountry>
412
+ <group_width translate="label comment">
413
+ <label>Width in pixels for city select menu</label>
414
+ <frontend_type>text</frontend_type>
415
+ <sort_order>10130</sort_order>
416
+ <show_in_default>1</show_in_default>
417
+ <show_in_website>1</show_in_website>
418
+ <show_in_store>1</show_in_store>
419
+ <comment>Use only when you feel that select menu is too wide.</comment>
420
+ </group_width>
421
+ <office_width translate="label comment">
422
+ <label>Width in pixels for office select menu</label>
423
+ <frontend_type>text</frontend_type>
424
+ <sort_order>10140</sort_order>
425
+ <show_in_default>1</show_in_default>
426
+ <show_in_website>1</show_in_website>
427
+ <show_in_store>1</show_in_store>
428
+ <comment>Use only when you feel that select menu is too wide.</comment>
429
+ </office_width>
430
+ <drop_menu_selection translate="label comment">
431
+ <label>Show customer one dropdown instead of two</label>
432
+ <frontend_type>select</frontend_type>
433
+ <source_model>adminhtml/system_config_source_yesno</source_model>
434
+ <sort_order>10150</sort_order>
435
+ <show_in_default>1</show_in_default>
436
+ <show_in_website>1</show_in_website>
437
+ <show_in_store>1</show_in_store>
438
+ <comment>If this setting is enabled, then customer will be displayed only with a list of stores you entered.&lt;br/&gt;If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.</comment>
439
+ </drop_menu_selection>
440
+ <disable_session translate="label">
441
+ <label>Disable populating list of last selected parcel terminals</label>
442
+ <frontend_type>select</frontend_type>
443
+ <source_model>adminhtml/system_config_source_yesno</source_model>
444
+ <sort_order>10160</sort_order>
445
+ <show_in_default>1</show_in_default>
446
+ <show_in_website>1</show_in_website>
447
+ <show_in_store>1</show_in_store>
448
+ </disable_session>
449
+ <update_interval translate="label comment">
450
+ <label>Update interval for the postoffice list in minutes</label>
451
+ <frontend_type>text</frontend_type>
452
+ <sort_order>10170</sort_order>
453
+ <show_in_default>1</show_in_default>
454
+ <show_in_website>1</show_in_website>
455
+ <show_in_store>1</show_in_store>
456
+ <comment>It is not recommended to update the list of offices more often than once a day.</comment>
457
+ </update_interval>
458
+ <!--enable_cod translate="label comment">
459
+ <label>Enable Cash on Delivery (requires extra plugin)</label>
460
+ <frontend_type>select</frontend_type>
461
+ <source_model>adminhtml/system_config_source_yesno</source_model>
462
+ <sort_order>10180</sort_order>
463
+ <show_in_default>1</show_in_default>
464
+ <show_in_website>1</show_in_website>
465
+ <show_in_store>1</show_in_store>
466
+ </enable_cod>
467
+ <cod_fee translate="label">
468
+ <label>Extra fee, when using Cash on delivery</label>
469
+ <frontend_type>text</frontend_type>
470
+ <sort_order>10190</sort_order>
471
+ <show_in_default>1</show_in_default>
472
+ <show_in_website>1</show_in_website>
473
+ <show_in_store>1</show_in_store>
474
+ <depends>
475
+ <enable_cod>1</enable_cod>
476
+ </depends>
477
+ </cod_fee-->
478
+ <rebuild_all translate="label comment">
479
+ <label>Rebuild Postoffice List</label>
480
+ <frontend_type>label</frontend_type>
481
+ <sort_order>99999</sort_order>
482
+ <frontend_model>eabi_postoffice/config_rebuildbutton</frontend_model>
483
+ <show_in_default>1</show_in_default>
484
+ <show_in_website>1</show_in_website>
485
+ <show_in_store>1</show_in_store>
486
+ <comment>If post offices are not displayed correctly, then rebuilding the list may help</comment>
487
+ </rebuild_all>
488
+ <sort_order translate="label">
489
+ <label>Sort order</label>
490
+ <frontend_type>text</frontend_type>
491
+ <sort_order>1000000</sort_order>
492
+ <show_in_default>1</show_in_default>
493
+ <show_in_website>1</show_in_website>
494
+ <show_in_store>1</show_in_store>
495
+ </sort_order>
496
+ <removal translate="">
497
+ <label></label>
498
+ <frontend_model>eabi_postoffice/adminhtml_config_form_field_remove</frontend_model>
499
+ <sort_order>1000001</sort_order>
500
+ <show_in_default>1</show_in_default>
501
+ <show_in_website>0</show_in_website>
502
+ <show_in_store>0</show_in_store>
503
+ </removal>
504
+ </fields>
505
+ </eabidpdee>
506
+ <eabidpdeeflat translate="label" module="eabi_dpdee">
507
+ <label>DPD - Pakivedu.ee - Courier service</label>
508
+ <sort_order>199</sort_order>
509
+ <show_in_default>1</show_in_default>
510
+ <show_in_website>1</show_in_website>
511
+ <show_in_store>1</show_in_store>
512
+ <comment><![CDATA[
513
+ <a href="http://www.e-abi.ee" target="_blank"><IMG border="0" src="http://www.e-abi.ee/skin/frontend/default/electronics3/images/logo-web.png"></a>
514
+ <div style="margin-top:4px;margin-bottom:4px; color:gray;"></div>
515
+ <div style="margin-top:4px;"><b>Aktsiamaailm OÜ, <a href="mailto:info@e-abi.ee">info@e-abi.ee</a></b></div>
516
+ <hr /><br />
517
+ ]]>
518
+ </comment>
519
+ <fields>
520
+ <active translate="label">
521
+ <label>Enabled</label>
522
+ <frontend_type>select</frontend_type>
523
+ <source_model>adminhtml/system_config_source_yesno</source_model>
524
+ <sort_order>1</sort_order>
525
+ <show_in_default>1</show_in_default>
526
+ <show_in_website>1</show_in_website>
527
+ <show_in_store>1</show_in_store>
528
+ </active>
529
+ <title translate="label">
530
+ <label>Title</label>
531
+ <frontend_type>text</frontend_type>
532
+ <sort_order>2</sort_order>
533
+ <show_in_default>1</show_in_default>
534
+ <show_in_website>1</show_in_website>
535
+ <show_in_store>1</show_in_store>
536
+ </title>
537
+
538
+ <handling_fee translate="label">
539
+ <label>Price</label>
540
+ <frontend_type>text</frontend_type>
541
+ <sort_order>10</sort_order>
542
+ <show_in_default>1</show_in_default>
543
+ <show_in_website>1</show_in_website>
544
+ <show_in_store>1</show_in_store>
545
+ </handling_fee>
546
+ <handling_fee_country translate="label comment">
547
+ <label>Price per country</label>
548
+ <frontend_type>text</frontend_type>
549
+ <frontend_model>eabi_dpdee/adminhtml_config_form_field_country</frontend_model>
550
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
551
+ <sort_order>11</sort_order>
552
+ <show_in_default>1</show_in_default>
553
+ <show_in_website>1</show_in_website>
554
+ <show_in_store>1</show_in_store>
555
+ <comment>If country is not listed here, but this method is available, then general handling fee is applied</comment>
556
+ </handling_fee_country>
557
+
558
+ <checkitems translate="label">
559
+ <label>Disable this carrier if product's short description contains HTML comment &amp;lt;!-- no dpd_ee_module --&amp;gt;</label>
560
+ <frontend_type>select</frontend_type>
561
+ <source_model>adminhtml/system_config_source_yesno</source_model>
562
+ <sort_order>40</sort_order>
563
+ <show_in_default>1</show_in_default>
564
+ <show_in_website>1</show_in_website>
565
+ <show_in_store>1</show_in_store>
566
+ </checkitems>
567
+ <max_package_weight translate="label">
568
+ <label>Maximum allowed package weight for this carrier</label>
569
+ <frontend_type>text</frontend_type>
570
+ <sort_order>50</sort_order>
571
+ <show_in_default>1</show_in_default>
572
+ <show_in_website>1</show_in_website>
573
+ <show_in_store>1</show_in_store>
574
+ </max_package_weight>
575
+
576
+ <handling_action translate="label comment">
577
+ <label>Handling action</label>
578
+ <frontend_type>select</frontend_type>
579
+ <source_model>shipping/source_handlingAction</source_model>
580
+ <sort_order>60</sort_order>
581
+ <show_in_default>1</show_in_default>
582
+ <show_in_website>1</show_in_website>
583
+ <show_in_store>1</show_in_store>
584
+ <comment>Per Order: Shipping cost equals Shipping price&lt;br/&gt;Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price</comment>
585
+ </handling_action>
586
+
587
+ <enable_free_shipping translate="label">
588
+ <label>Enable free shipping</label>
589
+ <frontend_type>select</frontend_type>
590
+ <source_model>adminhtml/system_config_source_yesno</source_model>
591
+ <sort_order>70</sort_order>
592
+ <show_in_default>1</show_in_default>
593
+ <show_in_website>1</show_in_website>
594
+ <show_in_store>1</show_in_store>
595
+ </enable_free_shipping>
596
+ <free_shipping_from translate="label">
597
+ <label>Free shipping subtotal</label>
598
+ <frontend_type>text</frontend_type>
599
+ <sort_order>80</sort_order>
600
+ <show_in_default>1</show_in_default>
601
+ <show_in_website>1</show_in_website>
602
+ <show_in_store>1</show_in_store>
603
+ </free_shipping_from>
604
+
605
+
606
+
607
+
608
+ <showmethod translate="label">
609
+ <label>Show method if not applicable</label>
610
+ <frontend_type>select</frontend_type>
611
+ <sort_order>10000</sort_order>
612
+ <source_model>adminhtml/system_config_source_yesno</source_model>
613
+ <show_in_default>1</show_in_default>
614
+ <show_in_website>1</show_in_website>
615
+ <show_in_store>1</show_in_store>
616
+ </showmethod>
617
+ <specificerrmsg translate="label">
618
+ <label>Error message displayed to the user</label>
619
+ <frontend_type>textarea</frontend_type>
620
+ <sort_order>10100</sort_order>
621
+ <show_in_default>1</show_in_default>
622
+ <show_in_website>1</show_in_website>
623
+ <show_in_store>1</show_in_store>
624
+ </specificerrmsg>
625
+ <sallowspecific translate="label">
626
+ <label>Ship to applicable countries</label>
627
+ <frontend_type>select</frontend_type>
628
+ <sort_order>10110</sort_order>
629
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
630
+ <show_in_default>1</show_in_default>
631
+ <show_in_website>1</show_in_website>
632
+ <show_in_store>1</show_in_store>
633
+ </sallowspecific>
634
+ <specificcountry translate="label">
635
+ <label>Ship to Specific countries</label>
636
+ <frontend_type>multiselect</frontend_type>
637
+ <sort_order>10120</sort_order>
638
+ <source_model>adminhtml/system_config_source_country</source_model>
639
+ <depends>
640
+ <sallowspecific>1</sallowspecific>
641
+ </depends>
642
+ <show_in_default>1</show_in_default>
643
+ <show_in_website>1</show_in_website>
644
+ <show_in_store>1</show_in_store>
645
+ </specificcountry>
646
+ <!--enable_cod translate="label comment">
647
+ <label>Enable Cash on Delivery (requires extra plugin)</label>
648
+ <frontend_type>select</frontend_type>
649
+ <source_model>adminhtml/system_config_source_yesno</source_model>
650
+ <sort_order>10180</sort_order>
651
+ <show_in_default>1</show_in_default>
652
+ <show_in_website>1</show_in_website>
653
+ <show_in_store>1</show_in_store>
654
+ </enable_cod>
655
+ <cod_fee translate="label">
656
+ <label>Extra fee, when using Cash on delivery</label>
657
+ <frontend_type>text</frontend_type>
658
+ <sort_order>10190</sort_order>
659
+ <show_in_default>1</show_in_default>
660
+ <show_in_website>1</show_in_website>
661
+ <show_in_store>1</show_in_store>
662
+ <depends>
663
+ <enable_cod>1</enable_cod>
664
+ </depends>
665
+ </cod_fee-->
666
+ <sort_order translate="label">
667
+ <label>Sort order</label>
668
+ <frontend_type>text</frontend_type>
669
+ <sort_order>1000000</sort_order>
670
+ <show_in_default>1</show_in_default>
671
+ <show_in_website>1</show_in_website>
672
+ <show_in_store>1</show_in_store>
673
+ </sort_order>
674
+ <removal translate="">
675
+ <label></label>
676
+ <frontend_model>eabi_postoffice/adminhtml_config_form_field_remove</frontend_model>
677
+ <sort_order>1000001</sort_order>
678
+ <show_in_default>1</show_in_default>
679
+ <show_in_website>0</show_in_website>
680
+ <show_in_store>0</show_in_store>
681
+ </removal>
682
+
683
+ </fields>
684
+ </eabidpdeeflat>
685
+
686
+ </groups>
687
+ </carriers>
688
+ </sections>
689
+
690
+ </config>
app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /* @var $installer Mage_Core_Model_Resource_Setup */
34
+ $installer = $this;
35
+
36
+ $installer->startSetup();
37
+ /*
38
+ * Adds DPD parcel terminal module as allowed carrier in the system.
39
+ */
40
+ $installer->run("
41
+
42
+ INSERT INTO {$this->getTable('eabi_carriermodule')}
43
+ (carrier_code, class_name, update_time)
44
+ VALUES
45
+ ('eabidpdee', 'eabi_dpdee/post', NOW());
46
+
47
+ ");
48
+
49
+ $installer->endSetup();
50
+
app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+ /*
37
+ * Adds DPD courier service module as allowed carrier in the system
38
+ */
39
+ $installer->run("
40
+
41
+ INSERT INTO {$this->getTable('eabi_carriermodule')}
42
+ (carrier_code, class_name, update_time)
43
+ VALUES
44
+ ('eabidpdeeflat', 'eabi_dpdee/flat', NOW());
45
+
46
+
47
+ ");
48
+
49
+
50
+ $installer->endSetup();
app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+ /*
38
+ * Adds simulated "parcel-terminal" for DPD courier module, without it there may be errors while customer picks carrier of choice.
39
+ */
40
+ $installer->run("
41
+
42
+
43
+ INSERT INTO {$this->getTable('eabi_postoffice')}
44
+ (`remote_module_id` ,`remote_module_name` ,`remote_place_id` ,`name` ,`city` ,`county` ,`zip_code` ,`country` ,`description` ,`created_time` ,`update_time`)
45
+ VALUES
46
+ ((SELECT id from {$this->getTable('eabi_carriermodule')} WHERE carrier_code = 'eabidpdeeflat'), 'eabidpdeeflat', '1' , 'Tarne kulleriga koju', '', '', '', '', '', NOW(), NOW());
47
+
48
+ ");
49
+
50
+
51
+ $installer->endSetup();
app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.2-0.1.3.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+ $installer->run("
38
+
39
+ ");
40
+
41
+ //insert action button with name of 'eabi_dpdee/action_carrier_order_courier'
42
+ /* @var $configBackend Eabi_Livehandler_Model_System_Config_Backend_Button */
43
+ $configBackend = Mage::getModel('eabi_livehandler/system_config_backend_button');
44
+ $configBackend->load('eabi_livehandler/admintools/buttons', 'path');
45
+
46
+ $foundValue = $configBackend->getValue();
47
+ if (!is_array($foundValue)) {
48
+ $foundValue = array();
49
+ }
50
+
51
+
52
+
53
+ $foundValue['_' . time() . '_' . mt_rand(0, 999)] = array(
54
+ 'button_name' => 'eabi_dpdee/action_carrier_order_courier',
55
+ 'sort_order' => "0",
56
+ 'disabled' => "0"
57
+ );
58
+ $configBackend->setValue($foundValue);
59
+
60
+ /* @var $helper Eabi_Livehandler_Helper_Data */
61
+ $helper = Mage::helper('eabi');
62
+ $helper->setConfigData('eabi_livehandler/admintools/buttons', serialize($foundValue), 'default', 0, true);
63
+ //$configBackend->save();
64
+ //end install
65
+
66
+ $installer->endSetup();
app/code/community/Eabi/DpdEE/sql/eabi_dpdee_setup/mysql4-upgrade-0.1.3-0.1.4.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+
38
+
39
+ //remove old action button from order info view with name of 'eabi_dpdee/action_carrier_order_courier'
40
+ /* @var $configBackend Eabi_Livehandler_Model_System_Config_Backend_Button */
41
+ $configBackend = Mage::getModel('eabi_livehandler/system_config_backend_button');
42
+ $configBackend->load('eabi_livehandler/admintools/buttons', 'path');
43
+
44
+ $foundValue = $configBackend->getValue();
45
+ if (!is_array($foundValue)) {
46
+ $foundValue = array();
47
+ }
48
+
49
+ $keyToUnset = false;
50
+ foreach ($foundValue as $key => $value) {
51
+ if ($value['button_name'] == 'eabi_dpdee/action_carrier_order_courier') {
52
+ $keyToUnset = $key;
53
+ }
54
+ }
55
+
56
+ if ($keyToUnset) {
57
+ unset($foundValue[$keyToUnset]);
58
+
59
+ $configBackend->setValue($foundValue);
60
+ /* @var $helper Eabi_Livehandler_Helper_Data */
61
+ $helper = Mage::helper('eabi');
62
+ $helper->setConfigData('eabi_livehandler/admintools/buttons', serialize($foundValue), 'default', 0, true);
63
+ }
64
+
65
+
66
+
67
+ //add same button to regular sales order grid view
68
+ $installer->run("
69
+
70
+ INSERT INTO {$this->getTable('eabi_livehandler')}
71
+ (name, is_enabled, is_admin, request_var, model_class, store_id, website_id, created_time, update_time)
72
+ VALUES
73
+ ('Adminhtml DPD courier order button', 1, 1, 'adminhtml/sales_order/index', 'eabi_dpdee/button_courier', 0, 0, NOW(), NOW());
74
+
75
+
76
+ ");
77
+
78
+
79
+ //end install
80
+ $installer->endSetup();
app/code/community/Eabi/Postoffice/Block/Adminhtml/Config/Form/Field/Remove.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Renders button, which allows to delete old instance of Eabi_Postoffice from app/code/local folder in Magento admin &gt; System &gt; Configuration &gt; Shipping Methods &gt; DPD - pakivedu.ee configuration menu, if such old instance exists</p>
35
+ *
36
+ * @author Matis
37
+ */
38
+ class Eabi_Postoffice_Block_Adminhtml_Config_Form_Field_Remove extends Mage_Adminhtml_Block_System_Config_Form_Field {
39
+
40
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
41
+ $divId = $element->getId();
42
+ $helper = Mage::helper('eabi_livehandler');
43
+ $res = '';
44
+ $dirName = Mage::getBaseDir('code') . '/local/Eabi/Postoffice';
45
+ if (is_dir($dirName) && file_exists($dirName.'/etc/config.xml')) {
46
+ $res .= <<<HTML
47
+ <button class="scalable" id="{$divId}_button" type="button" onclick="{$divId}make_request(); return false;">{$this->_getOfficeHelper()->__('Delete instance of this module from %s folder', 'app/code/local')}</button>
48
+
49
+ HTML;
50
+ $res .= <<<HTML
51
+ <script type="text/javascript">
52
+ //<![CDATA[
53
+
54
+ function {$divId}make_request(actionName) {
55
+ var confirmR = confirm({$this->_toJson($helper->__('Most probably you have older version of this module in the system. Do you want to remove the instance of this module from %s folder?', $dirName))});
56
+
57
+ if (confirmR) {
58
+ new Ajax.Request(
59
+ '{$this->getUrl('eabi_postoffice/adminhtml_postoffice/remove', array())}',
60
+ {
61
+ method: 'post',
62
+ asynchronous: true,
63
+ parameters: {"remove": "true"},
64
+ onSuccess: function(transport) {
65
+ var json = transport.responseText.evalJSON(true);
66
+ if (json['status'] && json['status'] == 'success') {
67
+ alert({$this->_toJson($this->_getOfficeHelper()->__('Folder %s deleted!', $dirName))});
68
+ \$({$this->_toJson($divId . '_button')}).hide();
69
+ } else {
70
+ alert({$this->_toJson($this->_getOfficeHelper()->__('Folder %s delete failed!', $dirName))});
71
+ }
72
+ },
73
+ onFailure: function(transport) {
74
+ alert(transport.responseText);
75
+ }
76
+ });
77
+ }
78
+
79
+ }
80
+ //]]>
81
+ </script>
82
+
83
+ HTML;
84
+
85
+ }
86
+ return $res;
87
+ }
88
+
89
+ private function _toJson($input) {
90
+ return json_encode($input);
91
+ }
92
+
93
+ /**
94
+ *
95
+ * @return Eabi_Postoffice_Helper_Data
96
+ */
97
+ protected function _getOfficeHelper() {
98
+ return Mage::helper('eabi_postoffice');
99
+ }
100
+
101
+
102
+
103
+ }
104
+
app/code/community/Eabi/Postoffice/Block/Config/Rebuildbutton.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Renders the button under the Magento Configuration panel.</p>
35
+ * <p>Purpose of this button is to invoke the procedure, which rebuilds the list of Postoffices/Parcel terminals
36
+ * which are directly related to this carrier.</p>
37
+ * <p>This button is only intended to use in the Magento -> System -> Configuration -> Shipping methods section
38
+ * and the carrier, that is using this button in the configuration panel should extend Eabi_Postoffice_Model_Carrier_Abstract class.</p>
39
+ *
40
+ * <p>In order to use this button in the system.xml configuration use the following example:</p>
41
+ * <p><pre><code>
42
+ * &lt;rebuild_all translate="label"&gt;
43
+ &lt;label&gt;Rebuild Postoffice List&lt;/label&gt;
44
+ &lt;frontend_type&gt;label&lt;/frontend_type&gt;
45
+ &lt;sort_order&gt;999&lt;/sort_order&gt;
46
+ &lt;frontend_model&gt;eabi_postoffice/config_rebuildbutton&lt;/frontend_model&gt;
47
+ &lt;show_in_default&gt;1&lt;/show_in_default&gt;
48
+ &lt;show_in_website&gt;1&lt;/show_in_website&gt;
49
+ &lt;show_in_store&gt;1&lt;/show_in_store&gt;
50
+ &lt;comment&gt;If post offices are not displayed correctly, then rebuilding the list may help&lt;/comment&gt;
51
+ &lt;/rebuild_all&gt;
52
+
53
+ * </code>
54
+ * </pre></p>
55
+ * <p>Most important parts of this example are <b>frontend_model</b> declaration, which refers to this block. Also <b>frontend_type</b> should be label.</p>
56
+ *
57
+ * @author matishalmann
58
+ */
59
+ class Eabi_Postoffice_Block_Config_Rebuildbutton extends Mage_Adminhtml_Block_System_Config_Form_Field {
60
+
61
+ /**
62
+ * Pre-render the element HTML.
63
+ * @param Varien_Data_Form_Element_Abstract $element
64
+ * @return string
65
+ * @throws Exception
66
+ */
67
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
68
+ $html = '';
69
+ $rebuildTextSuccess = Mage::helper('eabi_postoffice')->__('Rebuild successful');
70
+
71
+ //get the carrier code
72
+ $transformedNames = explode('/', str_replace(array('[', ']'), array('/', ''), $element->getName()));
73
+ $carrierName = trim($transformedNames[1]);
74
+ if ($carrierName == '') {
75
+ throw new Exception('Invalid carrier name');
76
+ }
77
+ $url = Mage::helper('adminhtml')->getUrl('eabi_postoffice/adminhtml_postoffice/rebuild', array('carrier_code' => $carrierName));
78
+
79
+ $rebuildText = Mage::helper('eabi_postoffice')->__('Rebuild postoffices for this carrier');
80
+ $rebuildTextConfirm = addslashes(sprintf(Mage::helper('eabi_postoffice')->__('Rebuilding postoffices for the carrier %s takes a little while... Continue?'), $carrierName));
81
+
82
+ $divId = $element->getId();
83
+
84
+ $html .= <<<EOT
85
+ <button class="scalable" type="button" onclick="{$divId}_eabi_office_rebuild(); return false;">
86
+ <span>{$rebuildText}</span>
87
+ </button>
88
+ <script type="text/javascript">
89
+ //<![CDATA[
90
+ function {$divId}_eabi_office_rebuild() {
91
+ var confirmR = confirm("{$rebuildTextConfirm}");
92
+ if (confirmR) {
93
+ new Ajax.Request('{$url}', {
94
+ method: 'get',
95
+ onSuccess: function(transport) {
96
+ json = transport.responseText.evalJSON(true);
97
+ if (json) {
98
+ if (json['error']) {
99
+ alert(json['error']);
100
+ } else if (json['success']) {
101
+ alert('{$rebuildTextSuccess}');
102
+ }
103
+ } else {
104
+ alert('Rebuild failed!');
105
+ }
106
+ }
107
+ });
108
+ }
109
+ }
110
+
111
+
112
+ //]]>
113
+ </script>
114
+
115
+ EOT;
116
+
117
+ return $html;
118
+ }
119
+ }
120
+
121
+
app/code/community/Eabi/Postoffice/Helper/Countrycode.php ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * Helper class of getting Country Phone dial codes.
35
+ *
36
+ * @author Matis
37
+ */
38
+ class Eabi_Postoffice_Helper_Countrycode {
39
+
40
+ protected $_countryCodes = array(
41
+ 'IL' => '972',
42
+ 'AF' => '93',
43
+ 'AL' => '355',
44
+ 'DZ' => '213',
45
+ 'AS' => '1684',
46
+ 'AD' => '376',
47
+ 'AO' => '244',
48
+ 'AI' => '1264',
49
+ 'AG' => '1268',
50
+ 'AR' => '54',
51
+ 'AM' => '374',
52
+ 'AW' => '297',
53
+ 'AU' => '61',
54
+ 'AT' => '43',
55
+ 'AZ' => '994',
56
+ 'BS' => '1242',
57
+ 'BH' => '973',
58
+ 'BD' => '880',
59
+ 'BB' => '1246',
60
+ 'BY' => '375',
61
+ 'BE' => '32',
62
+ 'BZ' => '501',
63
+ 'BJ' => '229',
64
+ 'BM' => '1441',
65
+ 'BT' => '975',
66
+ 'BA' => '387',
67
+ 'BW' => '267',
68
+ 'BR' => '55',
69
+ 'IO' => '246',
70
+ 'BG' => '359',
71
+ 'BF' => '226',
72
+ 'BI' => '257',
73
+ 'KH' => '855',
74
+ 'CM' => '237',
75
+ 'CA' => '1',
76
+ 'CV' => '238',
77
+ 'KY' => '345',
78
+ 'CF' => '236',
79
+ 'TD' => '235',
80
+ 'CL' => '56',
81
+ 'CN' => '86',
82
+ 'CX' => '61',
83
+ 'CO' => '57',
84
+ 'KM' => '269',
85
+ 'CG' => '242',
86
+ 'CK' => '682',
87
+ 'CR' => '506',
88
+ 'HR' => '385',
89
+ 'CU' => '53',
90
+ 'CY' => '537',
91
+ 'CZ' => '420',
92
+ 'DK' => '45',
93
+ 'DJ' => '253',
94
+ 'DM' => '1767',
95
+ 'DO' => '1849',
96
+ 'EC' => '593',
97
+ 'EG' => '20',
98
+ 'SV' => '503',
99
+ 'GQ' => '240',
100
+ 'ER' => '291',
101
+ 'EE' => '372',
102
+ 'ET' => '251',
103
+ 'FO' => '298',
104
+ 'FJ' => '679',
105
+ 'FI' => '358',
106
+ 'FR' => '33',
107
+ 'GF' => '594',
108
+ 'PF' => '689',
109
+ 'GA' => '241',
110
+ 'GM' => '220',
111
+ 'GE' => '995',
112
+ 'DE' => '49',
113
+ 'GH' => '233',
114
+ 'GI' => '350',
115
+ 'GR' => '30',
116
+ 'GL' => '299',
117
+ 'GD' => '1473',
118
+ 'GP' => '590',
119
+ 'GU' => '1671',
120
+ 'GT' => '502',
121
+ 'GN' => '224',
122
+ 'GW' => '245',
123
+ 'GY' => '595',
124
+ 'HT' => '509',
125
+ 'HN' => '504',
126
+ 'HU' => '36',
127
+ 'IS' => '354',
128
+ 'IN' => '91',
129
+ 'ID' => '62',
130
+ 'IQ' => '964',
131
+ 'IE' => '353',
132
+ 'IT' => '39',
133
+ 'JM' => '1876',
134
+ 'JP' => '81',
135
+ 'JO' => '962',
136
+ 'KZ' => '77',
137
+ 'KE' => '254',
138
+ 'KI' => '686',
139
+ 'KW' => '965',
140
+ 'KG' => '996',
141
+ 'LV' => '371',
142
+ 'LB' => '961',
143
+ 'LS' => '266',
144
+ 'LR' => '231',
145
+ 'LI' => '423',
146
+ 'LT' => '370',
147
+ 'LU' => '352',
148
+ 'MG' => '261',
149
+ 'MW' => '265',
150
+ 'MY' => '60',
151
+ 'MV' => '960',
152
+ 'ML' => '223',
153
+ 'MT' => '356',
154
+ 'MH' => '692',
155
+ 'MQ' => '596',
156
+ 'MR' => '222',
157
+ 'MU' => '230',
158
+ 'YT' => '262',
159
+ 'MX' => '52',
160
+ 'MC' => '377',
161
+ 'MN' => '976',
162
+ 'ME' => '382',
163
+ 'MS' => '1664',
164
+ 'MA' => '212',
165
+ 'MM' => '95',
166
+ 'NA' => '264',
167
+ 'NR' => '674',
168
+ 'NP' => '977',
169
+ 'NL' => '31',
170
+ 'AN' => '599',
171
+ 'NC' => '687',
172
+ 'NZ' => '64',
173
+ 'NI' => '505',
174
+ 'NE' => '227',
175
+ 'NG' => '234',
176
+ 'NU' => '683',
177
+ 'NF' => '672',
178
+ 'MP' => '1670',
179
+ 'NO' => '47',
180
+ 'OM' => '968',
181
+ 'PK' => '92',
182
+ 'PW' => '680',
183
+ 'PA' => '507',
184
+ 'PG' => '675',
185
+ 'PY' => '595',
186
+ 'PE' => '51',
187
+ 'PH' => '63',
188
+ 'PL' => '48',
189
+ 'PT' => '351',
190
+ 'PR' => '1939',
191
+ 'QA' => '974',
192
+ 'RO' => '40',
193
+ 'RW' => '250',
194
+ 'WS' => '685',
195
+ 'SM' => '378',
196
+ 'SA' => '966',
197
+ 'SN' => '221',
198
+ 'RS' => '381',
199
+ 'SC' => '248',
200
+ 'SL' => '232',
201
+ 'SG' => '65',
202
+ 'SK' => '421',
203
+ 'SI' => '386',
204
+ 'SB' => '677',
205
+ 'ZA' => '27',
206
+ 'GS' => '500',
207
+ 'ES' => '34',
208
+ 'LK' => '94',
209
+ 'SD' => '249',
210
+ 'SR' => '597',
211
+ 'SZ' => '268',
212
+ 'SE' => '46',
213
+ 'CH' => '41',
214
+ 'TJ' => '992',
215
+ 'TH' => '66',
216
+ 'TG' => '228',
217
+ 'TK' => '690',
218
+ 'TO' => '676',
219
+ 'TT' => '1868',
220
+ 'TN' => '216',
221
+ 'TR' => '90',
222
+ 'TM' => '993',
223
+ 'TC' => '1649',
224
+ 'TV' => '688',
225
+ 'UG' => '256',
226
+ 'UA' => '380',
227
+ 'AE' => '971',
228
+ 'GB' => '44',
229
+ 'US' => '1',
230
+ 'UY' => '598',
231
+ 'UZ' => '998',
232
+ 'VU' => '678',
233
+ 'WF' => '681',
234
+ 'YE' => '967',
235
+ 'ZM' => '260',
236
+ 'ZW' => '263',
237
+ 'BO' => '591',
238
+ 'BN' => '673',
239
+ 'CC' => '61',
240
+ 'CD' => '243',
241
+ 'CI' => '225',
242
+ 'FK' => '500',
243
+ 'GG' => '44',
244
+ 'VA' => '379',
245
+ 'HK' => '852',
246
+ 'IR' => '98',
247
+ 'IM' => '44',
248
+ 'JE' => '44',
249
+ 'KP' => '850',
250
+ 'KR' => '82',
251
+ 'LA' => '856',
252
+ 'LY' => '218',
253
+ 'MO' => '853',
254
+ 'MK' => '389',
255
+ 'FM' => '691',
256
+ 'MD' => '373',
257
+ 'MZ' => '258',
258
+ 'PS' => '970',
259
+ 'PN' => '872',
260
+ 'RE' => '262',
261
+ 'RU' => '7',
262
+ 'BL' => '590',
263
+ 'SH' => '290',
264
+ 'KN' => '1869',
265
+ 'LC' => '1758',
266
+ 'MF' => '590',
267
+ 'PM' => '508',
268
+ 'VC' => '1784',
269
+ 'ST' => '239',
270
+ 'SO' => '252',
271
+ 'SJ' => '47',
272
+ 'SY' => '963',
273
+ 'TW' => '886',
274
+ 'TZ' => '255',
275
+ 'TL' => '670',
276
+ 'VE' => '58',
277
+ 'VN' => '84',
278
+ 'VG' => '1284',
279
+ 'VI' => '1340',
280
+ );
281
+
282
+ /**
283
+ * Gets array of all phone country codes, where array key is country ISO-3166 code and value is numeric dial code without '+'
284
+ * @return array
285
+ */
286
+ public function getCountryCodes() {
287
+ return $this->_countryCodes;
288
+ }
289
+
290
+
291
+ /**
292
+ * Gets numeric dialcode without '+' sign for specified country code
293
+ * @param string $countryId ISO-3166 country code
294
+ * @return string
295
+ */
296
+ public function getCountryCode($countryId) {
297
+ if (isset($this->_countryCodes[$countryId])) {
298
+ return $this->_countryCodes[$countryId];
299
+ }
300
+ return null;
301
+ }
302
+
303
+
304
+
305
+ /**
306
+ * <p>Attempts to separate country code from phone number by supplied default country.</p>
307
+ * <p>If Phone number is missing country code, then it is applied by supplied country ISO-3166 code</p>
308
+ * <p>Returns array with following format</p>
309
+ * <pre>
310
+ * array(
311
+ * 'dial_code' => country dial code with + prefix
312
+ * 'phone_number' => phone number without country code
313
+ * );
314
+ * </pre>
315
+ *
316
+ * @param string $phonenumber phone number that may contain country code
317
+ * @param string $countryId ISO-3166 country code
318
+ * @return array
319
+ */
320
+ public function separatePhoneNumberFromCountryCode($phonenumber, $countryId) {
321
+ $result = array(
322
+ 'dial_code' => '',
323
+ 'phone_number' => '',
324
+ );
325
+ $defaultDialCode = $this->getCountryCode($countryId);
326
+
327
+ //remove all whitespace
328
+ $phonenumber = str_replace(' ', '', $phonenumber);
329
+
330
+ //when country code is supplied, then it can:
331
+ //start with country code
332
+ //start with + sign
333
+ //start with 00 (double zero)
334
+ //be longer than 10 digits
335
+ $containsCountryCode = strpos($phonenumber, $defaultDialCode) === 0
336
+ || strpos($phonenumber, '+') === 0
337
+ || strpos($phonenumber, '00') === 0
338
+ || strlen($phonenumber) > 10;
339
+
340
+ //when country code is not supplied, then it can
341
+ //start with single zero
342
+ //start with any number
343
+ if (!$containsCountryCode) {
344
+ $result['dial_code'] = '+'.$defaultDialCode;
345
+ if (strpos($phonenumber, '0') === 0) {
346
+ $result['phone_number'] = substr($phonenumber, 1);
347
+ } else {
348
+ $result['phone_number'] = $phonenumber;
349
+ }
350
+ } else {
351
+ //phone number contains country code
352
+ //we need to know what country code phone number contains
353
+ //remove 00 or + sign
354
+ $phonenumber = ltrim($phonenumber, '+0');
355
+ $dialCode = $this->_getCountryCodeFromPhonenumber($phonenumber, $defaultDialCode);
356
+ $result['dial_code'] = '+'.$dialCode;
357
+ $result['phone_number'] = substr($phonenumber, strlen($dialCode));
358
+ }
359
+
360
+
361
+ return $result;
362
+ }
363
+
364
+
365
+ /**
366
+ * <p>Attempts to find country code from phone number, when it is known that phone number most certainly contains country code.</p>
367
+ * <p>Method assumes that longest found dial code is matcing dial code for this phone number.</p>
368
+ * <p>If now match is found then default code is used.</p>
369
+ * @param string $phonenumber phone number that is known to contain country code
370
+ * @param string $defaultCode dial code to be used if no country code is found
371
+ * @return string resulting dial code without + sign
372
+ */
373
+ protected function _getCountryCodeFromPhonenumber($phonenumber, $defaultCode) {
374
+ $matchingCountryCode = '';
375
+ foreach ($this->getCountryCodes() as $countryIso => $dialCode) {
376
+ if (strpos($phonenumber, $dialCode) === 0) {
377
+ if (strlen($dialCode) > $matchingCountryCode) {
378
+ $matchingCountryCode = $dialCode;
379
+ }
380
+ }
381
+ }
382
+ //as last resort apply default dial code
383
+ if ($matchingCountryCode === '') {
384
+ return $defaultCode;
385
+ }
386
+ return $matchingCountryCode;
387
+ }
388
+
389
+ }
app/code/community/Eabi/Postoffice/Helper/Data.php ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * Helper class for dealing with situation, when Carrier provider needs some shipment data to be sent to Carrier providers server.
35
+ *
36
+ * @author Aktsiamaailm OÜ, Matis Halmann
37
+ */
38
+ class Eabi_Postoffice_Helper_Data extends Mage_Core_Helper_Abstract {
39
+ private static $timeDiff = null;
40
+
41
+ /**
42
+ * <p>Attempts to send order shipment data right at the moment, when user lands on the success page
43
+ * and user has just completed onepage checkout.</p>
44
+ * <p>Shipment data is sent to the server only, when automatic data sending is enabled and the timing is set to right after order completion.</p>
45
+ * <p>Shipment data is sent to the server in the following conditions:
46
+ * <ul>
47
+ * <li>Order has been fully paid, or payment method is Cash on delivery (to be implemented in future) and cash on delivery is allowed</li>
48
+ * <li>Carrier supports automatic shipment data sending to the Carrier server</li>
49
+ * <li>Merchant has enabled automatic shipment data sending to the server</li>
50
+ * <li>Shipment data has not been sent to the server earlier</li>
51
+ * </ul>
52
+ * </p>
53
+ * @see Eabi_Postoffice_Model_Source_Sendevent source for possible automatic data sending moments.
54
+ *
55
+ */
56
+ public function autoSendAfterOnepage() {
57
+ $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
58
+ if ($incrementId != '') {
59
+ $this->handleOrder($incrementId, 'after_checkout');
60
+ }
61
+
62
+ }
63
+
64
+ /**
65
+ * <p>Attempts to send order shipment data right at the moment, when user lands on the success page
66
+ * and user has just completed multishipping checkout.</p>
67
+ * <p>Shipment data is sent to the server only, when automatic data sending is enabled and the timing is set to right after order completion.</p>
68
+ * <p>Shipment data is sent to the server in the following conditions:
69
+ * <ul>
70
+ * <li>Order has been fully paid, or payment method is Cash on delivery (to be implemented in future) and cash on delivery is allowed</li>
71
+ * <li>Carrier supports automatic shipment data sending to the Carrier server</li>
72
+ * <li>Merchant has enabled automatic shipment data sending to the server</li>
73
+ * <li>Shipment data has not been sent to the server earlier</li>
74
+ * </ul>
75
+ * </p>
76
+ * @see Eabi_Postoffice_Model_Source_Sendevent source for possible automatic data sending moments.
77
+ *
78
+ */
79
+ public function autoSendAfterMultishipping() {
80
+ $ids = Mage::getSingleton('core/session')->getOrderIds(true);
81
+ if ($ids && is_array($ids)) {
82
+ foreach ($ids as $item) {
83
+ $this->handleOrder($item, 'after_checkout');
84
+ }
85
+ }
86
+
87
+ }
88
+
89
+ /**
90
+ * <p>Attempts to send order shipment data right at the moment, when Merchant has finished "Create Shipping" procedure for the order.
91
+ * </p>
92
+ * <p>Shipment data is sent to the server only, when automatic data sending is enabled and the timing is set to right after order completion.</p>
93
+ * <p>Shipment data is sent to the server in the following conditions:
94
+ * <ul>
95
+ * <li>Order has been fully paid, or payment method is Cash on delivery (to be implemented in future) and cash on delivery is allowed</li>
96
+ * <li>Carrier supports automatic shipment data sending to the Carrier server</li>
97
+ * <li>Merchant has enabled automatic shipment data sending to the server</li>
98
+ * <li>Shipment data has not been sent to the server earlier</li>
99
+ * </ul>
100
+ * </p>
101
+ * @see Eabi_Postoffice_Model_Source_Sendevent source for possible automatic data sending moments.
102
+ *
103
+ */
104
+ public function autoSendAfterShipment($observer) {
105
+ $event = $observer->getEvent();
106
+ $shipment = $event->getShipment();
107
+ $order = $shipment->getOrder();
108
+ $incrementId = $order->getIncrementId();
109
+ if ($shipment->getId() <= 0) {
110
+ $this->handleOrder($incrementId, 'after_shipment');
111
+ }
112
+ }
113
+
114
+ /**
115
+ * <p>Clears all the extra data created by this carrier or by the subclasses of this carrier.</p>
116
+ *
117
+ * <p>It is called with the event <code>sales_order_place_before</code></p>
118
+ *
119
+ *
120
+ * @param Varien_Object $observer
121
+ * @throws Exception
122
+ */
123
+ public function clearSessions($observer) {
124
+ $carriers = Mage::getModel('eabi_postoffice/carriermodule')->getCollection();
125
+
126
+ foreach ($carriers as $carrier) {
127
+ $shippingModel = Mage::getModel($carrier->getData('class_name'));
128
+ if (!($shippingModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
129
+ throw new Exception('Invalid Shipping model');
130
+ }
131
+ $shippingModel->clearSession();
132
+ }
133
+ }
134
+
135
+ /**
136
+ * <p>Attempts to send order shipment data right from the Merchant's manual call.
137
+ * </p>
138
+ * <p>Shipment data is sent to the server in the following conditions:
139
+ * <ul>
140
+ * <li>Order has been fully paid, or payment method is Cash on delivery (to be implemented in future) and cash on delivery is allowed</li>
141
+ * <li>Carrier supports automatic shipment data sending to the Carrier server</li>
142
+ * <li>Merchant has enabled automatic shipment data sending to the server</li>
143
+ * <li>Shipment data has not been sent to the server earlier</li>
144
+ * </ul>
145
+ * </p>
146
+ * @see Eabi_Postoffice_Model_Source_Sendevent source for possible automatic data sending moments.
147
+ *
148
+ * @param string $incrementId Order increment ID
149
+ * @param string $eventName Name of the event.
150
+ *
151
+ */
152
+ public function sendManualOrderData($incrementId, $eventName) {
153
+ return $this->handleOrder($incrementId, $eventName);
154
+ }
155
+
156
+ /**
157
+ *
158
+ * <p>Attempts to fetch the barcode, which has been generated by the remote Carrier.</p>
159
+ * <p>Fetching barcode is only possible, when shipment data is successfully sent to the carrier
160
+ * and Carrier itself supports Barcodes.</p>
161
+ * <p>Barcodes are used to print shipping labels.</p>
162
+ *
163
+ * @param string $incrementId Order increment ID.
164
+ * @return string|boolean barcode for the selected order, when successul, false in every other situation.
165
+ */
166
+ public function getBarcode($incrementId) {
167
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
168
+ if (!is_object($order) || $order->getId() <= 0) {
169
+ return false;
170
+ }
171
+ $shippingMethod = $order->getShippingMethod();
172
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
173
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
174
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
175
+ return $shippingMethodModel->getBarcode($order);
176
+ }
177
+ return false;
178
+
179
+ }
180
+
181
+ /**
182
+ * <p>Attempts to fetch shipping method instance for specified order increment id.</p>
183
+ * <p>Shipping method is fetched only if it is instance of <code>Eabi_Postoffice_Model_Carrier_Abstract</code> otherwise boolean false is returned</p>
184
+ * @param string $incrementId order increment id
185
+ * @return Eabi_Postoffice_Model_Carrier_Abstract|boolean
186
+ */
187
+ public function getShippingMethodInstance($incrementId) {
188
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
189
+ if (!is_object($order) || $order->getId() <= 0) {
190
+ return false;
191
+ }
192
+ $shippingMethod = $order->getShippingMethod();
193
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
194
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
195
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
196
+ $shippingMethodModel->setStore($order->getStore());
197
+ return $shippingMethodModel;
198
+ }
199
+ return false;
200
+ }
201
+
202
+
203
+ /**
204
+ *
205
+ * <p>Attempts to fetch the shipping label PDF created by the remote Carrier server.</p>
206
+ * <p>Fetching barcode is only possible, when shipment data is successfully sent to the carrier
207
+ * and Carrier itself supports Barcodes.</p>
208
+ *
209
+ * @param string $incrementId Order increment ID.
210
+ * @return string|boolean Packing slip PDF binary for the selected order when successful, false in every other condition.
211
+ */
212
+ public function getBarcodePdf($incrementId) {
213
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
214
+ if (!is_object($order) || $order->getId() <= 0) {
215
+ return false;
216
+ }
217
+ $shippingMethod = $order->getShippingMethod();
218
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
219
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
220
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
221
+ return $shippingMethodModel->getBarcodePdf($order);
222
+ }
223
+ return false;
224
+
225
+ }
226
+
227
+ /**
228
+ * <p>Determines whether Order shipment data has been successfully sent to the remote carrier server.</p>
229
+ *
230
+ * @param string $incrementId Order increment ID.
231
+ * @return boolean true, if the data has been successfully sent to the server. False, if the data has not been sent
232
+ * successfully to the server. NULL if automatic data sending is not enabled or not applicable for the Order selected carrier.
233
+ */
234
+ public function isDataSent($incrementId) {
235
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
236
+ if (!is_object($order) || $order->getId() <= 0) {
237
+ return null;
238
+ }
239
+ $shippingMethod = $order->getShippingMethod();
240
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
241
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
242
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
243
+ if ($shippingMethodModel->isAutoSendAvailable()) {
244
+ return $shippingMethodModel->isDataSent($order);
245
+ }
246
+ }
247
+ return null;
248
+
249
+ }
250
+
251
+ /**
252
+ * <p>Returns true if all of the following are true</p>
253
+ * <ul>
254
+ <li>Carrier supports automatic data sending</li>
255
+ <li>Automatic data sending is allowed</li>
256
+ <li>Order is fully paid or payment method is COD</li>
257
+ <li>Order is not canceled and contains physical goods</li>
258
+ </ul>
259
+ * @param Mage_Sales_Model_Order $order
260
+ * @param type $shippingMethodModel
261
+ * @return boolean
262
+ */
263
+ public function canSendData(Mage_Sales_Model_Order $order, &$shippingMethodModel = null) {
264
+ if (!$shippingMethodModel) {
265
+ $shippingMethod = $order->getShippingMethod();
266
+ $paymentMethod = $order->getPayment();
267
+
268
+ //get the shipping code from the order and call the module from it.
269
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
270
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
271
+ }
272
+
273
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)
274
+ && $shippingMethodModel->getConfigData('senddata_enable')
275
+ && !(round($order->getTotalDue(), 2) > 0 && (!$shippingMethodModel->getConfigData('enable_cod') ||
276
+ ($shippingMethodModel->getConfigData('enable_cod') && $paymentMethod->getMethod() != 'eabicodpayment')))
277
+ && !($order->isCanceled() || $order->getIsVirtual())) {
278
+ $shippingMethodModel->setStore($order->getStore());
279
+ return true;
280
+ }
281
+ return false;
282
+ }
283
+
284
+ /**
285
+ *
286
+ * <p>Attempts to auto send data to remote server and insert the result to order comments.</p>
287
+ * <p>Shipment data is sent to the server in the following conditions:
288
+ * <ul>
289
+ * <li>Order has been fully paid, or payment method is Cash on delivery (to be implemented in future) and cash on delivery is allowed</li>
290
+ * <li>Carrier supports automatic shipment data sending to the Carrier server</li>
291
+ * <li>Merchant has enabled automatic shipment data sending to the server</li>
292
+ * <li>Shipment data has not been sent to the server earlier</li>
293
+ * <li>$eventName matches data sending event set up in the configuration.</li>
294
+ * </ul>
295
+ * </p>
296
+ * @param string $incrementId order increment id
297
+ * @param string $eventName event name for send data
298
+ * @return null
299
+ * @see Eabi_Postoffice_Model_Source_Sendevent
300
+ */
301
+ private function handleOrder($incrementId, $eventName) {
302
+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
303
+ if (!is_object($order) || $order->getId() <= 0) {
304
+ return;
305
+ }
306
+ $shippingMethod = $order->getShippingMethod();
307
+ $paymentMethod = $order->getPayment();
308
+
309
+ //get the shipping code from the order and call the module from it.
310
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
311
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
312
+
313
+
314
+ if ($shippingMethodModel && ($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)
315
+ && $shippingMethodModel->getConfigData('senddata_enable')
316
+ && $shippingMethodModel->getConfigData('senddata_event') == $eventName
317
+ && !(round($order->getTotalDue(), 2) > 0 && (!$shippingMethodModel->getConfigData('enable_cod') ||
318
+ ($shippingMethodModel->getConfigData('enable_cod') && $paymentMethod->getMethod() != 'eabicodpayment')))
319
+ && !($order->isCanceled() || $order->getIsVirtual())
320
+ && $shippingMethodModel->isDataSent($order) === false) {
321
+ try {
322
+ $resultCarrierId = substr($shippingMethod, strrpos($shippingMethod, '_') + 1);
323
+ //TODO - make sure the correct store is selected, for example in admin.
324
+ $result = $shippingMethodModel->autoSendData($order, $resultCarrierId);
325
+ if ($result) {
326
+ $order->addStatusHistoryComment(print_r($result, true));
327
+ } else {
328
+ $order->addStatusHistoryComment($this->__('Automatic data sending not applicable'));
329
+ }
330
+ $order->save();
331
+ } catch (Exception $e) {
332
+ $order->addStatusHistoryComment($e->__toString());
333
+ $order->save();
334
+ }
335
+ }
336
+ }
337
+
338
+
339
+ /**
340
+ * <p>Attempts to fetch data from order that is stored by carriers extending Eabi_Postoffice_Model_Carrier_Abstract</p>
341
+ * <p>Data is stored in not visible on front order comment base64 encoded form and starting with specified prefix.</p>
342
+ * <p>If matching comment is found, it is decoded and returned as assoc array</p>
343
+ * @param Mage_Sales_Model_Order $order Magento order instance to look up the data for
344
+ * @param string $prefix unique string prefix order comment should start with.
345
+ * @return array
346
+ */
347
+ public function getDataFromOrder(Mage_Sales_Model_Order $order, $prefix) {
348
+ $orderData = array();
349
+ foreach ($order->getAllStatusHistory() as $statusHistory) {
350
+ /* @var $statusHistory Mage_Sales_Model_Order_Status_History */
351
+ if ($statusHistory->getComment() && !$statusHistory->getVisibleOnFront()) {
352
+ if ($this->_commentContainsValidData($statusHistory->getComment(), $prefix)) {
353
+ $orderData = @json_decode(@gzuncompress(@base64_decode($this->_getFromComment($statusHistory->getComment(), $prefix))), true);
354
+ if (!is_array($orderData)) {
355
+ //unserialize error on recognized pattern, should throw error or at least log
356
+ $orderData = array();
357
+ }
358
+ }
359
+ }
360
+
361
+
362
+ }
363
+ return $orderData;
364
+
365
+ }
366
+
367
+ /**
368
+ * <p>Stores extra data for specified order in single order comment, which will start with specified prefix.</p>
369
+ * <p>If no matching order comment is found, then it is created automatically, otherwise old one is updated.</p>
370
+ * <p>Order comment is stored using following procedure:</p>
371
+ * <ul>
372
+ <li>If old data is found, then it is merged with new data</li>
373
+ <li>Data is json encoded and after that gzcompressed</li>
374
+ <li>Now it is base64 encoded and divided into 40 char long lines and prefixed with $prefix</li>
375
+ <li>Result is stored to one of the comments contained within the order.</li>
376
+ </ul>
377
+ * @param Mage_Sales_Model_Order $order Magento order instance to set up the data for
378
+ * @param array $data
379
+ * @param string $prefix
380
+ * @return array
381
+ */
382
+ public function setDataToOrder(Mage_Sales_Model_Order $order, array $data, $prefix) {
383
+ $oldOrderData = $this->getDataFromOrder($order, $prefix);
384
+ if (isset($data['comment_id'])) {
385
+ unset($data['comment_id']);
386
+ }
387
+ if (count($oldOrderData) && isset($oldOrderData['comment_id'])) {
388
+ //we have old data
389
+ $history = Mage::getModel('sales/order_status_history')->load($oldOrderData['comment_id']);
390
+ if ($history && $history->getId()) {
391
+ foreach ($data as $k => $v) {
392
+ $oldOrderData[$k] = $v;
393
+ }
394
+ $history->setComment($this->_getCommentFromData($oldOrderData, $prefix));
395
+ $history->save();
396
+ }
397
+ //comment id for example.....
398
+ } else {
399
+ //we do not have old data, so add new comment
400
+ //set the id also
401
+
402
+ $history = Mage::getModel('sales/order_status_history')
403
+ ->setStatus($order->getStatus())
404
+ ->setOrderId($order->getId())
405
+ ->setParentId($order->getId())
406
+ ->setComment($this->_getCommentFromData($data, $prefix))
407
+ ->save();
408
+ $commentId = $history->getId();
409
+
410
+ $data['comment_id'] = $commentId;
411
+ $history->setComment($this->_getCommentFromData($data, $prefix));
412
+ $history->save();
413
+ }
414
+
415
+
416
+
417
+ return $history;
418
+ }
419
+
420
+
421
+
422
+ /**
423
+ * <p>Returns Magento timestamp and time() difference in seconds</p>
424
+ * @return int
425
+ */
426
+ public function getTimeDiff() {
427
+ if (self::$timeDiff === null) {
428
+ $time = time();
429
+ $now = Mage::getModel('core/date')->timestamp($time);
430
+ echo '<pre>'.htmlspecialchars(print_r($time, true)).'</pre>';
431
+ echo '<pre>'.htmlspecialchars(print_r($now, true)).'</pre>';
432
+ self::$timeDiff = $time - $now;
433
+ }
434
+ return self::$timeDiff;
435
+
436
+ }
437
+
438
+
439
+ protected function _getCommentFromData($data, $prefix) {
440
+ return $prefix ."\n". chunk_split(base64_encode(gzcompress(json_encode($data))), 40, "\n");
441
+ }
442
+
443
+ protected function _getFromComment($comment, $prefix) {
444
+ return str_replace($prefix, '', str_replace("\n", '', $comment));
445
+ }
446
+
447
+
448
+
449
+ protected function _commentContainsValidData($comment, $prefix) {
450
+ //TODO: refactor to something better
451
+ return strpos($comment, $prefix) === 0
452
+ && strlen($comment) > strlen($prefix);
453
+ }
454
+
455
+ /**
456
+ * <p>Takes in array of parcel weights and returns number of packages calculated by maximum allowed weight per package</p>
457
+ * <p>Uses better methology to find number of packages than regular cart weight divided by maximum package weight</p>
458
+ * <p>For example, if maximum package weight is 31kg, ang we have 3x 20kg packages, then number of packages would be 3 (not 2)</p>
459
+ * <p>If maximum package weight is not defined, then it returns 1</p>
460
+ * <p>If single item in <code>$itemWeights</code> exceeds <code>$maximumWeight</code> then this function returns false</p>
461
+ * @param array $itemWeights array of item weights
462
+ * @param int $maximumWeight maximum allowed weight of one package
463
+ * @return int
464
+ */
465
+ public function getNumberOfPackagesFromItemWeights(array $itemWeights, $maximumWeight) {
466
+ $numPackages = 1;
467
+ $weight = 0;
468
+ if ($maximumWeight > 0) {
469
+
470
+ foreach ($itemWeights as $itemWeight) {
471
+ if ($itemWeight > $maximumWeight) {
472
+ return false;
473
+ }
474
+ $weight += $itemWeight;
475
+ if ($weight > $maximumWeight) {
476
+ $numPackages++;
477
+ $weight = $itemWeight;
478
+ }
479
+ }
480
+
481
+ }
482
+ return $numPackages;
483
+ }
484
+
485
+
486
+
487
+
488
+
489
+ }
app/code/community/Eabi/Postoffice/Model/Carrier/Abstract.php ADDED
@@ -0,0 +1,1016 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Base class for carriers, which ask customer to pick parcel terminal of choice from dropdown list.</p>
35
+ * <p>Offers following business functions:</p>
36
+ * <ul>
37
+ <li>Chosen parcel terminal is forwarded to the Merchant</li>
38
+ <li>Monitors if shipment parcel data is sent to remote server</li>
39
+ <li>Offers PDF packing slip printing function, if subclasses implement actual fetch procedure.</li>
40
+ <li>Offers auto update functionality for parcel terminals if subclasses implement actual parcel terminal fetch procedure</li>
41
+ <li>Offers cash on delivery functionality with help of extra plugins.</li>
42
+ * <li>Offers clickable tracking url or iframe functionality from Magento</li>
43
+ </ul>
44
+ * @author matishalmann
45
+ */
46
+ abstract class Eabi_Postoffice_Model_Carrier_Abstract extends Mage_Shipping_Model_Carrier_Abstract {
47
+
48
+ /**
49
+ * <p>Actual URL can be entered here, where %s in the url would be replaced with supplied tracking number.</p>
50
+ * <p>When tracking number is entered, then user is provided with link to track the status of package on remote server.</p>
51
+ * @var bool|string
52
+ */
53
+ protected $_tracking_url = false;
54
+
55
+ /**
56
+ * <p>When set to true and $_tracking_url is provided, then instead of clickable link iframe is displayed instead.</p>
57
+ * @var bool
58
+ */
59
+ protected $_track_iframe = false;
60
+
61
+
62
+ /**
63
+ * <p>This method should be implemented in subclasses of this carrier.</p>
64
+ * <p>Purpose of this method is to return array of Postoffices/Parcel terminals associated to this carrier.</p>
65
+ * <p>This method is called automatically by Magento's cron and the update frequency is regulated by the carriers
66
+ * configuration data of <code>update_interval</code> which is expressed in minutes.</p>
67
+ * <p>Usually the carriers are fetched from some remote location and sometimes the fetching may fail, in this case
68
+ * this method should return boolean false in order to avoid Postoffice list being empty.</p>
69
+ *
70
+ * <p>Each element contained in this array should have the following structure:
71
+ * <pre>
72
+ * <code>
73
+ * array(
74
+ 'place_id' => (int)unique remote id for this office (Mandatory),
75
+ 'name' => Unique name for this office (Mandatory),
76
+ 'city' => City where this office is located,
77
+ 'county' => County where this office is located,
78
+ 'description' => Description where this office is located,
79
+ 'country' => Country ID where this office is located format: EN, EE, FI,
80
+ 'zip' => Zip code for this office,
81
+ 'group_sort' => higher number places group higher in the parcel terminal list, defaults to 0,
82
+ );
83
+
84
+ * </code>
85
+ * </pre>
86
+ * </p>
87
+ * <p>You can also supply <code>group_sort</code> parameter, if you have it. Offices which have greater group_sort parameter are displayed before
88
+ * other postoffices. Alternatively you can write your own group_sort generator function by overwriting the getGroupSort(group_name) method
89
+ * which should return integer value.</p>
90
+ * <p>It is advised to supply at least city or county parameter, because first select menu will be created from group_name parameters
91
+ * and group_name parameter is basically: county_name/city_name</p>
92
+ *
93
+ * @return array of postoffices, where each element is assoc array with described structure.
94
+ *
95
+ */
96
+ abstract public function getOfficeList();
97
+
98
+
99
+ /**
100
+ * <p>If you would like to display certain counties or cities before the others, then you can overwrite this function.</p>
101
+ * <p>This function should return positive integer. The greater the number returned means this county/city is more important than the others
102
+ * and should be displayed before the others.</p>
103
+ * <p>In general postoffices will be displayed according to the following rules:
104
+ * <ul>
105
+ * <li>group_sort descending</li>
106
+ * <li>group_name ascending</li>
107
+ * <li>name ascending</li>
108
+ * </ul>
109
+ * </p>
110
+ * <p>This function is called only when getOfficeList function does not supply group_sort parameter</p>
111
+ *
112
+ *
113
+ * @param string $group_name county/city or county or city
114
+ * @return int greater value, means this office belongs to more important group.
115
+ */
116
+ public function getGroupSort($group_name) {
117
+ return 0;
118
+ }
119
+
120
+ /**
121
+ * <p>This function is called right after:
122
+ * <ul>
123
+ * <li>This carrier is active</li>
124
+ * <li>Cart's max weight does not exceed the limit</li>
125
+ * <li>Cart's min weight is not below the limit</li>
126
+ * </ul>
127
+ * </p>
128
+ * <p>If this function returns false, then this carrier is not available.</p>
129
+ *
130
+ * @param Mage_Shipping_Model_Rate_Request $request
131
+ * @return boolean false, if this carrier should not be available.
132
+ */
133
+ protected function _isAvailable(Mage_Shipping_Model_Rate_Request $request) {
134
+ return true;
135
+ }
136
+
137
+ /**
138
+ * <p>If carrier supports external tracking URL's then it should return true</p>
139
+ * @return boolean
140
+ */
141
+ public function isTrackingAvailable() {
142
+ if ($this->getTrackingUrl()) {
143
+ return true;
144
+ }
145
+ return false;
146
+ }
147
+
148
+
149
+
150
+ /**
151
+ * <p>Returns tracking URL for current carrier if one exists.</p>
152
+ * @return bool|string
153
+ */
154
+ public function getTrackingUrl() {
155
+ return $this->_tracking_url;
156
+ }
157
+
158
+ /**
159
+ * <p>When set to true and $_tracking_url is provided, then instead of clickable link iframe is displayed instead.</p>
160
+ * @return bool
161
+ */
162
+ public function getTrackingInIframe() {
163
+ return $this->_track_iframe;
164
+ }
165
+
166
+ /**
167
+ * <p>Attempts to display tracking link or tracking iframe if tracking is supported by the carrier and tracking url is available.</p>
168
+ * @param string $number tracking number
169
+ * @return Varien_Object|null
170
+ */
171
+ public function getTrackingInfo($number) {
172
+ if ($this->getTrackingUrl()) {
173
+ $custom = new Varien_Object();
174
+
175
+ $trackingUrl = sprintf($this->getTrackingUrl(), $number);
176
+ if ($this->getTrackingInIframe()) {
177
+
178
+ $custom->setTracking('<iframe src="' . $trackingUrl . '" style="border:0px #FFFFFF none;" name="abc" scrolling="no" frameborder="0" marginheight="0px" marginwidth="0px" height="100%" width="100%"></iframe>');
179
+ } else {
180
+ $custom->setTracking(sprintf('<a href="%s" target="_blank">%s</a>', $trackingUrl, $this->_getEabi()->__('Tracking URL')));
181
+ }
182
+
183
+ return $custom;
184
+ }
185
+ return null;
186
+ }
187
+
188
+ /**
189
+ * Returns true if this Mage_Shipping_Model_Rate_Request is multishipping.
190
+ *
191
+ *
192
+ * @param Mage_Shipping_Model_Rate_Request $request
193
+ * @return boolean
194
+ */
195
+ protected function _isMultishipping(Mage_Shipping_Model_Rate_Request $request) {
196
+ foreach ($request->getAllItems() as $item) {
197
+ if ($item instanceof Mage_Sales_Model_Quote_Address_Item) {
198
+ return true;
199
+ }
200
+ break;
201
+ }
202
+ return false;
203
+ }
204
+
205
+
206
+ /**
207
+ * <p>use <code>_isAvailable()</code> function to determine if the carrier is available.</p>
208
+ * <p>use <code>_calculateAdditionalShippingPrice</code> function to calculate any additional shipping cost.</p>
209
+ *
210
+ * <p>Checks for the following conditions:
211
+ * <ul>
212
+ * <li>This carrier is active</li>
213
+ * <li>Cart's max weight does not exceed the limit</li>
214
+ * <li>Cart's min weight is not below the limit</li>
215
+ * </ul>
216
+ * </p>
217
+ * <p>Calculates the shipping price based on the following:
218
+ * <ul>
219
+ * <li>Configurations like <code>enable_free_shipping</code>,<code>free_shipping_from</code> are enabled or disabled </li>
220
+ * <li>Configuration like <code>handling_fee</code> which is the base shipping price.</li>
221
+ * <li>Configuration like <code>handling_action</code> which determines whether the shipping price is based on per order or per item</li>
222
+ * <li>If shopping cart rules specify free shipping.</li>
223
+ * <li>Price found from the conditions above will be passed as second parameter to the function <code>_calculateAdditionalShippingPrice</code> which in turn can alter the shipping price further.</li>
224
+ * </ul>
225
+ * </p>
226
+ *
227
+ *
228
+ * @param Mage_Shipping_Model_Rate_Request $request
229
+ * @return boolean|Eabi_Postoffice_Model_Carrier_Result false, if carrier is not available.
230
+ */
231
+ final public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
232
+ //determine if this shipping method is available
233
+ $addressId = (string)$this->getAddressId($request);
234
+ if (!$this->getConfigData('active')) {
235
+ $this->clearAddressId($addressId);
236
+ return false;
237
+ }
238
+ if ($this->getConfigData('use_per_item_weight')) {
239
+ //we compare each item individually
240
+ //if any of the items is overweight, disable
241
+ //if any of the items is underweight, disable
242
+ $loadedProductWeights = array();
243
+ if ($this->getConfigData('max_package_weight') > 0 || $this->getConfigData('min_package_weight') > 0) {
244
+ //get request items
245
+ if ($request->getAllItems()) {
246
+ foreach ($request->getAllItems() as $requestItem) {
247
+ $productToWeight = $this->_getProductModel()->load($requestItem->getProduct()->getId());
248
+ for ($i = 0; $i < $requestItem->getQty(); $i++) {
249
+ $loadedProductWeights[] = $productToWeight->getWeight();
250
+ }
251
+ }
252
+ }
253
+ }
254
+ if ($this->getConfigData('max_package_weight') > 0) {
255
+ if (max($loadedProductWeights) > (float) $this->getConfigData('max_package_weight')) {
256
+ $this->clearAddressId($addressId);
257
+ return false;
258
+ }
259
+ }
260
+ if ($this->getConfigData('min_package_weight') > 0) {
261
+ if (min($loadedProductWeights) < (float) $this->getConfigData('min_package_weight')) {
262
+ $this->clearAddressId($addressId);
263
+ return false;
264
+ }
265
+ }
266
+ $request->setEabiProductWeights($loadedProductWeights);
267
+
268
+ } else {
269
+ //we summarize weight of all cart and apply the weight rule
270
+ //total cart is overweight, disable
271
+ //total cart is underweight, disable
272
+ if ($this->getConfigData('max_package_weight') > 0) {
273
+ if ($request->getPackageWeight() > (float) $this->getConfigData('max_package_weight')) {
274
+ $this->clearAddressId($addressId);
275
+ return false;
276
+ }
277
+ }
278
+ if ($this->getConfigData('min_package_weight') > 0) {
279
+ if ($request->getPackageWeight() < (float) $this->getConfigData('min_package_weight')) {
280
+ $this->clearAddressId($addressId);
281
+ return false;
282
+ }
283
+ }
284
+ }
285
+
286
+ $isAvailable = $this->_isAvailable($request);
287
+ if ($isAvailable === false) {
288
+ $this->clearAddressId($addressId);
289
+ return false;
290
+ }
291
+
292
+ //determine the shipping price
293
+ $price = 0;
294
+
295
+ //fetch the base handling fee
296
+ $handlingFee = (float)str_replace(',', '.', $this->getConfigData('handling_fee'));
297
+ //shipping method is available. Find the price.
298
+ $isFree = false;
299
+
300
+ //if we have defined free shipping from certain cart subtotal level
301
+ if ($this->getConfigData('enable_free_shipping') && $request->getPackageValueWithDiscount() >= $this->getConfigData('free_shipping_from')) {
302
+ $price = 0;
303
+ $isFree = true;
304
+ }
305
+
306
+ //if there is free shipping defined by shopping cart rule
307
+ if ($request->getFreeShipping() === true && !$isFree) {
308
+ $isFree = true;
309
+ }
310
+
311
+ if (!$isFree) {
312
+ $freeBoxes = 0;
313
+ //if there are any free boxes defined by shopping cart rule
314
+ foreach ($request->getAllItems() as $item) {
315
+ if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
316
+ $freeBoxes += $item->getQty();
317
+ }
318
+ }
319
+ $this->setFreeBoxes($freeBoxes);
320
+ }
321
+
322
+
323
+ //if there is no free shipping, attempt to calcualte the price
324
+ //on per order or per item basis
325
+ if ($this->getConfigData('handling_action') == 'O' && !$isFree) {
326
+ //handling action per_order basis
327
+ $price = $handlingFee;
328
+ } else if ($this->getConfigData('handling_action') == 'P' && !$isFree) {
329
+ //handling action per item basis
330
+ if ($this->getConfigData('use_per_item_weight')) {
331
+ //calculate number of packages first
332
+ $price = ($this->_getOfficeHelper()->getNumberOfPackagesFromItemWeights($loadedProductWeights, $this->getConfigData('max_package_weight')) - $this->getFreeBoxes()) * $handlingFee;
333
+
334
+ } else {
335
+ $price = ($request->getPackageQty() * $handlingFee) - ($this->getFreeBoxes() * $handlingFee);
336
+ }
337
+ if ($price == 0) {
338
+ $isFree = true;
339
+ }
340
+ } else if (!$isFree) {
341
+ //handling action type could not be detected, return false
342
+ //shipping method not available
343
+ $this->clearAddressId($addressId);
344
+ return false;
345
+ }
346
+
347
+ //if there is any additional logic for calculating the price
348
+ if (!$isFree) {
349
+ $price = $this->_calculateAdditionalShippingPrice($request, $price);
350
+ }
351
+ if ($price === false) {
352
+ return false;
353
+ }
354
+ $session = Mage::getSingleton('core/session');
355
+
356
+ $this->registerAddressId($addressId);
357
+
358
+
359
+
360
+ $result = Mage::getModel('eabi_postoffice/carrier_result');
361
+ //list the offices
362
+ $method = Mage::getModel('shipping/rate_result_method');
363
+ $method->setCarrier($this->_code);
364
+ $method->setCarrierTitle($this->getConfigData('title'));
365
+
366
+ $method->setMethod($this->_code);
367
+ //TODO: get the correct price
368
+ $method->setPrice($price);
369
+ $loadingText = Mage::helper('eabi_postoffice')->__('Loading offices...');
370
+ $html = '';
371
+ if ($this->_isMultishipping($request)) {
372
+ $html .= '<div id="eabi_carrier_'.$addressId.'_'.$this->_code.'" style="display:inline-block;">'.$loadingText.'</div>';
373
+ } else {
374
+ $html .= '<div id="eabi_carrier_'.$this->_code.'" style="display:inline-block;"></div>';
375
+ }
376
+ $url = Mage::getUrl('eabi_postoffice/index/office', array('_secure' => true));
377
+
378
+ if (Mage::app()->getStore()->isAdmin()) {
379
+ $url = Mage::helper('adminhtml')->getUrl('eabi_postoffice/adminhtml_postoffice/office', array('store_id' => $request->getStoreId(), '_secure' => true));
380
+ }
381
+
382
+ $carrierId = 's_method_'.$this->_code.'_'.$this->_code;
383
+ $divId = 'eabi_carrier_'.$this->_code;
384
+ if ($this->_isMultishipping($request)) {
385
+ $carrierId = 's_method_'.$addressId.'_'.$this->_code.'_'.$this->_code;
386
+ $divId = 'eabi_carrier_'.$addressId.'_'.$this->_code;
387
+ }
388
+ $carrierCode = $this->_code;
389
+
390
+ $html .= <<<EOT
391
+ <script type="text/javascript">
392
+ /* <![CDATA[ */
393
+ $('{$carrierId}').writeAttribute('value', '');
394
+ new Ajax.Request('{$url}', {
395
+ method: 'post',
396
+ parameters: {
397
+ carrier_id: '{$carrierId}',
398
+ carrier_code: '{$carrierCode}',
399
+ div_id: '{$divId}',
400
+ address_id: '{$addressId}',
401
+ },
402
+ onSuccess: function(transport) {
403
+ $('{$divId}').update(transport.responseText);
404
+ }
405
+ });
406
+ /* ]]> */
407
+ </script>
408
+ EOT;
409
+ $method->setMethodTitle($html);
410
+ $terminalsCollection = $this->getTerminals();
411
+ if ($terminalsCollection->count() == 1) {
412
+ //if we have only one terminal in the collection, then do not create select drop downs.
413
+ //just render the single element and return the result.
414
+ $office = $terminalsCollection->getFirstItem();
415
+ $method->setMethodTitle($this->getTerminalTitle($office));
416
+ $method->setCarrier($this->_code);
417
+ $method->setCarrierTitle($this->getConfigData('title'));
418
+
419
+ $method->setMethod($this->_code.'_'.$office->getRemotePlaceId());
420
+ $result->append($method);
421
+ return $result;
422
+ }
423
+
424
+
425
+ $result->append($method);
426
+
427
+
428
+ $addedMethods = array();
429
+ //try to see, if we have any extra methods stored in a session
430
+ $sessionData = $session->getData('eabi_carrier_' . $this->_code);
431
+ if (is_array($sessionData) && isset($sessionData[$addressId])) {
432
+ foreach ($sessionData[$addressId] as $subCarrier) {
433
+ $method = Mage::getModel('shipping/rate_result_method');
434
+ $method->setCarrier($subCarrier['carrier']);
435
+ $method->setCarrierTitle($subCarrier['carrier_title']);
436
+ $addedMethods[$subCarrier['method']] = $subCarrier['method'];
437
+
438
+ $method->setMethod($subCarrier['method']);
439
+ $method->setMethodTitle($subCarrier['method_title']);
440
+ $method->setPrice($price);
441
+ $result->append($method);
442
+ }
443
+ }
444
+
445
+ //TODO: add the method if we are able to detect the postoffice automatically
446
+ $additionalOffices = $this->getOfficesFromAddress($request);
447
+ foreach ($additionalOffices as $office) {
448
+ $methodName = $this->_code .'_' .$office->getRemoteModuleId();
449
+ if (!isset($addedMethods[$methodName])) {
450
+ $method = Mage::getModel('shipping/rate_result_method');
451
+ $method->setCarrier($this->_code);
452
+ $method->setCarrierTitle($this->getConfigData('title'));
453
+ $addedMethods[$methodName] = $method;
454
+
455
+ $method->setMethod($methodName);
456
+ $method->setMethodTitle($this->getAdminTerminalTitle($office));
457
+ $method->setPrice($price);
458
+ $result->append($method);
459
+
460
+ }
461
+ }
462
+
463
+
464
+ return $result;
465
+
466
+ }
467
+
468
+
469
+
470
+ /**
471
+ * <p>Registers current address id in session, so no outsiders could tamper with selected parcel terminal data.</p>
472
+ * @param string $addressId
473
+ * @return Eabi_Postoffice_Model_Carrier_Abstract
474
+ */
475
+ private function registerAddressId($addressId) {
476
+ $addressId = (string)$addressId;
477
+ $session = Mage::getSingleton('core/session');
478
+ $sessionData = $session->getData('eabi_allowedcarriers');
479
+ if (!is_array($sessionData)) {
480
+ $sessionData = array();
481
+ }
482
+ if (!isset($sessionData[$addressId])) {
483
+ $sessionData[$addressId] = array();
484
+ }
485
+ if (!isset($sessionData[$addressId][$this->_code])) {
486
+ $sessionData[$addressId][$this->_code] = $this->_code;
487
+ }
488
+ $session->setData('eabi_allowedcarriers', $sessionData);
489
+ return $this;
490
+ }
491
+
492
+ /**
493
+ * Security related, used to prevent customer to enter arbitrary data as their shipping carrier.
494
+ *
495
+ *
496
+ * @param int $addressId
497
+ * @return boolean
498
+ */
499
+ final public function isAjaxInsertAllowed($addressId) {
500
+ $addressId = (string)$addressId;
501
+ $session = Mage::getSingleton('core/session');
502
+ $sessionData = $session->getData('eabi_allowedcarriers');
503
+ if (is_array($sessionData) && isset($sessionData[$addressId]) && isset($sessionData[$addressId][$this->_code])) {
504
+ return true;
505
+ }
506
+ return false;
507
+ }
508
+
509
+ /**
510
+ * <p>After successful checkout all entered parcel terminal data should be cleared by calling this function.</p>
511
+ * @param string $addressId
512
+ * @return Eabi_Postoffice_Model_Carrier_Abstract
513
+ */
514
+ private function clearAddressId($addressId) {
515
+ $addressId = (string)$addressId;
516
+ $session = Mage::getSingleton('core/session');
517
+ $sessionData = $session->getData('eabi_allowedcarriers');
518
+ if (is_array($sessionData) && isset($sessionData[$addressId]) && isset($sessionData[$addressId][$this->_code])) {
519
+ unset($sessionData[$addressId][$this->_code]);
520
+ }
521
+ return $this;
522
+ }
523
+
524
+ /**
525
+ * <p>This function is called right after the initial price calculation by the </code>collectRates</code> has been called.</p>
526
+ * <p>Overwrite this function if you want to apply more complicated price calculation rules, than </code>collectRates</code>
527
+ * function offers.</p>
528
+ *
529
+ *
530
+ *
531
+ * @param Mage_Shipping_Model_Rate_Request $request
532
+ * @param float $price pre-calculated price by the </code>collectRates</code> function.
533
+ * @return float new price, this carrier should have.
534
+ */
535
+ protected function _calculateAdditionalShippingPrice(Mage_Shipping_Model_Rate_Request $request, $price) {
536
+ return $price;
537
+ }
538
+
539
+ /**
540
+ * <p>Overwrite this function in your subclass if you would like to offer automatic postoffice selection based on the user entered address.</p>
541
+ *
542
+ * ["dest_country_id"] => string(2) "EE"
543
+ * ["dest_region_id"] => string(3) "345"
544
+ * ["dest_region_code"] => string(5) "EE-57"
545
+ * ["dest_street"] => string(11) "mina ei tea"
546
+ * ["dest_city"] => string(7) "tallinn"
547
+ * ["dest_postcode"] => string(5) "12345"
548
+ * ["package_value"] => float(16.33)
549
+ * ["package_value_with_discount"] => float(16.33)
550
+ * ["package_weight"] => float(16.16)
551
+ * ["package_qty"] => int(2)
552
+ * ["package_physical_value"] => float(16.33)
553
+ * ["free_method_weight"] => float(16.16)
554
+ * ["store_id"] => string(1) "2"
555
+ * ["website_id"] => string(1) "1"
556
+ * ["free_shipping"] => int(0)
557
+ * ["base_currency (Mage_Directory_Model_Currency)"] => array(1) { ["currency_code"] => string(3) "EUR" }
558
+ * ["package_currency (Mage_Directory_Model_Currency)"] => array(1) { ["currency_code"] => string(3) "EUR" }
559
+ * ["country_id"] => string(2) "EE"
560
+ * ["region_id"] => string(1) "0"
561
+ * ["city"] => string(0) ""
562
+ * ["postcode"] => string(0) ""
563
+ *
564
+ * @param Mage_Shipping_Model_Rate_Request $request
565
+ * @return array of 'eabi_postoffice/office' models belonging to this carrier.
566
+ */
567
+ protected function getOfficesFromAddress(Mage_Shipping_Model_Rate_Request $request) {
568
+ return array();
569
+ }
570
+
571
+ /**
572
+ * <p>Returns distinct group_name,group_id,group_sort as Eabi_Postoffice_Model_Mysql4_Office_Collection of 'eabi_postoffice/office' models</p>
573
+ * <p>Result of this function is used to render the first select menu (county/city) for this carrier.</p>
574
+ * <p>If no groups can be found, then this function returns boolean false.</p>
575
+ *
576
+ *
577
+ * @param int $addressId when supplied then only groups from the addressId country are returned.
578
+ * @return boolean|array
579
+ */
580
+ public function getGroups($addressId = null) {
581
+ if( $this->getConfigData('drop_menu_selection')){
582
+ return false;
583
+ }
584
+ $groups = Mage::getModel('eabi_postoffice/office')->getCollection()
585
+ ->distinct(true)
586
+ ->addFieldToFilter('remote_module_name', $this->_code);
587
+ $groups->getSelect()->reset(Zend_Db_Select::COLUMNS)
588
+ ->columns(array('group_id', 'group_name', 'group_sort'));
589
+ $groups->addOrder('group_sort', 'DESC');
590
+ $groups->addOrder('group_name', 'ASC');
591
+ if ($addressId) {
592
+ $address = $this->_getAddressModel()->load($addressId);
593
+ if ($address->getCountryId()) {
594
+ $groups->addFieldToFilter('country', $address->getCountryId());
595
+ }
596
+ }
597
+
598
+
599
+ if ($groups->count() <= 1) {
600
+ return false;
601
+ }
602
+ return $groups;
603
+ }
604
+
605
+ /**
606
+ *
607
+ * <p>Returns Eabi_Postoffice_Model_Mysql4_Office_Collection which should contain the actual postoffices
608
+ * which belong to the selected group_id in alplabetically sorted order.</p>
609
+ * <p>If no $groupId is supplied, then all the postoffices are returned.</p>
610
+ * <p>Offices are sorted by</p>
611
+ * <ul>
612
+ <li>group_sort descending</li>
613
+ <li>group_name ascending</li>
614
+ <li>name ascending</li>
615
+ </ul>
616
+ * @param int $groupId
617
+ * @param int $addressId when supplied then only offices from the addressId country are returned.
618
+ * @return Eabi_Postoffice_Model_Mysql4_Office_Collection
619
+ * @see Eabi_Postoffice_Model_Carrier_Abstract::getGroupSort()
620
+ */
621
+ public function getTerminals($groupId = null, $addressId = null) {
622
+ $terminals = Mage::getModel('eabi_postoffice/office')->getCollection()
623
+ ->addFieldToFilter('remote_module_name', $this->_code)
624
+ ->addOrder('group_sort', 'DESC')
625
+ ->addOrder('group_name', 'ASC')
626
+ ->addOrder('name', 'ASC')
627
+ ;
628
+
629
+ if ($addressId) {
630
+ $address = $this->_getAddressModel()->load($addressId);
631
+ if ($address->getCountryId()) {
632
+ $terminals->addFieldToFilter('country', $address->getCountryId());
633
+ }
634
+ }
635
+
636
+ if ($groupId !== null) {
637
+ $terminals->addFieldToFilter('group_id', $groupId);
638
+ }
639
+ return $terminals;
640
+ }
641
+
642
+
643
+ /**
644
+ * <p>Returns the selected postoffice by it's place id.<p>
645
+ * <p>If no postoffice found, then returns boolean false.</p>
646
+ *
647
+ * @param int $placeId
648
+ * @return Eabi_Postoffice_Model_Office|boolean false
649
+ */
650
+ public function getTerminal($placeId) {
651
+ $places = Mage::getModel('eabi_postoffice/office')->getCollection()
652
+ ->addFieldToFilter('remote_module_name', $this->_code)
653
+ ->addFieldToFilter('remote_place_id', $placeId);
654
+ if ($places->count() == 1) {
655
+ return $places->getFirstItem();
656
+ }
657
+ return false;
658
+ }
659
+
660
+ /**
661
+ * Determines how name of each postoffice in the second select menu should be rendered.
662
+ *
663
+ *
664
+ * @param Eabi_Postoffice_Model_Office $office
665
+ * @return string
666
+ */
667
+ public function getTerminalTitle(Eabi_Postoffice_Model_Office $office) {
668
+ return htmlspecialchars($office->getName());
669
+ }
670
+ /**
671
+ * Determines how name of each county/city in the first select menu should be rendered.
672
+ *
673
+ *
674
+ * @param Eabi_Postoffice_Model_Office $office
675
+ * @return string
676
+ */
677
+ public function getGroupTitle(Eabi_Postoffice_Model_Office $office) {
678
+ return htmlspecialchars($office->getGroupName());
679
+ }
680
+ /**
681
+ * Determines how name of customer selected postoffice should be rendered and this is also how merchant sees the selected postoffice.
682
+ *
683
+ *
684
+ * @param Eabi_Postoffice_Model_Office $office
685
+ * @return string
686
+ */
687
+ public function getAdminTerminalTitle(Eabi_Postoffice_Model_Office $office) {
688
+ $name = $office->getName();
689
+ if ($office->getGroupName() != '') {
690
+ $name = $office->getGroupName().' - '.$office->getName();
691
+ }
692
+ return htmlspecialchars($name);
693
+ }
694
+
695
+
696
+ /**
697
+ *
698
+ * Used to fetch the price from 'sales/quote_address_rate' database table.
699
+ *
700
+ * @param type $addressId
701
+ * @return boolean
702
+ */
703
+ final protected function getPriceFromAddressId($addressId) {
704
+ $calculatedPriceModelCollection = Mage::getModel('sales/quote_address_rate')
705
+ ->getCollection()
706
+ ->addFieldToFilter('address_id', $addressId)
707
+ ->addFieldToFilter('carrier', $this->_code)
708
+ ->addFieldToFilter('code', $this->_code . '_' . $this->_code)
709
+ ;
710
+ if ($calculatedPriceModelCollection->count() == 1) {
711
+ return $calculatedPriceModelCollection->getFirstItem()->getPrice();
712
+ }
713
+ return false;
714
+ }
715
+
716
+ /**
717
+ * <p>Initially this carrier does not set up all the shipping methods for this carrier in the 'sales/quote_address_rate' database table.
718
+ * since storing too many methods in there is not the smartest thing to do</p>
719
+ * <p>So once the user selects the actual office, an AJAX callback is performed and this one inserts the selected office to the database
720
+ * and also to the session, in order the customer would easily reach latest selected offices and the order itself could be placed,
721
+ * since user selected postoffices have to exist in the 'sales/quote_address_rate' database table.</p>
722
+ * <p>This one results in less entries in 'sales/quote_address_rate' database table.</p>
723
+ *
724
+ *
725
+ * @param int $addressId
726
+ * @param Eabi_Postoffice_Model_Office $office
727
+ * @throws Exception
728
+ */
729
+ final public function setOfficeToSession($addressId, Eabi_Postoffice_Model_Office $office) {
730
+
731
+ $addressRateModelCollection = Mage::getModel('sales/quote_address_rate')
732
+ ->getCollection()
733
+ ->addFieldToFilter('address_id', $addressId)
734
+ ->addFieldToFilter('carrier', $this->_code)
735
+ ->addFieldToFilter('code', $this->_code . '_' . $this->_code . '_' . $office->getRemotePlaceId())
736
+ ;
737
+ if ($addressRateModelCollection->count() == 0) {
738
+ //insert
739
+ $newRate = Mage::getModel('sales/quote_address_rate');
740
+ $newRate->setData('address_id', $addressId);
741
+ $newRate->setData('carrier', $this->_code);
742
+ $newRate->setData('code', $this->_code . '_' . $this->_code . '_' . $office->getRemotePlaceId());
743
+ $newRate->setData('method', $this->_code . '_' . $office->getRemotePlaceId());
744
+
745
+ $title = $this->getAdminTerminalTitle($office);
746
+
747
+ $newRate->setData('carrier_title', $this->getConfigData('title'));
748
+ $newRate->setData('method_title', $title);
749
+ $price = $this->getPriceFromAddressId($addressId);
750
+ if ($price === false) {
751
+ throw new Exception('Cannot calculate price');
752
+ }
753
+ $newRate->setPrice($price);
754
+ $newRate->save();
755
+ $session = Mage::getSingleton('core/session');
756
+ $sessionData = $session->getData('eabi_carrier_' . $this->_code);
757
+ if (!is_array($sessionData)) {
758
+ $sessionData = array();
759
+ }
760
+ if (!isset($sessionData[(string)$addressId])) {
761
+ $sessionData[(string)$addressId] = array();
762
+ }
763
+ if ($this->getConfigData('disable_session')) {
764
+ foreach ($sessionData[(string)$addressId] as $k => $v) {
765
+ if ($k != $this->_code) {
766
+ unset($sessionData[(string)$addressId][$k]);
767
+ }
768
+ }
769
+
770
+ }
771
+ $sessionData[(string)$addressId][$this->_code . '_' . $this->_code . '_' . $office->getRemotePlaceId()] = $newRate->debug();
772
+ $session->setData('eabi_carrier_' . $this->_code, $sessionData);
773
+ }
774
+ }
775
+
776
+ /**
777
+ * Clears all the session data created by this carrier.
778
+ *
779
+ *
780
+ * @return \Eabi_Postoffice_Model_Carrier_Abstract
781
+ */
782
+ final public function clearSession() {
783
+ Mage::getSingleton('core/session')->unsetData('eabi_allowedcarriers');
784
+ Mage::getSingleton('core/session')->unsetData('eabi_carrier_' . $this->_code);
785
+ return $this;
786
+ }
787
+
788
+
789
+
790
+ /**
791
+ * <p>Sets Magento store config for current carrier specified by key</p>
792
+ * @param string $key
793
+ * @param mixed $value
794
+ * @return Eabi_Postoffice_Model_Carrier_Abstract|boolean
795
+ */
796
+ public function setConfigData($key, $value) {
797
+ if (empty($this->_code)) {
798
+ return false;
799
+ }
800
+ Mage::helper('eabi')->setConfigData('carriers/'.$this->_code.'/'.$key, $value);
801
+ return $this;
802
+ }
803
+
804
+ /**
805
+ * Should return true, when this carrier can automatically send shipment data to third party carrier server.
806
+ *
807
+ *
808
+ * @return bool
809
+ */
810
+ public function isAutoSendAvailable() {
811
+ return (bool)$this->getConfigData('senddata_enable');
812
+ }
813
+
814
+ /**
815
+ * <p>Should return the actual generated barcode by the third party carrier server.
816
+ * Overwrite this method in the subclass.</p>
817
+ * <p>This function is available to the merchant, if he/she wants to print the packing slip in the order view.</p>
818
+ *
819
+ *
820
+ *
821
+ * @param Mage_Sales_Model_Order $order order, to get the barcode for.
822
+ * @return boolean|string
823
+ */
824
+ public function getBarcode(Mage_Sales_Model_Order $order) {
825
+ return false;
826
+ }
827
+
828
+ /**
829
+ * <p>Should return the actual Pdf binary which should be packing slip for this order and false in every other case.</p>
830
+ * <p>This function is available to the merchant, if he/she wants to print the packing slip in the order view.</p>
831
+ *
832
+ *
833
+ * @param Mage_Sales_Model_Order $order
834
+ * @return boolean
835
+ */
836
+ public function getBarcodePdf(Mage_Sales_Model_Order $order) {
837
+ return false;
838
+ }
839
+
840
+ /**
841
+ * <p>Returns true, if data has been sent</p>
842
+ * <p>Returns false, if data has not been sent</p>
843
+ * <p>Returns null, if data sending is not available.</p>
844
+ *
845
+ * @param Mage_Sales_Model_Order $order
846
+ * @return boolean
847
+ */
848
+ public function isDataSent(Mage_Sales_Model_Order $order) {
849
+ if ($this->isAutoSendAvailable()) {
850
+ return false;
851
+ }
852
+ return null;
853
+ }
854
+
855
+ /**
856
+ *
857
+ * If the barcode function is available at all for this carrier.
858
+ * @return boolean
859
+ */
860
+ public function isBarcodeFunctionAvailable() {
861
+ return false;
862
+ }
863
+
864
+
865
+
866
+ /**
867
+ * <p> If automatic data sending is available, then this function should be overwritten and the actual data sending should be performed in here.</p>
868
+ * <p>Also Configuration value of <code>senddata_enable</code> should be set to '1' or this function will never be called.</p>
869
+ * <p>If automatic sending is not applicable, then this function should return boolean false.</p>
870
+ * <p>If automatic data sending is successful, then the result will be added to the order comments using <code>print_r()</code> function.</p>
871
+ *
872
+ *
873
+ *
874
+ * @param Mage_Sales_Model_Order $order
875
+ * @param type $selectedOfficeId remote_place_id - id of the carrier, that the customer selected.
876
+ * @return boolean|array
877
+ */
878
+ public function autoSendData(Mage_Sales_Model_Order $order, $selectedOfficeId) {
879
+ return false;
880
+ }
881
+
882
+ /**
883
+ * Wrapper function for the parent class, simply for security and session management.
884
+ * For example, when user first selects country, where the carrier is available and then switches country and the carrier is not available any more,
885
+ * then the session has to be cleared a bit, in order to avoid the user entering arbitrary data for the previously available carrier.
886
+ *
887
+ * @param Mage_Shipping_Model_Rate_Request $request
888
+ * @return \Mage_Shipping_Model_Rate_Result_Error
889
+ */
890
+ public function checkAvailableShipCountries(Mage_Shipping_Model_Rate_Request $request) {
891
+ $checkResult = parent::checkAvailableShipCountries($request);
892
+ if ($checkResult === false || ($checkResult instanceof Mage_Shipping_Model_Rate_Result_Error)) {
893
+ $this->clearAddressId($this->getAddressId($request));
894
+ }
895
+ return $checkResult;
896
+ }
897
+
898
+ /**
899
+ * <p>Indicates if specified order has been picked up by courier.</p>
900
+ * <p>Should return the following</p>
901
+ * <ul>
902
+ <li><b>true</b> - If the order has been picked up by courier</li>
903
+ <li><b>false</b> - If the order has not been picked up by courier</li>
904
+ <li><b>null</b> - If courier pickup is not applicable to specified order</li>
905
+ </ul>
906
+ * @param Mage_Sales_Model_Order $order
907
+ * @return null|bool
908
+ */
909
+ public function isPickedUpByCourier(Mage_Sales_Model_Order $order) {
910
+ return null;
911
+ }
912
+
913
+ /**
914
+ * Gets the address_id, which will be used in the 'sales/quote_address_rate' database table, in order to handle user selection of postoffice
915
+ * related to this carrier.
916
+ *
917
+ *
918
+ * @param Mage_Shipping_Model_Rate_Request $request
919
+ * @return type
920
+ */
921
+ protected function getAddressId(Mage_Shipping_Model_Rate_Request $request) {
922
+ if (Mage::app()->getStore()->isAdmin()) {
923
+ return Mage::getSingleton('adminhtml/sales_order_create')->getQuote()->getShippingAddress()->getId();
924
+ } else if ($this->_isMultishipping($request)) {
925
+ $shippingAddresses = Mage::getSingleton('checkout/type_multishipping')->getQuote()->getAllShippingAddresses();
926
+ foreach ($shippingAddresses as $shippingAddress) {
927
+ if ($this->_compareAddressToRequest($request, $shippingAddress)) {
928
+ if ($shippingAddress->getId() <= 0) {
929
+ $shippingAddress->save();
930
+ }
931
+ return $shippingAddress->getId();
932
+ }
933
+ }
934
+ } else {
935
+ return Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getId();
936
+ }
937
+
938
+ }
939
+
940
+ /**
941
+ * <p>In multishipping scenarios shipping addresses may not be saved and thus lacking correct id. In such scenario they need to be compared manually to detect the correct chosen parcel terminal</p>
942
+ * @param Mage_Shipping_Model_Rate_Request $request
943
+ * @param Mage_Sales_Model_Quote_Address $address
944
+ * @return boolean
945
+ */
946
+ protected function _compareAddressToRequest(Mage_Shipping_Model_Rate_Request $request, $address) {
947
+ $compareFields = array(
948
+ 'dest_country_id' => 'country_id',
949
+ 'dest_region_id' => 'region_id',
950
+ 'dest_street' => 'street',
951
+ 'dest_city' => 'city',
952
+ 'dest_postcode' => 'postcode',
953
+ );
954
+ foreach ($compareFields as $requestField => $addressField) {
955
+ if ($request->getData($requestField) != $address->getData($addressField)) {
956
+ return false;
957
+ }
958
+ }
959
+ return true;
960
+ }
961
+
962
+ /**
963
+ * <p>Gets current carrier code for usage in other helper classes.</p>
964
+ * @return string
965
+ */
966
+ public function getCode() {
967
+ return $this->_code;
968
+ }
969
+
970
+
971
+
972
+ /**
973
+ *
974
+ * @return Mage_Sales_Model_Quote_Address
975
+ */
976
+ protected function _getAddressModel() {
977
+ return Mage::getModel('sales/quote_address');
978
+ }
979
+
980
+ /**
981
+ *
982
+ * @return Mage_Catalog_Model_Product
983
+ */
984
+ protected function _getProductModel() {
985
+ return Mage::getModel('catalog/product');
986
+ }
987
+
988
+
989
+ /**
990
+ *
991
+ * @return Eabi_Livehandler_Helper_Data
992
+ */
993
+ protected function _getEabi() {
994
+ return Mage::helper('eabi');
995
+ }
996
+
997
+ /**
998
+ *
999
+ * @return Eabi_Postoffice_Helper_Data
1000
+ */
1001
+ protected function _getOfficeHelper() {
1002
+ return Mage::helper('eabi_postoffice');
1003
+ }
1004
+
1005
+
1006
+ /**
1007
+ *
1008
+ * @return Eabi_Postoffice_Helper_Countrycode
1009
+ */
1010
+ protected function _getDialCodeHelper() {
1011
+ return Mage::helper('eabi_postoffice/countrycode');
1012
+ }
1013
+
1014
+
1015
+ }
1016
+
app/code/community/Eabi/Postoffice/Model/Carrier/Result.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * This class is required in order to avoid sorting by the price, which is default behaviour for Magento, when sorting shipping methods
35
+ * for single carrier.
36
+ *
37
+ * @author matishalmann
38
+ */
39
+ class Eabi_Postoffice_Model_Carrier_Result extends Mage_Shipping_Model_Rate_Result {
40
+
41
+ public function sortRatesByPrice() {
42
+ return $this;
43
+ }
44
+ }
45
+
app/code/community/Eabi/Postoffice/Model/Carriermodule.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ *
35
+ * <p>Carrier module represents unlimited amount of parcel terminals which can be placed in many countries.</p>
36
+ * <p>Represents one entry from eabi_carriermodule database table.</p>
37
+ * <p>Structure description:</p>
38
+ * <ul>
39
+ <li><b>id</b> - unique auto increment id</li>
40
+ <li><b>carrier_code</b> - Magento shipping method carrier code</li>
41
+ <li><b>class_name</b> - full Magento model name</li>
42
+ <li><b>update_time</b> - time when this carrier module was last updated</li>
43
+ </ul>
44
+ * @author matishalmann
45
+ */
46
+ class Eabi_Postoffice_Model_Carriermodule extends Mage_Core_Model_Abstract {
47
+
48
+ /**
49
+ *
50
+ * @var array
51
+ */
52
+ private $_groups = array();
53
+
54
+
55
+ public function _construct() {
56
+ parent::_construct();
57
+ $this->_init('eabi_postoffice/carriermodule');
58
+
59
+ }
60
+
61
+ /**
62
+ * <p>Attempts to synchronize list of parcel terminals with remote server if update time was earlier than update interval for the current carrier.</p>
63
+ * @param bool $byPassTimeCheck when set to true, then data is updated anyway
64
+ * @return null
65
+ * @throws Exception
66
+ */
67
+ public function updateCarrierData($byPassTimeCheck) {
68
+ $className = $this->getData('class_name');
69
+ $date = new Zend_Date(time(), Zend_Date::TIMESTAMP);
70
+ if (!$className || $className == '' || $this->getId() <= 0) {
71
+ throw new Exception('Cannot update Carrier data for empty CarrierModule');
72
+ }
73
+ //load the carrier
74
+ $shippingMethodModel = Mage::getModel($this->getData('class_name'));
75
+
76
+ if (!($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
77
+ throw new Exception('This method can only update instances of Eabi_Postoffice_Model_Office carriers');
78
+ }
79
+
80
+
81
+ $lastUpdated = $shippingMethodModel->getConfigData('last_updated');
82
+ $updateInterval = $shippingMethodModel->getConfigData('update_interval');
83
+
84
+ if ($lastUpdated + ($updateInterval * 60) < $date->get(Zend_Date::TIMESTAMP) || $byPassTimeCheck) {
85
+ $oldData = array();
86
+
87
+ //load the old data
88
+ $oldDataCollection = Mage::getModel('eabi_postoffice/office')->getCollection()
89
+ ->addFieldToFilter('remote_module_id', $this->getId())
90
+ ;
91
+
92
+ foreach ($oldDataCollection as $oldDataElement) {
93
+ $oldData[(string)$oldDataElement->getRemotePlaceId()] = $oldDataElement;
94
+
95
+ if ($oldDataElement->getGroupName() != '' && $oldDataElement->getGroupId() > 0) {
96
+ $this->_groups[(string)$oldDataElement->getGroupId()] = $oldDataElement->getGroupName();
97
+ }
98
+
99
+ }
100
+ //load the new data
101
+ $newData = $shippingMethodModel->getOfficeList();
102
+ if (!is_array($newData)) {
103
+ //we had a failure loading new models
104
+ //update the last updated interval and return
105
+ $shippingMethodModel->setConfigData('last_updated', $date->get(Zend_Date::TIMESTAMP));
106
+ return;
107
+ }
108
+ $processedPlaceIds = array();
109
+ foreach ($newData as $newDataElement) {
110
+
111
+ if (!isset($newDataElement['group_id']) || !isset($newDataElement['group_name'])
112
+ || $newDataElement['group_id'] == '' || $newDataElement['group_name'] == '') {
113
+ $this->assignGroup($newDataElement);
114
+
115
+ }
116
+ if (!isset($newDataElement['group_sort'])) {
117
+ $newDataElement['group_sort'] = $shippingMethodModel->getGroupSort($newDataElement['group_name']);
118
+ }
119
+
120
+ if (!isset($oldData[(string)$newDataElement['place_id']])) {
121
+ //add to the list
122
+ $oldData[(string)$newDataElement['place_id']] = Mage::getModel('eabi_postoffice/office')
123
+ ->fromOfficeElement($newDataElement, $this->getId());
124
+ } else {
125
+ //update the olddata element
126
+ $oldData[(string)$newDataElement['place_id']] = $oldData[(string)$newDataElement['place_id']]->fromOfficeElement($newDataElement);
127
+ }
128
+ $processedPlaceIds[(string)$newDataElement['place_id']] = (string)$newDataElement['place_id'];
129
+
130
+ }
131
+
132
+ //delete the removed elements
133
+ foreach ($oldData as $placeId => $oldDataElement) {
134
+ if (!isset($processedPlaceIds[(string)$placeId])) {
135
+ //delete the element
136
+ $oldDataElement->delete();
137
+
138
+ } else {
139
+ //save the element
140
+ $oldDataElement->save();
141
+
142
+ }
143
+ }
144
+
145
+ //save the config data too
146
+
147
+ $shippingMethodModel->setConfigData('last_updated', $date->get(Zend_Date::TIMESTAMP));
148
+
149
+ //all done!
150
+
151
+ }
152
+
153
+ }
154
+
155
+ /**
156
+ * <p>Keeps track of generated group_id-s based on the group_names, making sure that each group has it's unique id.</p>
157
+ * @param array $dataElement
158
+ */
159
+ protected function assignGroup(array &$dataElement) {
160
+ $groupNames = array();
161
+ if (isset($dataElement['county']) && !empty($dataElement['county'])) {
162
+ $groupNames[] = $dataElement['county'];
163
+ }
164
+ if (isset($dataElement['city']) && !empty($dataElement['city'])) {
165
+ $groupNames[] = $dataElement['city'];
166
+ }
167
+ if (count($groupNames) > 0) {
168
+ $groupName = implode('/', $groupNames);
169
+ if (in_array($groupName, $this->_groups)) {
170
+ $dataElement['group_name'] = $groupName;
171
+ $dataElement['group_id'] = array_search($groupName, $this->_groups);
172
+ } else {
173
+ $new_id = 1;
174
+ if (count($this->_groups) > 0) {
175
+ $new_id = max(array_keys($this->_groups)) + 1;
176
+
177
+ }
178
+ $this->_groups[(string)$new_id] = $groupName;
179
+ $dataElement['group_name'] = $groupName;
180
+ $dataElement['group_id'] = array_search($groupName, $this->_groups);
181
+ }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * <p>Assigns created time and update time before saving.</p>
187
+ * @return Eabi_Postoffice_Model_Carriermodule
188
+ */
189
+ protected function _beforeSave() {
190
+ if ($this->isObjectNew()) {
191
+ $this->setCreatedTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
192
+ $this->setUpdateTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
193
+
194
+ } else {
195
+ $this->setUpdateTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
196
+ }
197
+ return parent::_beforeSave();
198
+ }
199
+
200
+ /**
201
+ * <p>Initiates date object</p>
202
+ */
203
+ public static function eabi_init() {
204
+ self::$_date = new Zend_Date(time(), Zend_Date::TIMESTAMP);
205
+ }
206
+
207
+ protected static $_date;
208
+
209
+ }
210
+ Eabi_Postoffice_Model_Carriermodule::eabi_init();
app/code/community/Eabi/Postoffice/Model/Mysql4/Carriermodule.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ *
35
+ * @author matishalmann
36
+ */
37
+ class Eabi_Postoffice_Model_Mysql4_Carriermodule extends Mage_Core_Model_Mysql4_Abstract {
38
+
39
+
40
+ public function _construct() {
41
+ $this->_init('eabi_postoffice/carriermodule', 'id');
42
+ }
43
+ }
44
+
45
+
app/code/community/Eabi/Postoffice/Model/Mysql4/Carriermodule/Collection.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Represents collection of eabi_carriermodule database entries</p>
35
+ * @author matishalmann
36
+ */
37
+ class Eabi_Postoffice_Model_Mysql4_Carriermodule_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
38
+
39
+ public function _construct() {
40
+ parent::_construct();
41
+ $this->_init('eabi_postoffice/carriermodule');
42
+ }
43
+
44
+ }
app/code/community/Eabi/Postoffice/Model/Mysql4/Office.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ *
35
+ * @author matishalmann
36
+ */
37
+ class Eabi_Postoffice_Model_Mysql4_Office extends Mage_Core_Model_Mysql4_Abstract {
38
+
39
+ public function _construct() {
40
+ $this->_init('eabi_postoffice/office', 'id');
41
+ }
42
+
43
+ }
44
+
45
+
app/code/community/Eabi/Postoffice/Model/Mysql4/Office/Collection.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Represents collection of eabi_postoffice database table entries</p>
35
+ * @author matishalmann
36
+ */
37
+ class Eabi_Postoffice_Model_Mysql4_Office_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
38
+ //put your code here
39
+ public function _construct() {
40
+ parent::_construct();
41
+ $this->_init('eabi_postoffice/office');
42
+ }
43
+
44
+ }
app/code/community/Eabi/Postoffice/Model/Office.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Represents one entry from eabi_postoffice table.</p>
35
+ * <p>Represents one parcel terminal, which can be selected as preferred shipping location for end user.</p>
36
+ * <p>Structure:</p>
37
+ * <ul>
38
+ <li><b>id</b> - unique auto incement id for entry</li>
39
+ <li><b>remote_module_id</b> - refers to eabi_carriermodule.id</li>
40
+ <li><b>remote_module_name</b> - Magento carrier code, also refers to eabi_carriermodule.carrier_code</li>
41
+ <li><b>remote_place_id</b> - Parcel terminal numeric ID, which is provided by remote server.</li>
42
+ <li><b>remote_servicing_place_id</b> - not used</li>
43
+ <li><b>name</b> - human readable remote parcel terminal short name</li>
44
+ <li><b>city</b> - city where remote parcel terminal is located (optional)</li>
45
+ <li><b>county</b> - region or county where remote parcel terminal is located (optional)</li>
46
+ <li><b>zip_code</b> - zip code for the remote parcel terminal (optional)</li>
47
+ <li><b>country</b> - ISO-3166 country code for the remote parcel terminal</li>
48
+ <li><b>description</b> - Extra human readable information can be entered here like address, opening times, etc...</li>
49
+ <li><b>group_id</b> - unique id that represents city/county combination group. Module auto generates this id for you.</li>
50
+ <li><b>group_name</b> - merged city/county if any of those is set. Otherwise left empty</li>
51
+ <li><b>group_sort</b> - higher the number, the more important group is and thus parcel terminal belonging to more important group is displayed before the others.</li>
52
+ <li><b>local_carrier_id</b> - not used</li>
53
+ <li><b>created_time</b> - time, when this parcel terminal entry was created</li>
54
+ <li><b>update_time</b> - time, when this parcel terminal was last updated</li>
55
+ <li><b>cached_attributes</b> - not used, but can store data in serialized form</li>
56
+ </ul>
57
+ * @author matishalmann
58
+ */
59
+ class Eabi_Postoffice_Model_Office extends Mage_Core_Model_Abstract {
60
+ //put your code here
61
+
62
+ public function _construct() {
63
+ parent::_construct();
64
+ $this->_init('eabi_postoffice/office');
65
+
66
+ }
67
+
68
+ public function fromOfficeElement(array $officeElement, $remoteModuleId = false) {
69
+ $remoteModuleId = (int)$remoteModuleId;
70
+ if ($remoteModuleId > 0) {
71
+ $remoteModule = Mage::getModel('eabi_postoffice/carriermodule')->load($remoteModuleId);
72
+ if (!is_object($remoteModule) || $remoteModule->getId() <= 0) {
73
+ throw new Exception('Carrier module could not be detected for this Office model');
74
+ }
75
+ $this->setData('remote_module_id', $remoteModule->getId());
76
+ $this->setData('remote_module_name', $remoteModule->getCarrierCode());
77
+ } else {
78
+ if ($this->getData('remote_module_id') == '' || $this->getData('remote_module_name') == '' ) {
79
+ throw new Exception('Remote module ID and Remote Module Name have to be defined');
80
+ }
81
+ }
82
+
83
+ //start setting the data
84
+ //mandatory
85
+ $this->setData('remote_place_id', $officeElement['place_id']);
86
+ $this->setData('name', $officeElement['name']);
87
+
88
+ if (isset($officeElement['servicing_place_id'])) {
89
+ $this->setData('remote_servicing_place_id', $officeElement['servicing_place_id']);
90
+ }
91
+ if (isset($officeElement['city'])) {
92
+ $this->setData('city', $officeElement['city']);
93
+ }
94
+ if (isset($officeElement['county'])) {
95
+ $this->setData('county', $officeElement['county']);
96
+ }
97
+ if (isset($officeElement['zip'])) {
98
+ $this->setData('zip_code', $officeElement['zip']);
99
+ }
100
+ if (isset($officeElement['country'])) {
101
+ $this->setData('country', $officeElement['country']);
102
+ }
103
+ if (isset($officeElement['description'])) {
104
+ $this->setData('description', $officeElement['description']);
105
+ }
106
+ if (isset($officeElement['group_id']) && isset($officeElement['group_name'])) {
107
+ $this->setData('group_id', $officeElement['group_id']);
108
+ $this->setData('group_name', $officeElement['group_name']);
109
+ if (isset($officeElement['group_sort'])) {
110
+ $this->setData('group_sort', $officeElement['group_sort']);
111
+ }
112
+ }
113
+
114
+ if (isset($officeElement['extra']) && is_array($officeElement['extra'])) {
115
+ $this->setData('cached_attributes', serialize($officeElement['extra']));
116
+ }
117
+
118
+
119
+ return $this;
120
+
121
+ }
122
+
123
+ public function loadByCodeAndRemoteId($code, $remoteId) {
124
+ return $this->getCollection()
125
+ ->addFieldToFilter('remote_module_name', $code)
126
+ ->addFieldToFilter('remote_place_id', $remoteId)
127
+ ->getFirstItem();
128
+ }
129
+
130
+
131
+ protected function _beforeSave() {
132
+ if (method_exists($this, 'isObjectNew') && $this->isObjectNew()) {
133
+ $this->setCreatedTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
134
+ $this->setUpdateTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
135
+
136
+ } else {
137
+ $this->setUpdateTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
138
+ }
139
+ if ($this->getCreatedTime() == '') {
140
+ $this->setCreatedTime(self::$_date->get('yyyy-MM-dd HH:mm:ss'));
141
+ }
142
+ return parent::_beforeSave();
143
+ }
144
+
145
+ public static function eabi_init() {
146
+ self::$_date = new Zend_Date(time(), Zend_Date::TIMESTAMP);
147
+ }
148
+
149
+ protected static $_date;
150
+
151
+ }
152
+ Eabi_Postoffice_Model_Office::eabi_init();
app/code/community/Eabi/Postoffice/Model/Orderview.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Creates the extra buttons in the sales/order/view in admin.</p>
35
+ * <p>Added buttons are:
36
+ * <ul>
37
+ * <li>Send parcel data to server - if automatic data sending is available for the selected order and data has not been already sent</li>
38
+ * <li>Print packing slip - If automatic data has been sent and packing slip print functionality is available.</li>
39
+ * </ul>
40
+ * </p>
41
+ *
42
+ *
43
+ * @author matishalmann
44
+ */
45
+ class Eabi_Postoffice_Model_Orderview extends Eabi_Livehandler_Model_Adminhtml_Gridmanager {
46
+
47
+ private $_incrementId;
48
+ private $_orderId;
49
+
50
+ public function _construct() {
51
+ parent::_construct();
52
+ $this->_init('eabi_postoffice/orderview');
53
+
54
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
55
+
56
+ $order = Mage::getModel('sales/order')->load($orderId);
57
+ if (is_object($order) && $order->getId() > 0) {
58
+ $this->_incrementId = $order->getIncrementId();
59
+ $this->_orderId = $order->getId();
60
+ $barcode = Mage::helper('eabi_postoffice')->getBarcode($order->getIncrementId());
61
+
62
+ if (is_string($barcode)) {
63
+ $url = Mage::helper('adminhtml')->getUrl('eabi_postoffice/adminhtml_postoffice/addresscardpdf', array('order_id'=> $orderId));
64
+
65
+ $this->addActionButton('eabi_get_addresscard', Mage::helper('eabi_postoffice')->__('Print packing slip'), "setLocation('".$url."')");
66
+ }
67
+
68
+ if (Mage::helper('eabi_postoffice')->isDataSent($order->getIncrementId()) === false) {
69
+ $confirmText = str_replace('\"', '"', addslashes(Mage::helper('eabi_postoffice')->__('Send shipping data to server') . '?'));
70
+ $dataSendTextSuccess = str_replace('\"', '"', addslashes(Mage::helper('eabi_postoffice')->__('Data sent to server, please verify the status from the order comments')));
71
+ $url = Mage::helper('adminhtml')->getUrl('eabi_postoffice/adminhtml_postoffice/autosend', array('order_id' => $this->_orderId));
72
+ $js = <<<EOT
73
+ if(confirm("{$confirmText}")){new Ajax.Request("{$url}",{method:"get",onSuccess:function(a){json=a.responseText.evalJSON(true);if(json){if(json["error"]){alert(json["error"])}else if(json["success"]){alert("{$dataSendTextSuccess}");location.reload(true)}}else{alert("Fatal error")}},onFailure:function(){alert("Fatal error")}})}; return false;
74
+ EOT;
75
+
76
+ $this->addActionButton('eabi_send_data_to_server', Mage::helper('eabi_postoffice')->__('Send shipping data to server'), $js);
77
+ }
78
+
79
+ }
80
+
81
+
82
+ }
83
+
84
+ protected function _getAdditionalJs($currentJs) {
85
+ if ($currentJs != '' && $this->_incrementId != '') {
86
+ $confirmText = str_replace('\"', '"', addslashes(Mage::helper('eabi_postoffice')->__('Send shipping data to server') . '?'));
87
+ $dataSendTextSuccess = str_replace('\"', '"', addslashes(Mage::helper('eabi_postoffice')->__('Data sent to server, please verify the status from the order comments')));
88
+ $url = Mage::helper('adminhtml')->getUrl('eabi_postoffice/adminhtml_postoffice/autosend', array('order_id' => $this->_orderId));
89
+ return '';
90
+
91
+
92
+ return <<<EOT
93
+
94
+ function eabi_autosend_data() {
95
+ var eabi_confirmR = confirm('{$confirmText}');
96
+ if (confirm('{$confirmText}')) {
97
+ new Ajax.Request('{$url}', {
98
+ method: 'get',
99
+ onSuccess: function(transport) {
100
+ json = transport.responseText.evalJSON(true);
101
+ if (json) {
102
+ if (json['error']) {
103
+ alert(json['error']);
104
+ } else if (json['success']) {
105
+ alert('{$datasendTextSuccess}');
106
+ location.reload(true);
107
+ }
108
+ } else {
109
+ alert('Fatal error');
110
+ }
111
+ },
112
+ onFailure: function() {
113
+ alert('Fatal error');
114
+ }
115
+ });
116
+ }
117
+ }
118
+ EOT;
119
+ }
120
+ return '';
121
+ }
122
+
123
+
124
+ public function service($postData) {
125
+ return array();
126
+ }
127
+
128
+ }
129
+
130
+
app/code/community/Eabi/Postoffice/Model/Source/Sendevent.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Represents possible moments for automatic data sending.</p>
35
+ * @author matishalmann
36
+ */
37
+ class Eabi_Postoffice_Model_Source_Sendevent {
38
+ //put your code here
39
+
40
+ public function toOptionArray() {
41
+ $options = array();
42
+
43
+ $options[] = array(
44
+ 'label' => Mage::helper('eabi_postoffice')->__('After successful checkout'),
45
+ 'value' => 'after_checkout',
46
+ );
47
+ $options[] = array(
48
+ 'label' => Mage::helper('eabi_postoffice')->__('After successful shipment creation'),
49
+ 'value' => 'after_shipment',
50
+ );
51
+ $options[] = array(
52
+ 'label' => Mage::helper('eabi_postoffice')->__('I will send data myself by clicking on the button'),
53
+ 'value' => 'manual',
54
+ );
55
+
56
+ return $options;
57
+ }
58
+
59
+
60
+ }
61
+
app/code/community/Eabi/Postoffice/Model/Updater.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ *
35
+ * <p>Updates list of available parcel terminal in all carriers that are declared in eabi_carriermodule database table</p>
36
+ * @author matishalmann
37
+ */
38
+ class Eabi_Postoffice_Model_Updater extends Mage_Core_Model_Abstract {
39
+
40
+ public function _construct() {
41
+ parent::_construct();
42
+ $this->_init('eabi_postoffice/updater');
43
+
44
+ }
45
+ /**
46
+ *<p>Updates list of postoffices for all of the carriers.<p>
47
+ * <p>If $forceUpdate param is not supplied, then the carrier will not be updated, if last_update + update_interval has not yet been passed.</p>
48
+ *
49
+ *
50
+ * @param bool $forceUpdate when set to true, then update is performed anyway.
51
+ */
52
+ public function updateCarriers($forceUpdate = false) {
53
+ $carriers = Mage::getModel('eabi_postoffice/carriermodule')->getCollection();
54
+
55
+ foreach ($carriers as $carrier) {
56
+ $carrier->updateCarrierData($forceUpdate);
57
+ }
58
+
59
+ }
60
+
61
+ }
62
+
63
+
app/code/community/Eabi/Postoffice/controllers/Adminhtml/PostofficeController.php ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ *
35
+ * Contains the functions, which helps store administrator to place an order using this carrier or the subclasses of this carrier and
36
+ * also contains actions related to printing packing slips and sending automatic parcel data to the third party carrier server.
37
+ * @author matishalmann
38
+ */
39
+ class Eabi_Postoffice_Adminhtml_PostofficeController extends Mage_Adminhtml_Controller_Action {
40
+
41
+ protected function _initAction() {
42
+ return $this;
43
+ }
44
+
45
+ protected function _construct() {
46
+
47
+ }
48
+
49
+ /**
50
+ * Rebuilds the list of postoffices for the selected carrier immediately and returns json response.
51
+ *
52
+ *
53
+ */
54
+ public function rebuildAction() {
55
+ $result = $this->_rebuild();
56
+ echo json_encode($result);
57
+ die();
58
+ }
59
+
60
+ protected function _rebuild() {
61
+ $carrierCode = $this->getRequest()->getParam('carrier_code', '');
62
+ if ($carrierCode == '') {
63
+ return array('error' => Mage::helper('eabi_postoffice')->__('Invalid Carrier code'));
64
+ }
65
+ $carrierModule = Mage::getModel('eabi_postoffice/carriermodule')->load($carrierCode, 'carrier_code');
66
+ if (!is_object($carrierModule) ||$carrierModule->getId() <= 0) {
67
+ return array('error' => Mage::helper('eabi_postoffice')->__('Invalid Carrier code'));
68
+ }
69
+ try {
70
+ $carrierModule->updateCarrierData(true);
71
+ } catch (Exception $e) {
72
+ return array('error' => $e->getMessage());
73
+ }
74
+ return array('success' => true);
75
+
76
+ }
77
+
78
+ /**
79
+ * Prints out packing slip pdf for the selected order as response or echoes that barcode is not available.
80
+ *
81
+ *
82
+ * @return type
83
+ */
84
+ public function addresscardpdfAction() {
85
+ $orderId = (int)$this->getRequest()->getParam('order_id', 0);
86
+ if ($orderId <= 0) {
87
+ return;
88
+ }
89
+ $order = Mage::getModel('sales/order')->load($orderId);
90
+ if (!$order || $order->getId() <= 0) {
91
+ return;
92
+ }
93
+ $incrementId = $order->getIncrementId();
94
+ $res = Mage::helper('eabi_postoffice')->getBarcodePdf($incrementId);
95
+ if ($res !== false) {
96
+ header('Content-Type: application/pdf');
97
+ header('Content-Disposition: attachment; filename="addresscard-' . $incrementId . '.pdf"');
98
+ echo $res;
99
+ } else {
100
+ echo 'No barcode available';
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Attempts to automatically send the shipment data for the selected order to the third party carrier server
106
+ * and returns the result as json response.
107
+ *
108
+ *
109
+ *
110
+ */
111
+ public function autosendAction() {
112
+ $result = $this->_autoSend();
113
+ echo json_encode($result);
114
+ die();
115
+ }
116
+
117
+ protected function _autoSend() {
118
+ //get the order id
119
+ $orderId = (int)$this->getRequest()->getParam('order_id', 0);
120
+ if ($orderId <= 0) {
121
+ return array('error' => Mage::helper('eabi_postoffice')->__('Invalid Order ID'));
122
+ }
123
+ $order = Mage::getModel('sales/order')->load($orderId);
124
+ if (!$order || $order->getId() <= 0) {
125
+ return array('error' => Mage::helper('eabi_postoffice')->__('Invalid Order ID'));
126
+ }
127
+
128
+ //get the carrier
129
+ $shippingMethod = $order->getShippingMethod();
130
+ $paymentMethod = $order->getPayment();
131
+
132
+ //get the shipping code from the order and call the module from it.
133
+ $shippingCarrierCode = substr($shippingMethod, 0, strpos($shippingMethod, '_'));
134
+ $shippingMethodModel = Mage::getModel('shipping/shipping')->getCarrierByCode($shippingCarrierCode);
135
+
136
+ if (!($shippingMethodModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)){
137
+ return array('error' => Mage::helper('eabi_postoffice')->__('This carrier is not subclass of Eabi_Postoffice_Model_Carrier_Abstract'));
138
+ }
139
+ $shippingMethodModel->setStoreId($order->getStoreId());
140
+
141
+ //determine if auto send is available
142
+ if (!$shippingMethodModel->isAutoSendAvailable()) {
143
+ return array('error' => Mage::helper('eabi_postoffice')->__('Automatic data sending is not available for the selected carrier'));
144
+ }
145
+
146
+ if (round($order->getTotalDue(), 2) > 0 && (!$shippingMethodModel->getConfigData('enable_cod') ||
147
+ ($shippingMethodModel->getConfigData('enable_cod') && $paymentMethod->getMethod() != 'eabicodpayment'))) {
148
+ return array('error' => Mage::helper('eabi_postoffice')->__('This order has not yet been fully paid'));
149
+ }
150
+
151
+ if (($order->isCanceled() || $order->getIsVirtual())) {
152
+ return array('error' => Mage::helper('eabi_postoffice')->__('This order cannot be shipped'));
153
+ }
154
+
155
+
156
+ //send the data
157
+ Mage::helper('eabi_postoffice')->sendManualOrderData($order->getIncrementId(), $shippingMethodModel->getConfigData('senddata_event'));
158
+
159
+
160
+ //return the results
161
+ return array('success' => true);
162
+
163
+ }
164
+
165
+ /**
166
+ * <p>Returns the contents for the selected carriers.</p>
167
+ * <p>Mainly it returns two select menus, where first select menu contains all the groups and
168
+ * second select menu contains actual offices, which belong to the selected group</p>
169
+ *
170
+ *
171
+ *
172
+ *
173
+ * @return html
174
+ * @throws Exception
175
+ */
176
+ public function officeAction() {
177
+ try {
178
+ if ($this->getRequest()->isPost()) {
179
+
180
+ $post = $this->getRequest()->getPost();
181
+ $storeId = (int)$this->getRequest()->getParam('store_id', 0);
182
+ if ($storeId <= 0) {
183
+ throw new Exception('Store ID must be supplied');
184
+ }
185
+ $url = $this->getUrl('eabi_postoffice/adminhtml_postoffice/office', array('store_id' => $storeId, '_secure' => true));
186
+ $addressId = $post['address_id'];
187
+ $carrierCode = $post['carrier_code'];
188
+ $carrierId = $post['carrier_id'];
189
+ $divId = $post['div_id'];
190
+ $groupId = isset($post['group_id']) ? ((int) $post['group_id']) : 0;
191
+ $placeId = isset($post['place_id']) ? ((int) $post['place_id']) : 0;
192
+ $shippingModel = Mage::getModel('shipping/shipping')->getCarrierByCode($carrierCode);
193
+
194
+ //we are in admin section, so we need to set the store it manually
195
+ $shippingModel->setStoreId($storeId);
196
+
197
+ if (!$shippingModel->isAjaxInsertAllowed($addressId)) {
198
+ throw new Exception('Invalid Shipping method');
199
+ }
200
+ if (!($shippingModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
201
+ throw new Exception('Invalid Shipping model');
202
+ }
203
+
204
+ if ($placeId > 0) {
205
+ $place = $shippingModel->getTerminal($placeId);
206
+ if ($place) {
207
+ $shippingModel->setOfficeToSession($addressId, $place);
208
+ echo 'true';
209
+ return;
210
+ } else {
211
+ echo 'false';
212
+ return;
213
+ }
214
+ }
215
+
216
+ $groups = $shippingModel->getGroups($addressId);
217
+ $html = '';
218
+
219
+ if ($groups) {
220
+ $groupSelectWidth = (int)$shippingModel->getConfigData('group_width');
221
+ $style = '';
222
+ if ($groupSelectWidth > 0) {
223
+ $style = ' style="width:'.$groupSelectWidth.'px"';
224
+ }
225
+ $html .= '<select onclick="return false;" ' . $style . ' name="' . $carrierCode . '_select_group" onchange="new Ajax.Request(\'' . $url . '\',{method:\'post\',parameters:{carrier_id:\'' . $carrierId . '\',carrier_code:\'' . $carrierCode . '\',div_id:\'' . $divId . '\',address_id:\'' . $addressId . '\',group_id: $(this).getValue()},onSuccess:function(a){$(\'' . $divId . '\').update(a.responseText)}});">';
226
+ $html .= '<option value="">';
227
+ $html .= htmlspecialchars(Mage::helper('eabi_postoffice')->__('-- select --'));
228
+ $html .= '</option>';
229
+
230
+ foreach ($groups as $group) {
231
+ $html .= '<option value="' . $group->getGroupId() . '"';
232
+ if ($groupId > 0 && $groupId == $group->getGroupId()) {
233
+ $html .= ' selected="selected"';
234
+ }
235
+ $html .= '>';
236
+ $html .= $shippingModel->getGroupTitle($group);
237
+ $html .= '</option>';
238
+ }
239
+ $html .= '</select>';
240
+ }
241
+
242
+ //get the group values
243
+ if ($groupId > 0 || $groups === false) {
244
+ $terminals = array();
245
+ if ($groups !== false) {
246
+ $terminals = $shippingModel->getTerminals($groupId, $addressId);
247
+ } else {
248
+ $terminals = $shippingModel->getTerminals(null, $addressId);
249
+ }
250
+ $officeSelectWidth = (int)$shippingModel->getConfigData('office_width');
251
+ $style = '';
252
+ if ($officeSelectWidth > 0) {
253
+ $style = ' style="width:'.$officeSelectWidth.'px"';
254
+ }
255
+ $html .= '<select onclick="return false;" '.$style.' name="' . $carrierCode . '_select_office" onchange="var sel = $(this); new Ajax.Request(\'' . $url . '\',{method:\'post\',parameters:{carrier_id:\'' . $carrierId . '\',carrier_code:\'' . $carrierCode . '\',div_id:\'' . $divId . '\',address_id:\'' . $addressId . '\',place_id: sel.getValue()},onSuccess:function(a){ if (a.responseText == \'true\') { $(\'' . $carrierId . '\').writeAttribute(\'value\', \'' . $carrierCode . '_' . $carrierCode . '_\' + sel.getValue()); $(\'' . $carrierId . '\').click(); }}});">';
256
+ $html .= '<option value="">';
257
+ $html .= htmlspecialchars(Mage::helper('eabi_postoffice')->__('-- select --'));
258
+ $html .= '</option>';
259
+
260
+ $optionsHtml = '';
261
+ $previousGroup = false;
262
+ $optGroupHtml = '';
263
+ $groupCount = 0;
264
+
265
+ foreach ($terminals as $terminal) {
266
+ if ($shippingModel->getGroupTitle($terminal) != $previousGroup && !$shippingModel->getConfigData('disable_group_titles')) {
267
+ if ($previousGroup != false) {
268
+ $optionsHtml .= '</optgroup>';
269
+ $optionsHtml .= '<optgroup label="'.$shippingModel->getGroupTitle($terminal).'">';
270
+ } else {
271
+ $optGroupHtml .= '<optgroup label="'.$shippingModel->getGroupTitle($terminal).'">';
272
+ }
273
+ $groupCount++;
274
+ }
275
+ $optionsHtml .= '<option value="' . $terminal->getRemotePlaceId() . '"';
276
+ if (false) {
277
+ $optionsHtml .= ' selected="selected"';
278
+ }
279
+ $optionsHtml .= '>';
280
+ $optionsHtml .= $shippingModel->getTerminalTitle($terminal);
281
+ $optionsHtml .= '</option>';
282
+
283
+ $previousGroup = $shippingModel->getGroupTitle($terminal);
284
+ }
285
+ if ($groupCount > 1) {
286
+ $html .= $optGroupHtml . $optionsHtml . '</optgroup>';
287
+ } else {
288
+ $html .= $optionsHtml;
289
+ }
290
+
291
+ $html .= '</select>';
292
+
293
+
294
+ }
295
+
296
+
297
+ echo $html;
298
+ } else {
299
+ throw new Exception('Invalid request method');
300
+ }
301
+ } catch (Exception $e) {
302
+ $this->getResponse()->setHeader('HTTP/1.1', '500 Internal error');
303
+ $this->getResponse()->setHeader('Status', '500 Internal error');
304
+ throw $e;
305
+ }
306
+ return;
307
+ }
308
+
309
+
310
+ /**
311
+ * <p>If older instance of Eabi_Postoffice exists, then this function attempts to remove it</p>
312
+ * @return null
313
+ */
314
+ public function removeAction() {
315
+ $result = array('status' => 'failed');
316
+ if ($this->getRequest()->isPost() && $this->getRequest()->getPost('remove') == 'true') {
317
+ $dirName = Mage::getBaseDir('code').'/local/Eabi/Postoffice';
318
+ if (is_dir($dirName) && file_exists($dirName.'/etc/config.xml')) {
319
+ $directory = new Varien_Io_File();
320
+ $deleteResult = $directory->rmdir($dirName, true);
321
+ if ($deleteResult) {
322
+ $result['status'] = 'success';
323
+ }
324
+ }
325
+
326
+ }
327
+ $this->getResponse()->setRawHeader('Content-type: application/json');
328
+ $this->getResponse()->setBody(json_encode($result));
329
+ return;
330
+ }
331
+
332
+ /**
333
+ *
334
+ * @return Eabi_Livehandler_Helper_Data
335
+ */
336
+ protected function _getEabi() {
337
+ return Mage::helper('eabi');
338
+ }
339
+
340
+
341
+ }
342
+
app/code/community/Eabi/Postoffice/controllers/IndexController.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ /**
34
+ * <p>Displays list of available parcel terminals for current carrier and address if carrier supports parcel terminals feature</p>
35
+ *
36
+ * @author matishalmann
37
+ */
38
+ class Eabi_Postoffice_IndexController extends Mage_Core_Controller_Front_Action {
39
+
40
+
41
+ /**
42
+ * <p>Returns the contents for the selected carriers.</p>
43
+ * <p>Mainly it returns two select menus, where first select menu contains all the groups and
44
+ * second select menu contains actual offices, which belong to the selected group</p>
45
+ *
46
+ *
47
+ *
48
+ *
49
+ * @return html
50
+ * @throws Exception
51
+ */
52
+ public function officeAction() {
53
+ try {
54
+ if ($this->getRequest()->isPost()) {
55
+ $url = Mage::getUrl('eabi_postoffice/index/office', array('_secure' => true));
56
+
57
+ $post = $this->getRequest()->getPost();
58
+ $addressId = $post['address_id'];
59
+ $carrierCode = $post['carrier_code'];
60
+ $carrierId = $post['carrier_id'];
61
+ $divId = $post['div_id'];
62
+ $groupId = isset($post['group_id']) ? ((int) $post['group_id']) : 0;
63
+ $placeId = isset($post['place_id']) ? ((int) $post['place_id']) : 0;
64
+ $shippingModel = Mage::getModel('shipping/shipping')->getCarrierByCode($carrierCode);
65
+ if (!$shippingModel->isAjaxInsertAllowed($addressId)) {
66
+ throw new Exception('Invalid Shipping method');
67
+ }
68
+ if (!($shippingModel instanceof Eabi_Postoffice_Model_Carrier_Abstract)) {
69
+ throw new Exception('Invalid Shipping model');
70
+ }
71
+
72
+ if ($placeId > 0) {
73
+ $place = $shippingModel->getTerminal($placeId);
74
+ if ($place) {
75
+ $shippingModel->setOfficeToSession($addressId, $place);
76
+ echo 'true';
77
+ return;
78
+ } else {
79
+ echo 'false';
80
+ return;
81
+ }
82
+ }
83
+
84
+ $groups = $shippingModel->getGroups($addressId);
85
+ $html = '';
86
+
87
+ if ($groups) {
88
+ $groupSelectWidth = (int)$shippingModel->getConfigData('group_width');
89
+ $style = '';
90
+ if ($groupSelectWidth > 0) {
91
+ $style = ' style="width:'.$groupSelectWidth.'px"';
92
+ }
93
+ $html .= '<select onclick="return false;" '.$style.' name="' . $carrierCode . '_select_group" onchange="new Ajax.Request(\'' . $url . '\',{method:\'post\',parameters:{carrier_id:\'' . $carrierId . '\',carrier_code:\'' . $carrierCode . '\',div_id:\'' . $divId . '\',address_id:\'' . $addressId . '\',group_id: $(this).getValue()},onSuccess:function(a){$(\'' . $divId . '\').update(a.responseText)}});">';
94
+ $html .= '<option value="">';
95
+ $html .= htmlspecialchars(Mage::helper('eabi_postoffice')->__('-- select --'));
96
+ $html .= '</option>';
97
+
98
+ foreach ($groups as $group) {
99
+ $html .= '<option value="' . $group->getGroupId() . '"';
100
+ if ($groupId > 0 && $groupId == $group->getGroupId()) {
101
+ $html .= ' selected="selected"';
102
+ }
103
+ $html .= '>';
104
+ $html .= $shippingModel->getGroupTitle($group);
105
+ $html .= '</option>';
106
+ }
107
+ $html .= '</select>';
108
+ }
109
+
110
+ //get the group values
111
+ if ($groupId > 0 || $groups === false) {
112
+ $terminals = array();
113
+ if ($groups !== false) {
114
+ $terminals = $shippingModel->getTerminals($groupId, $addressId);
115
+ } else {
116
+ $terminals = $shippingModel->getTerminals(null, $addressId);
117
+ }
118
+ $officeSelectWidth = (int)$shippingModel->getConfigData('office_width');
119
+ $style = '';
120
+ if ($officeSelectWidth > 0) {
121
+ $style = ' style="width:'.$officeSelectWidth.'px"';
122
+ }
123
+
124
+ $html .= '<select onclick="return false;" '.$style.' name="' . $carrierCode . '_select_office" onchange="var sel = $(this); new Ajax.Request(\'' . $url . '\',{method:\'post\',parameters:{carrier_id:\'' . $carrierId . '\',carrier_code:\'' . $carrierCode . '\',div_id:\'' . $divId . '\',address_id:\'' . $addressId . '\',place_id: sel.getValue()},onSuccess:function(a){ if (a.responseText == \'true\') { $(\'' . $carrierId . '\').writeAttribute(\'value\', \'' . $carrierCode . '_' . $carrierCode . '_\' + sel.getValue()); $(\'' . $carrierId . '\').click(); }}});">';
125
+ $html .= '<option value="">';
126
+ $html .= htmlspecialchars(Mage::helper('eabi_postoffice')->__('-- select --'));
127
+ $html .= '</option>';
128
+
129
+ $optionsHtml = '';
130
+ $previousGroup = false;
131
+ $optGroupHtml = '';
132
+ $groupCount = 0;
133
+
134
+ foreach ($terminals as $terminal) {
135
+ if ($shippingModel->getGroupTitle($terminal) != $previousGroup && !$shippingModel->getConfigData('disable_group_titles')) {
136
+ if ($previousGroup != false) {
137
+ $optionsHtml .= '</optgroup>';
138
+ $optionsHtml .= '<optgroup label="'.$shippingModel->getGroupTitle($terminal).'">';
139
+ } else {
140
+ $optGroupHtml .= '<optgroup label="'.$shippingModel->getGroupTitle($terminal).'">';
141
+ }
142
+ $groupCount++;
143
+ }
144
+ $optionsHtml .= '<option value="' . $terminal->getRemotePlaceId() . '"';
145
+ if (false) {
146
+ $optionsHtml .= ' selected="selected"';
147
+ }
148
+ $optionsHtml .= '>';
149
+ $optionsHtml .= $shippingModel->getTerminalTitle($terminal);
150
+ $optionsHtml .= '</option>';
151
+
152
+ $previousGroup = $shippingModel->getGroupTitle($terminal);
153
+ }
154
+ if ($groupCount > 1) {
155
+ $html .= $optGroupHtml . $optionsHtml . '</optgroup>';
156
+ } else {
157
+ $html .= $optionsHtml;
158
+ }
159
+
160
+ $html .= '</select>';
161
+ }
162
+
163
+
164
+ echo $html;
165
+ } else {
166
+ throw new Exception('Invalid request method');
167
+ }
168
+ } catch (Exception $e) {
169
+ $this->getResponse()->setHeader('HTTP/1.1', '500 Internal error');
170
+ $this->getResponse()->setHeader('Status', '500 Internal error');
171
+ throw $e;
172
+ }
173
+ return;
174
+ }
175
+
176
+ }
177
+
app/code/community/Eabi/Postoffice/etc/config.xml ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+
35
+
36
+ <config>
37
+ <modules>
38
+ <Eabi_Postoffice>
39
+ <version>0.1.2</version>
40
+ </Eabi_Postoffice>
41
+ </modules>
42
+
43
+
44
+ <frontend>
45
+ <routers>
46
+ <eabi_postoffice>
47
+ <use>standard</use>
48
+ <args>
49
+ <module>Eabi_Postoffice</module>
50
+ <frontName>eabi_postoffice</frontName>
51
+ </args>
52
+ </eabi_postoffice>
53
+ </routers>
54
+ <layout>
55
+ <updates>
56
+ <eabi_postoffice>
57
+ <file>eabi_postoffice.xml</file>
58
+ </eabi_postoffice>
59
+ </updates>
60
+ </layout>
61
+ <events>
62
+ <checkout_onepage_controller_success_action>
63
+ <observers>
64
+ <eabi_postoffice_send_data>
65
+ <type>model</type>
66
+ <class>Eabi_Postoffice_Helper_Data</class>
67
+ <method>autoSendAfterOnepage</method>
68
+ </eabi_postoffice_send_data>
69
+ </observers>
70
+ </checkout_onepage_controller_success_action>
71
+ <checkout_multishipping_controller_success_action>
72
+ <observers>
73
+ <eabi_postoffice_send_multidata>
74
+ <type>model</type>
75
+ <class>Eabi_Postoffice_Helper_Data</class>
76
+ <method>autoSendAfterMultishipping</method>
77
+ </eabi_postoffice_send_multidata>
78
+ </observers>
79
+ </checkout_multishipping_controller_success_action>
80
+ </events>
81
+ <translate>
82
+ <modules>
83
+ <eabi_postoffice>
84
+ <files>
85
+ <default>Eabi_Postoffice.csv</default>
86
+ </files>
87
+ </eabi_postoffice>
88
+ </modules>
89
+ </translate>
90
+ </frontend>
91
+
92
+ <adminhtml>
93
+ <layout>
94
+ <updates>
95
+ <eabi_postoffice>
96
+ <file>eabi_postoffice.xml</file>
97
+ </eabi_postoffice>
98
+ </updates>
99
+ </layout>
100
+ <translate>
101
+ <modules>
102
+ <eabi_postoffice>
103
+ <files>
104
+ <default>Eabi_Postoffice.csv</default>
105
+ </files>
106
+ </eabi_postoffice>
107
+ </modules>
108
+ </translate>
109
+ <events>
110
+ <sales_order_shipment_save_before>
111
+ <observers>
112
+ <eabi_postoffice_send_shipment>
113
+ <type>model</type>
114
+ <class>Eabi_Postoffice_Helper_Data</class>
115
+ <method>autoSendAfterShipment</method>
116
+ </eabi_postoffice_send_shipment>
117
+ </observers>
118
+ </sales_order_shipment_save_before>
119
+ </events>
120
+ </adminhtml>
121
+ <admin>
122
+ <translate>
123
+ <modules>
124
+ <eabi_postoffice>
125
+ <files>
126
+ <default>Eabi_Postoffice.csv</default>
127
+ </files>
128
+ </eabi_postoffice>
129
+ </modules>
130
+ </translate>
131
+ <routers>
132
+ <eabi_postoffice>
133
+ <use>admin</use>
134
+ <args>
135
+ <module>Eabi_Postoffice</module>
136
+ <frontName>eabi_postoffice</frontName>
137
+ </args>
138
+ </eabi_postoffice>
139
+ </routers>
140
+
141
+ </admin>
142
+
143
+ <global>
144
+ <models>
145
+ <eabi_postoffice>
146
+ <class>Eabi_Postoffice_Model</class>
147
+ <resourceModel>eabi_postoffice_mysql4</resourceModel>
148
+ </eabi_postoffice>
149
+ <eabi_postoffice_mysql4>
150
+ <class>Eabi_Postoffice_Model_Mysql4</class>
151
+ <entities>
152
+ <office>
153
+ <table>eabi_postoffice</table>
154
+ </office>
155
+ <carriermodule>
156
+ <table>eabi_carriermodule</table>
157
+ </carriermodule>
158
+ </entities>
159
+ </eabi_postoffice_mysql4>
160
+ </models>
161
+ <blocks>
162
+ <eabi_postoffice>
163
+ <class>Eabi_Postoffice_Block</class>
164
+ </eabi_postoffice>
165
+ </blocks>
166
+ <resources>
167
+ <eabi_postoffice_setup>
168
+ <setup>
169
+ <module>Eabi_Postoffice</module>
170
+ </setup>
171
+ <connection>
172
+ <use>core_setup</use>
173
+ </connection>
174
+ </eabi_postoffice_setup>
175
+ <eabi_postoffice_write>
176
+ <setup>
177
+ <module>Eabi_Postoffice</module>
178
+ </setup>
179
+ <connection>
180
+ <use>core_write</use>
181
+ </connection>
182
+ </eabi_postoffice_write>
183
+ <eabi_postoffice_read>
184
+ <setup>
185
+ <module>Eabi_Postoffice</module>
186
+ </setup>
187
+ <connection>
188
+ <use>core_read</use>
189
+ </connection>
190
+ </eabi_postoffice_read>
191
+ </resources>
192
+ <helpers>
193
+ <eabi_postoffice>
194
+ <class>Eabi_Postoffice_Helper</class>
195
+ </eabi_postoffice>
196
+ </helpers>
197
+
198
+ <events>
199
+ <sales_order_place_before>
200
+ <observers>
201
+ <eabi_postoffice_clear_session>
202
+ <type>model</type>
203
+ <class>Eabi_Postoffice_Helper_Data</class>
204
+ <method>clearSessions</method>
205
+ </eabi_postoffice_clear_session>
206
+ </observers>
207
+ </sales_order_place_before>
208
+ </events>
209
+ <translate>
210
+ <modules>
211
+ <eabi_postoffice>
212
+ <files>
213
+ <default>Eabi_Postoffice.csv</default>
214
+ </files>
215
+ </eabi_postoffice>
216
+ </modules>
217
+ </translate>
218
+
219
+ </global>
220
+ <crontab>
221
+ <jobs>
222
+ <eabi_postoffice_update_carrier_data>
223
+ <schedule>
224
+ <cron_expr>*/10 * * * *</cron_expr>
225
+ </schedule>
226
+ <run>
227
+ <model>eabi_postoffice/updater::updateCarriers</model>
228
+ </run>
229
+ </eabi_postoffice_update_carrier_data>
230
+ </jobs>
231
+
232
+ </crontab>
233
+ </config>
app/code/community/Eabi/Postoffice/sql/eabi_postoffice_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+ /*
37
+ * <p>Structure description for eabi_carriermodule:</p>
38
+ * <ul>
39
+ <li><b>id</b> - unique auto increment id</li>
40
+ <li><b>carrier_code</b> - Magento shipping method carrier code</li>
41
+ <li><b>class_name</b> - full Magento model name</li>
42
+ <li><b>update_time</b> - time when this carrier module was last updated</li>
43
+ </ul>
44
+ * <p>Structure description for eabi_postoffice</p>
45
+ * <ul>
46
+ <li><b>id</b> - unique auto incement id for entry</li>
47
+ <li><b>remote_module_id</b> - refers to eabi_carriermodule.id</li>
48
+ <li><b>remote_module_name</b> - Magento carrier code, also refers to eabi_carriermodule.carrier_code</li>
49
+ <li><b>remote_place_id</b> - Parcel terminal numeric ID, which is provided by remote server.</li>
50
+ <li><b>remote_servicing_place_id</b> - not used</li>
51
+ <li><b>name</b> - human readable remote parcel terminal short name</li>
52
+ <li><b>city</b> - city where remote parcel terminal is located (optional)</li>
53
+ <li><b>county</b> - region or county where remote parcel terminal is located (optional)</li>
54
+ <li><b>zip_code</b> - zip code for the remote parcel terminal (optional)</li>
55
+ <li><b>country</b> - ISO-3166 country code for the remote parcel terminal</li>
56
+ <li><b>description</b> - Extra human readable information can be entered here like address, opening times, etc...</li>
57
+ <li><b>group_id</b> - unique id that represents city/county combination group. Module auto generates this id for you.</li>
58
+ <li><b>group_name</b> - merged city/county if any of those is set. Otherwise left empty</li>
59
+ <li><b>group_sort</b> - higher the number, the more important group is and thus parcel terminal belonging to more important group is displayed before the others.</li>
60
+ <li><b>local_carrier_id</b> - not used</li>
61
+ <li><b>created_time</b> - time, when this parcel terminal entry was created</li>
62
+ <li><b>update_time</b> - time, when this parcel terminal was last updated</li>
63
+ <li><b>cached_attributes</b> - not used, but can store data in serialized form</li>
64
+ </ul>
65
+ */
66
+ $installer->run("
67
+ DROP TABLE IF EXISTS {$this->getTable('eabi_postoffice')};
68
+ DROP TABLE IF EXISTS {$this->getTable('eabi_carriermodule')};
69
+
70
+ CREATE TABLE {$this->getTable('eabi_postoffice')} (
71
+ `id` int(11) unsigned NOT NULL auto_increment,
72
+ `remote_module_id` int(11) unsigned NOT NULL,
73
+ `remote_module_name` varchar(255) NOT NULL,
74
+ `remote_place_id` int(11) unsigned NOT NULL,
75
+ `remote_servicing_place_id` int(11) unsigned NULL,
76
+
77
+ `name` varchar(255) NOT NULL,
78
+ `city` varchar(255) NULL,
79
+ `county` varchar(255) NULL,
80
+ `zip_code` varchar(255) NULL,
81
+ `country` varchar(2) NULL,
82
+ `description` text NULL,
83
+
84
+ `group_id` int(11) unsigned NULL,
85
+ `group_name` varchar(255) NULL,
86
+ `group_sort` int(11) unsigned NULL,
87
+
88
+ `local_carrier_id` int(11) unsigned NULL,
89
+
90
+ `created_time` datetime NULL,
91
+ `update_time` datetime NULL,
92
+ `cached_attributes` text NULL,
93
+
94
+ PRIMARY KEY (`id`)
95
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
96
+
97
+ ALTER TABLE {$this->getTable('eabi_postoffice')} ADD UNIQUE (
98
+ `remote_module_id`,
99
+ `remote_place_id`
100
+ );
101
+
102
+ CREATE TABLE {$this->getTable('eabi_carriermodule')} (
103
+ `id` int(11) unsigned NOT NULL auto_increment,
104
+ `carrier_code` varchar(255) NOT NULL,
105
+ `class_name` varchar(255) NOT NULL,
106
+ `update_time` datetime NULL,
107
+
108
+ PRIMARY KEY (`id`)
109
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
110
+
111
+
112
+
113
+ ");
114
+
115
+
116
+ $installer->endSetup();
app/code/community/Eabi/Postoffice/sql/eabi_postoffice_setup/mysql4-upgrade-0.1.0-0.1.1.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+ /*
38
+ * Add automatic data sending/packing slip printing feature to Magento Sales Order View by the help of Eabi_Livehandler
39
+ */
40
+ $installer->run("
41
+
42
+ INSERT INTO {$this->getTable('eabi_livehandler')}
43
+ (name, is_enabled, is_admin, request_var, model_class, store_id, website_id, created_time, update_time)
44
+ VALUES
45
+ ('Adminhtml Sales Order view Order Data Autosend feature', 1, 1, 'adminhtml/sales_order/view', 'eabi_postoffice/orderview', 0, 0, NOW(), NOW());
46
+
47
+
48
+ ");
49
+
50
+
51
+ $installer->endSetup();
app/code/community/Eabi/Postoffice/sql/eabi_postoffice_setup/mysql4-upgrade-0.1.1-0.1.2.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+
33
+ $installer = $this;
34
+
35
+ $installer->startSetup();
36
+
37
+ /*
38
+ * Fixes county/region names not displaying for certain regions on shipping address view
39
+ */
40
+ $installer->run("
41
+
42
+ INSERT INTO {$this->getTable('directory_country_region_name')}
43
+ SELECT 'en_US', r.region_id, r.default_name FROM {$this->getTable('directory_country_region')} r
44
+ WHERE r.region_id NOT IN (SELECT region_id FROM {$this->getTable('directory_country_region_name')});
45
+
46
+ ");
47
+
48
+
49
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/eabi_dpdee.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_sales_order_index>
4
+ <reference name="head">
5
+ <action method="addJs">
6
+ <script>eabi_js/eabi_dpdee.js</script>
7
+ </action>
8
+ <action method="addCss">
9
+ <name>eabi_dpdee.css</name>
10
+ </action>
11
+ </reference>
12
+ </adminhtml_sales_order_index>
13
+
14
+ </layout>
app/design/adminhtml/default/default/layout/eabi_postoffice.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+
35
+
36
+ <layout>
37
+ <adminhtml_sales_order_create_index>
38
+ <reference name="root">
39
+ <reference name="content">
40
+ <reference name="form">
41
+ <reference name="data">
42
+ <reference name="shipping_method">
43
+ <reference name="form">
44
+ <action method="setTemplate">
45
+ <template>eabi_postoffice/shipping_method_form.phtml</template>
46
+ </action>
47
+ </reference>
48
+ </reference>
49
+ </reference>
50
+ </reference>
51
+ </reference>
52
+ </reference>
53
+ </adminhtml_sales_order_create_index>
54
+
55
+ <adminhtml_sales_order_create_load_block_shipping_method>
56
+ <reference name="content">
57
+ <reference name="shipping_method">
58
+ <reference name="form">
59
+ <action method="setTemplate">
60
+ <template>eabi_postoffice/shipping_method_form.phtml</template>
61
+ </action>
62
+ </reference>
63
+ </reference>
64
+ </reference>
65
+ </adminhtml_sales_order_create_load_block_shipping_method>
66
+
67
+ <adminhtml_sales_order_create_load_block_data>
68
+ <reference name="content">
69
+ <reference name="data">
70
+ <reference name="shipping_method">
71
+ <reference name="form">
72
+ <action method="setTemplate">
73
+ <template>eabi_postoffice/shipping_method_form.phtml</template>
74
+ </action>
75
+ </reference>
76
+ </reference>
77
+ </reference>
78
+ </reference>
79
+ </adminhtml_sales_order_create_load_block_data>
80
+
81
+ </layout>
app/design/adminhtml/default/default/template/eabi_dpdee/order/courier.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @licence@
4
+ */
5
+ /* @var $this Eabi_DpdEE_Block_Order_Courier */
6
+ ?>
7
+ <div class="date_range">
8
+ <label for=""><?php echo $this->_getDpdHelper()->__('Pickup date'); ?>:</label><?php echo $this->getAvailableDates(); ?>
9
+ </div>
10
+ <div class="time_range">
11
+ <label for="Po_time"><?php echo $this->__('Pickup time');?>:</label><span id="eabidpdee_courier_times"></div>
12
+ </div>
13
+ <script type="text/javascript">
14
+ // <![CDATA[
15
+ window.updateDpdEeTimes = function(elem) {
16
+ var option = elem.options[elem.selectedIndex],
17
+ availableTimes = <?php echo $this->getAvailabeTimes(); ?>;
18
+
19
+ if (option.value && availableTimes[option.value]) {
20
+ $('eabidpdee_courier_times').update(availableTimes[option.value]);
21
+ }
22
+
23
+ };
24
+ window.updateDpdEeTimes($('Po_date'));
25
+ // ]]>
26
+ </script>
27
+ <div class="shipment_info">
28
+ <label for="Po_envelope_qty"><input type="text" name="Po_envelope_qty" id="Po_envelope_qty" value="<?php echo $this->getEnvelopeQty(); ?>"
29
+ class="validate-not-negative-number validate-digits"/><?php echo $this->__('Envelopes (≤ 0,5kg)'); ?></label>
30
+ <label for="Po_parcel_qty"><input type="text" name="Po_parcel_qty" id="Po_parcel_qty" value="<?php echo $this->getParcelQty(); ?>"
31
+ class="validate-not-negative-number validate-digits"/><?php echo $this->__('Parcels (≤ 31,5kg)'); ?></label>
32
+ <label for="Po_pallet_qty"><input type="text" name="Po_pallet_qty" id="Po_pallet_qty" value="<?php echo $this->getPalletQty(); ?>"
33
+ class="validate-not-negative-number validate-digits"/><?php echo $this->__('Pallets'); ?></label>
34
+ </div>
35
+ <div class="shipment_comment">
36
+ <textarea name="Po_remark" id="Po_remark" cols="40" rows="2" title="<?php echo $this->__('Comment to courier');?>"></textarea>
37
+ </div>
38
+ <input type="hidden" name="order_ids" id="eabi_dpdee_order_ids" value=""/>
app/design/adminhtml/default/default/template/eabi_postoffice/shipping_method_form.phtml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+ ?>
33
+ <?php /** @var $this Mage_Adminhtml_Block_Sales_Order_Create_Shipping_Method_Form */ ?>
34
+ <?php $_shippingRateGroups = $this->getShippingRates(); ?>
35
+ <?php if ($_shippingRateGroups): ?>
36
+ <div id="order-shipping-method-choose" style="display:none">
37
+ <dl class="shipment-methods">
38
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
39
+ <dt><strong><?php echo htmlspecialchars($this->getCarrierName($code)) ?></strong></dt>
40
+ <dd>
41
+ <ul>
42
+ <?php foreach ($_rates as $_rate): ?>
43
+ <?php $_radioProperty = 'name="order[shipping_method]" type="radio" onclick="order.setShippingMethod(this.value)"' ?>
44
+ <?php $_code=$_rate->getCode() ?>
45
+ <li>
46
+ <?php if ($_rate->getErrorMessage()): ?>
47
+ <ul class="messages">
48
+ <li class="error-msg"><?php echo htmlspecialchars($_rate->getErrorMessage()) ?></li>
49
+ </ul>
50
+ <?php else: ?>
51
+ <?php $_checked = $this->isMethodActive($_code) ? 'checked="checked"' : '' ?>
52
+ <input <?php echo $_radioProperty ?> value="<?php echo $_code ?>" id="s_method_<?php echo $_code ?>" <?php echo $_checked ?>/>
53
+ <label class="normal" for="s_method_<?php echo $_code ?>">
54
+ <?php echo ($_rate->getMethodTitle() ? $_rate->getMethodTitle() : $_rate->getMethodDescription()) ?> -
55
+ <strong>
56
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
57
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
58
+
59
+ <?php echo $_excl; ?>
60
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
61
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
62
+ <?php endif; ?>
63
+ </strong>
64
+ </label>
65
+ <?php endif ?>
66
+ </li>
67
+ <?php endforeach; ?>
68
+ </ul>
69
+ </dd>
70
+ <?php endforeach; ?>
71
+ </dl>
72
+ </div>
73
+ <?php if ($_rate = $this->getActiveMethodRate()): ?>
74
+ <div id="order-shipping-method-info">
75
+ <strong><?php echo htmlspecialchars($this->getCarrierName($_rate->getCarrier())) ?></strong><br/>
76
+ <?php echo htmlspecialchars($_rate->getMethodTitle() ? $_rate->getMethodTitle() : $_rate->getMethodDescription()) ?> -
77
+ <strong>
78
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
79
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
80
+
81
+ <?php echo $_excl; ?>
82
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
83
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
84
+ <?php endif; ?>
85
+ </strong>
86
+ <!--input type="text" class="input-text" style="width:70px"/-->
87
+ <br/>
88
+ <a href="#" onclick="$('order-shipping-method-info').hide();$('order-shipping-method-choose').show();return false">
89
+ <?php echo Mage::helper('sales')->__('Click to change shipping method') ?>
90
+ </a>
91
+ </div>
92
+ <?php else: ?>
93
+ <script type="text/javascript">$('order-shipping-method-choose').show();</script>
94
+ <?php endif; ?>
95
+ <?php elseif($this->getIsRateRequest()): ?>
96
+ <strong><?php echo Mage::helper('sales')->__('Sorry, no quotes are available for this order at this time.') ?></strong>
97
+ <?php else: ?>
98
+ <div id="order-shipping-method-summary">
99
+ <a href="#" onclick="order.loadShippingRates();return false">
100
+ <?php echo Mage::helper('sales')->__('Get shipping methods and rates') ?>
101
+ </a>
102
+ <input type="hidden" name="order[has_shipping]" value="" class="required-entry" />
103
+ </div>
104
+ <?php endif; ?>
105
+ <div style="display:none;" id="shipping-method-overlay" class="overlay"><span><?php echo $this->__('Shipping method selection is not applicable') ?></span></div>
106
+ <script type="text/javascript">
107
+ order.overlay('shipping-method-overlay', <?php if ($this->getQuote()->isVirtual()): ?>false<?php else: ?>true<?php endif; ?>);
108
+ order.overlay('address-shipping-overlay', <?php if ($this->getQuote()->isVirtual()): ?>false<?php else: ?>true<?php endif; ?>);
109
+ </script>
app/design/frontend/base/default/layout/eabi_dpdee.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ </layout>
app/design/frontend/base/default/layout/eabi_postoffice.xml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+
35
+
36
+ <layout>
37
+ <checkout_onepage_shippingmethod>
38
+ <reference name="root">
39
+ <action method="setTemplate">
40
+ <template>eabi_postoffice/available.phtml</template>
41
+ </action>
42
+
43
+ </reference>
44
+ </checkout_onepage_shippingmethod>
45
+ <checkout_cart_index>
46
+ <reference name="content">
47
+ <reference name="checkout.cart">
48
+ <reference name="checkout.cart.shipping">
49
+ <action method="setTemplate">
50
+ <template>eabi_postoffice/shipping.phtml</template>
51
+ </action>
52
+
53
+ </reference>
54
+ </reference>
55
+
56
+ </reference>
57
+ </checkout_cart_index>
58
+ <checkout_multishipping_shipping>
59
+ <reference name="content">
60
+ <reference name="checkout_shipping">
61
+ <action method="setTemplate">
62
+ <template>eabi_postoffice/multishipping.phtml</template>
63
+ </action>
64
+ </reference>
65
+ </reference>
66
+ </checkout_multishipping_shipping>
67
+ <shipping_tracking_popup>
68
+ <reference name="content">
69
+ <reference name="shipping.tracking.popup">
70
+ <action method="setTemplate">
71
+ <template>eabi_postoffice/tracking/popup.phtml</template>
72
+ </action>
73
+ </reference>
74
+ </reference>
75
+
76
+ </shipping_tracking_popup>
77
+
78
+
79
+ </layout>
app/design/frontend/base/default/template/eabi_postoffice/available.phtml ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+ ?>
33
+ <?php /** @var $this Mage_Checkout_Block_Onepage_Shipping_Method_Available */ ?>
34
+ <?php $_shippingRateGroups = $this->getShippingRates(); ?>
35
+ <?php if (!$_shippingRateGroups): ?>
36
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
37
+ <?php else: ?>
38
+ <dl class="sp-methods">
39
+ <?php $shippingCodePrice = array(); ?>
40
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
41
+ <dt><?php echo htmlspecialchars($this->getCarrierName($code)) ?></dt>
42
+ <dd>
43
+ <ul>
44
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
45
+ <?php $shippingCodePrice[] = "'".$_rate->getCode()."':".(float)$_rate->getPrice(); ?>
46
+ <li>
47
+ <?php if ($_rate->getErrorMessage()): ?>
48
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo htmlspecialchars($_rate->getErrorMessage()) ?></li></ul></li></ul>
49
+ <?php else: ?>
50
+ <?php if ($_sole) : ?>
51
+ <span class="no-display"><input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" /></span>
52
+ <?php else: ?>
53
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio"/>
54
+
55
+ <?php if ($_rate->getCode() === $this->getAddressShippingMethod()): ?>
56
+ <script type="text/javascript">
57
+ //<![CDATA[
58
+ lastPrice = <?php echo (float)$_rate->getPrice(); ?>;
59
+ //]]>
60
+ </script>
61
+ <?php endif; ?>
62
+
63
+ <?php endif; ?>
64
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo ($_rate->getMethodTitle()) ?>
65
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
66
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
67
+ <?php echo $_excl; ?>
68
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
69
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
70
+ <?php endif; ?>
71
+ </label>
72
+ <?php endif ?>
73
+ </li>
74
+ <?php endforeach; ?>
75
+ </ul>
76
+ </dd>
77
+ <?php endforeach; ?>
78
+ </dl>
79
+ <script type="text/javascript">
80
+ //<![CDATA[
81
+ <?php if (!empty($shippingCodePrice)): ?>
82
+ var shippingCodePrice = {<?php echo implode(',',$shippingCodePrice); ?>};
83
+ <?php endif; ?>
84
+
85
+ $$('input[type="radio"][name="shipping_method"]').each(function(el){
86
+ Event.observe(el, 'click', function(){
87
+ if (el.checked == true) {
88
+ var getShippingCode = el.getValue();
89
+ <?php if (!empty($shippingCodePrice)): ?>
90
+ var newPrice = shippingCodePrice[getShippingCode];
91
+ if (!lastPrice) {
92
+ lastPrice = newPrice;
93
+ quoteBaseGrandTotal += newPrice;
94
+ }
95
+ if (newPrice != lastPrice) {
96
+ quoteBaseGrandTotal += (newPrice-lastPrice);
97
+ lastPrice = newPrice;
98
+ }
99
+ <?php endif; ?>
100
+ checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
101
+ return false;
102
+ }
103
+ });
104
+ });
105
+ //]]>
106
+ </script>
107
+ <?php endif; ?>
app/design/frontend/base/default/template/eabi_postoffice/multishipping.phtml ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+ ?>
33
+ <?php
34
+ /**
35
+ * Multishipping checkout shipping template
36
+ *
37
+ * @see Mage_Checkout_Block_Multishipping_Shipping
38
+ * @var $this Mage_Checkout_Block_Multishipping_Shipping
39
+ */
40
+ ?>
41
+ <div class="multiple-checkout">
42
+ <div class="page-title">
43
+ <h1><?php echo $this->__('Select Shipping Method') ?></h1>
44
+ </div>
45
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
46
+ <form action="<?php echo $this->getPostActionUrl() ?>" method="post" id="shipping_method_form">
47
+ <?php foreach ($this->getAddresses() as $_index => $_address): ?>
48
+ <div class="col2-set">
49
+ <h2 class="legend"><?php echo $this->__('Address %s of %s', ($_index+1), $this->getAddressCount()) ?></h2>
50
+ <div class="col-1 col-narrow">
51
+ <div class="box">
52
+ <div class="box-title">
53
+ <h3><?php echo $this->__('Shipping To') ?> <span class="separator">|</span> <a href="<?php echo $this->getAddressEditUrl($_address) ?>"><?php echo $this->__('Change') ?></a></h3>
54
+ </div>
55
+ <div class="box-content">
56
+ <address><?php echo $_address->format('html') ?></address>
57
+ </div>
58
+ </div>
59
+ <div class="box box-sp-methods">
60
+ <div class="pointer"></div>
61
+ <div class="box-title">
62
+ <h3><?php echo $this->__('Shipping Method') ?></h3>
63
+ </div>
64
+ <div class="box-content">
65
+ <?php if (!($_shippingRateGroups = $this->getShippingRates($_address))): ?>
66
+ <p><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></p>
67
+ <?php else: ?>
68
+ <dl class="sp-methods">
69
+ <?php $_sole = count($_shippingRateGroups) == 1; foreach ($_shippingRateGroups as $code => $_rates): ?>
70
+ <dt><?php echo htmlspecialchars($this->getCarrierName($code)) ?></dt>
71
+ <dd>
72
+ <ul>
73
+ <?php $_sole = $_sole && count($_rates) == 1; foreach ($_rates as $_rate): ?>
74
+ <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"' ?>>
75
+ <?php if ($_rate->getErrorMessage()): ?>
76
+ <?php echo htmlspecialchars($_rate->getCarrierTitle()) ?>: <?php echo htmlspecialchars($_rate->getErrorMessage()) ?>
77
+ <?php else: ?>
78
+ <?php if ($_sole) : ?>
79
+ <span class="no-display"><input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $this->htmlEscape($_rate->getCode()) ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>" checked="checked"/></span>
80
+ <?php else: ?>
81
+ <input type="radio" name="shipping_method[<?php echo $_address->getId() ?>]" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod($_address)) echo ' checked="checked"' ?> class="radio" />
82
+ <?php endif; ?>
83
+ <label for="s_method_<?php echo $_address->getId() ?>_<?php echo $_rate->getCode() ?>"><?php echo ($_rate->getMethodTitle()) ?>
84
+ <?php $_excl = $this->getShippingPrice($_address, $_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
85
+ <?php $_incl = $this->getShippingPrice($_address, $_rate->getPrice(), true); ?>
86
+ <?php echo $_excl; ?>
87
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
88
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
89
+ <?php endif; ?>
90
+ </label>
91
+ <?php endif ?>
92
+ </li>
93
+ <?php endforeach; ?>
94
+ </ul>
95
+ </dd>
96
+ <?php endforeach; ?>
97
+ </dl>
98
+ <?php endif; ?>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ <div class="col-2 col-wide">
103
+ <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress_checkbox', $_address); ?>
104
+ <h3><?php echo $this->__('Items') ?> <span class="separator">|</span> <a href="<?php echo $this->getItemsEditUrl($_address) ?>"><?php echo $this->__('Edit Items') ?></a></h3>
105
+ <table class="data-table" id="shipping-table-<?php echo $_address->getId() ?>">
106
+ <col />
107
+ <col width="1" />
108
+ <thead>
109
+ <tr>
110
+ <th><?php echo $this->__('Product Name') ?></th>
111
+ <th class="a-center"><?php echo $this->__('Qty') ?></th>
112
+ </tr>
113
+ </thead>
114
+ <tbody>
115
+ <?php foreach ($this->getAddressItems($_address) as $_item): ?>
116
+ <tr>
117
+ <td>
118
+ <?php echo $this->getItemHtml($_item->getQuoteItem()) ?>
119
+ </td>
120
+ <td class="a-center"><?php echo $_item->getQty() ?></td>
121
+ </tr>
122
+ <?php endforeach; ?>
123
+ </tbody>
124
+ </table>
125
+ <script type="text/javascript">decorateTable('shipping-table-<?php echo $_address->getId() ?>')</script>
126
+ <?php echo $this->helper('giftmessage/message')->getInline('multishipping_adress', $_address); ?>
127
+ </div>
128
+ </div>
129
+ <?php endforeach; ?>
130
+ <?php echo $this->getChildHtml('checkout_billing_items') ?>
131
+ <div class="buttons-set">
132
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back to Select Addresses') ?></a></p>
133
+ <button type="submit" title="<?php echo $this->__('Continue to Billing Information') ?>" class="button"><span><span><?php echo $this->__('Continue to Billing Information') ?></span></span></button>
134
+ </div>
135
+ </form>
136
+ </div>
app/design/frontend/base/default/template/eabi_postoffice/shipping.phtml ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+ ?>
33
+ <?php /** @var $this Mage_Checkout_Block_Cart_Shipping */ ?>
34
+ <div class="shipping">
35
+ <h2><?php echo $this->__('Estimate Shipping and Tax') ?></h2>
36
+ <div class="shipping-form">
37
+ <form action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>" method="post" id="shipping-zip-form">
38
+ <p><?php echo $this->__('Enter your destination to get a shipping estimate.') ?></p>
39
+ <ul class="form-list">
40
+ <li>
41
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
42
+ <div class="input-box">
43
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getEstimateCountryId()) ?>
44
+ </div>
45
+ </li>
46
+ <?php //if($this->getStateActive()): ?>
47
+ <li>
48
+ <label for="region_id"<?php if ($this->isStateProvinceRequired()) echo ' class="required"' ?>><?php if ($this->isStateProvinceRequired()) echo '<em>*</em>' ?><?php echo $this->__('State/Province') ?></label>
49
+ <div class="input-box">
50
+ <select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" style="display:none;"<?php echo ($this->isStateProvinceRequired() ? ' class="validate-select"' : '') ?>>
51
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
52
+ </select>
53
+ <script type="text/javascript">
54
+ //<![CDATA[
55
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getEstimateRegionId() ?>");
56
+ //]]>
57
+ </script>
58
+ <input type="text" id="region" name="region" value="<?php echo htmlspecialchars($this->getEstimateRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
59
+ </div>
60
+ </li>
61
+ <?php //endif; ?>
62
+ <?php if($this->getCityActive()): ?>
63
+ <li>
64
+ <label for="city"<?php if ($this->isCityRequired()) echo ' class="required"' ?>><?php if ($this->isCityRequired()) echo '<em>*</em>' ?><?php echo $this->__('City') ?></label>
65
+ <div class="input-box">
66
+ <input class="input-text<?php if ($this->isCityRequired()):?> required-entry<?php endif;?>" id="city" type="text" name="estimate_city" value="<?php echo htmlspecialchars($this->getEstimateCity()) ?>" />
67
+ </div>
68
+ </li>
69
+ <?php endif; ?>
70
+ <li>
71
+ <label for="postcode"<?php if ($this->isZipCodeRequired()) echo ' class="required"' ?>><?php if ($this->isZipCodeRequired()) echo '<em>*</em>' ?><?php echo $this->__('Zip/Postal Code') ?></label>
72
+ <div class="input-box">
73
+ <input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()):?> required-entry<?php endif;?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo htmlspecialchars($this->getEstimatePostcode()) ?>" />
74
+ </div>
75
+ </li>
76
+ </ul>
77
+ <div class="buttons-set">
78
+ <button type="button" title="<?php echo $this->__('Get a Quote') ?>" onclick="coShippingMethodForm.submit()" class="button"><span><span><?php echo $this->__('Get a Quote') ?></span></span></button>
79
+ </div>
80
+ </form>
81
+ <script type="text/javascript">
82
+ //<![CDATA[
83
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
84
+ //]]>
85
+ </script>
86
+
87
+ <?php if (($_shippingRateGroups = $this->getEstimateRates())): ?>
88
+ <form id="co-shipping-method-form" action="<?php echo $this->getUrl('checkout/cart/estimateUpdatePost') ?>">
89
+ <dl class="sp-methods">
90
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
91
+ <dt><?php echo ($this->getCarrierName($code)) ?></dt>
92
+ <dd>
93
+ <ul>
94
+ <?php foreach ($_rates as $_rate): ?>
95
+ <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"';?>>
96
+ <?php if ($_rate->getErrorMessage()): ?>
97
+ <?php echo htmlspecialchars($_rate->getErrorMessage()) ?>
98
+ <?php else: ?>
99
+ <input name="estimate_method" type="radio" value="<?php echo htmlspecialchars($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if($_rate->getCode()===$this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
100
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo ($_rate->getMethodTitle()) ?>
101
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
102
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
103
+ <?php echo $_excl; ?>
104
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
105
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
106
+ <?php endif; ?>
107
+ </label>
108
+ <?php endif ?>
109
+ </li>
110
+ <?php endforeach; ?>
111
+ </ul>
112
+ </dd>
113
+ <?php endforeach; ?>
114
+ </dl>
115
+ <div class="buttons-set">
116
+ <button type="submit" title="<?php echo $this->__('Update Total') ?>" class="button" name="do" value="<?php echo $this->__('Update Total') ?>"><span><span><?php echo $this->__('Update Total') ?></span></span></button>
117
+ </div>
118
+ </form>
119
+ <?php endif; ?>
120
+ <script type="text/javascript">
121
+ //<![CDATA[
122
+ var coShippingMethodForm = new VarienForm('shipping-zip-form');
123
+ var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;
124
+
125
+ coShippingMethodForm.submit = function () {
126
+ var country = $F('country');
127
+ var optionalZip = false;
128
+
129
+ for (i=0; i < countriesWithOptionalZip.length; i++) {
130
+ if (countriesWithOptionalZip[i] == country) {
131
+ optionalZip = true;
132
+ }
133
+ }
134
+ if (optionalZip) {
135
+ $('postcode').removeClassName('required-entry');
136
+ }
137
+ else {
138
+ $('postcode').addClassName('required-entry');
139
+ }
140
+ return VarienForm.prototype.submit.bind(coShippingMethodForm)();
141
+ }
142
+ //]]>
143
+ </script>
144
+ </div>
145
+ </div>
app/design/frontend/base/default/template/eabi_postoffice/tracking/popup.phtml ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * or OpenGPL v3 license (GNU Public License V3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * or
13
+ * http://www.gnu.org/licenses/gpl-3.0.txt
14
+ * If you did not receive a copy of the license and are unable to
15
+ * obtain it through the world-wide-web, please send an email
16
+ * to info@e-abi.ee so we can send you a copy immediately.
17
+ *
18
+ * DISCLAIMER
19
+ *
20
+ * Do not edit or add to this file if you wish to upgrade this module to newer
21
+ * versions in the future.
22
+ *
23
+ * @category Eabi
24
+ * @package Eabi_Dpd
25
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
28
+ * @author Matis Halmann
29
+ *
30
+
31
+ */
32
+ ?><?php /** @var $this Mage_Shipping_Block_Tracking_Popup */ ?>
33
+ <?php $_results = $this->getTrackingInfo(); ?>
34
+ <div class="page-title title-buttons">
35
+ <h1><?php echo $this->__('Tracking Information'); ?></h1>
36
+ <button class="button" onclick="window.close(); window.opener.focus();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
37
+ </div>
38
+ <?php if(sizeof($_results)>0): ?>
39
+ <?php foreach($_results as $shipid => $_result): ?>
40
+ <?php if($shipid): ?>
41
+ <h2 class="sub-title"><?php echo $this->__('Shipment #').$shipid; ?></h2>
42
+ <?php endif; ?>
43
+ <?php if(sizeof($_result)>0): ?>
44
+ <?php $rowCount = sizeof($_result); $counter = 1; ?>
45
+ <?php $_id = 0; foreach($_result as $track): ?>
46
+ <table class="tracking-table-popup data-table" id="tracking-table-popup-<?php echo $_id ?>">
47
+ <col width="15%" />
48
+ <col />
49
+ <tbody>
50
+ <?php if(is_object($track)): ?>
51
+ <tr>
52
+ <th class="label"><?php echo $this->__('Tracking Number:'); ?></th>
53
+ <td class="value"><?php echo ($track->getTracking()); ?></td>
54
+ </tr>
55
+ <?php if ($track->getCarrierTitle()): ?>
56
+ <tr>
57
+ <th class="label"><?php echo $this->__('Carrier:'); ?></th>
58
+ <td class="value"><?php echo $this->escapeHtml($track->getCarrierTitle()); ?></td>
59
+ </tr>
60
+ <?php endif; ?>
61
+ <?php if($track->getErrorMessage()): ?>
62
+ <tr>
63
+ <th class="label"><?php echo $this->__('Error:'); ?></th>
64
+ <td class="error"><?php echo $this->__('Tracking information is currently not available. Please '); if ($this->getContactUsEnabled()) : ?><a href="<?php echo $this->getContactUs() ?>" title="<?php echo $this->__('contact us') ?>" onclick="this.target='_blank'"><?php echo $this->__('contact us') ?></a><?php echo $this->__(' for more information or '); endif; echo $this->__('email us at '); ?><a href="mailto:<?php echo $this->getStoreSupportEmail() ?>"><?php echo $this->getStoreSupportEmail() ?></a></td>
65
+ </tr>
66
+ <?php elseif($track->getTrackSummary()): ?>
67
+ <tr>
68
+ <th class="label"><?php echo $this->__('Info:'); ?></th>
69
+ <td class="value"><?php echo $track->getTrackSummary(); ?></td>
70
+ </tr>
71
+ <?php elseif($track->getUrl()): ?>
72
+ <tr>
73
+ <th class="label"><?php echo $this->__('Track:'); ?></th>
74
+ <td class="value"><a href="<?php echo $this->escapeHtml($track->getUrl()); ?>" onclick="this.target='_blank'"><?php echo $this->escapeHtml($track->getUrl()); ?></a></td>
75
+ </tr>
76
+ <?php else: ?>
77
+ <?php if ($track->getStatus()): ?>
78
+ <tr>
79
+ <th class="label"><?php echo $this->__('Status:'); ?></th>
80
+ <td class="value"><?php echo $track->getStatus(); ?></td>
81
+ </tr>
82
+ <?php endif; ?>
83
+
84
+ <?php if ($track->getDeliverydate()): ?>
85
+ <tr>
86
+ <th class="label"><?php echo $this->__('Delivered on:'); ?></th>
87
+ <td class="value"><?php echo $this->formatDeliveryDateTime($track->getDeliverydate(),$track->getDeliverytime()); ?></td>
88
+ </tr>
89
+ <?php endif; ?>
90
+
91
+ <?php if ($track->getSignedby()): ?>
92
+ <tr>
93
+ <th class="label"><?php echo $this->__('Signed by:'); ?></th>
94
+ <td class="value"><?php echo $track->getSignedby(); ?></td>
95
+ </tr>
96
+ <?php endif; ?>
97
+
98
+ <?php if ($track->getDeliveryLocation()): ?>
99
+ <tr>
100
+ <th class="label"><?php echo $this->__('Delivered to:'); ?></th>
101
+ <td class="value"><?php echo $track->getDeliveryLocation(); ?></td>
102
+ </tr>
103
+ <?php endif; ?>
104
+
105
+ <?php if ($track->getShippedDate()): ?>
106
+ <tr>
107
+ <th class="label"><?php echo $this->__('Shipped or billed on:'); ?></th>
108
+ <td class="value"><?php echo $track->getShippedDate(); ?></td>
109
+ </tr>
110
+ <?php endif; ?>
111
+
112
+ <?php if ($track->getService()): ?>
113
+ <tr>
114
+ <th class="label"><?php echo $this->__('Service Type:'); ?></th>
115
+ <td class="value"><?php echo $track->getService(); ?></td>
116
+ </tr>
117
+ <?php endif; ?>
118
+
119
+ <?php if ($track->getWeight()): ?>
120
+ <tr>
121
+ <th class="label"><?php echo $this->__('Weight:'); ?></th>
122
+ <td class="value"><?php echo $track->getWeight(); ?></td>
123
+ </tr>
124
+ <?php endif; ?>
125
+ <?php endif; ?>
126
+ <?php elseif(isset($track['title']) && isset($track['number']) && $track['number']): ?>
127
+ <!--if the tracking is custom value-->
128
+ <tr>
129
+ <th class="label"><?php echo ($track['title'] ? $this->escapeHtml($track['title']) : $this->__('N/A')); ?>:</th>
130
+ <td class="value"><?php echo (isset($track['number']) ? $this->escapeHtml($track['number']) : ''); ?></td>
131
+ </tr>
132
+ <?php endif; ?>
133
+ </tbody>
134
+ </table>
135
+ <script type="text/javascript">decorateTable('tracking-table-popup-<?php echo $_id++ ?>');</script>
136
+ <?php if (is_object($track) && sizeof($track->getProgressdetail())>0): ?>
137
+ <br />
138
+ <table class="data-table" id="track-history-table-<?php echo $track->getTracking(); ?>">
139
+ <col />
140
+ <col width="1" />
141
+ <col width="1" />
142
+ <col />
143
+ <thead>
144
+ <tr>
145
+ <th><?php echo $this->__('Location') ?></th>
146
+ <th><?php echo $this->__('Date') ?></th>
147
+ <th><?php echo $this->__('Local Time') ?></th>
148
+ <th><?php echo $this->__('Description') ?></th>
149
+ </tr>
150
+ </thead>
151
+ <tbody>
152
+ <?php foreach($track->getProgressdetail() as $_detail): ?>
153
+ <?php $_detailDate = (isset($_detail['deliverydate']) ? $this->formatDeliveryDate($_detail['deliverydate']) : '') ?>
154
+ <?php $_detailTime = (isset($_detail['deliverytime']) ? $this->formatDeliveryTime($_detail['deliverytime'], $_detail['deliverydate']) : '') ?>
155
+ <tr>
156
+ <td><?php echo (isset($_detail['deliverylocation']) ? $_detail['deliverylocation'] : ''); ?></td>
157
+ <td><span class="nobr"><?php echo $_detailDate ?></span></td>
158
+ <td><span class="nobr"><?php echo $_detailTime ?></span></td>
159
+ <td><?php echo (isset($_detail['activity']) ? $_detail['activity'] : '') ?></td>
160
+ </tr>
161
+ <?php endforeach; ?>
162
+ </tbody>
163
+ </table>
164
+ <script type="text/javascript">decorateTable('track-history-table-<?php echo $track->getTracking(); ?>');</script>
165
+ <?php endif; ?>
166
+ <div class="divider"></div>
167
+ <?php if($counter!=$rowCount): ?>
168
+ <?php endif; ?>
169
+ <?php $counter++; ?>
170
+ <!--end for each tracking information-->
171
+ <?php endforeach; ?>
172
+ <?php else: ?>
173
+ <p><?php echo $this->__('There is no tracking available for this shipment.'); ?></p>
174
+ <?php endif; ?>
175
+
176
+ <?php endforeach; ?>
177
+ <?php else: ?>
178
+ <p><?php echo $this->__('There is no tracking available.'); ?></p>
179
+ <?php endif; ?>
180
+ <div class="buttons-set">
181
+ <button type="button" title="<?php echo $this->__('Close Window') ?>" class="button" onclick="window.close(); window.opener.focus();"><span><span><?php echo $this->__('Close Window') ?></span></span></button>
182
+ </div>
183
+
app/etc/modules/Eabi_DpdEE.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+ <config>
35
+ <modules>
36
+ <Eabi_DpdEE>
37
+ <active>true</active>
38
+ <codePool>community</codePool>
39
+ <depends>
40
+ <Eabi_Postoffice />
41
+ </depends>
42
+ <version>0.1.5</version>
43
+ </Eabi_DpdEE>
44
+ </modules>
45
+ </config>
app/etc/modules/Eabi_Postoffice.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /*
4
+
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * or OpenGPL v3 license (GNU Public License V3.0)
10
+ * that is bundled with this package in the file LICENSE.txt.
11
+ * It is also available through the world-wide-web at this URL:
12
+ * http://opensource.org/licenses/osl-3.0.php
13
+ * or
14
+ * http://www.gnu.org/licenses/gpl-3.0.txt
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to info@e-abi.ee so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade this module to newer
22
+ * versions in the future.
23
+ *
24
+ * @category Eabi
25
+ * @package Eabi_Dpd
26
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
27
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
29
+ * @author Matis Halmann
30
+ *
31
+
32
+ */
33
+ -->
34
+
35
+
36
+ <config>
37
+ <modules>
38
+ <Eabi_Postoffice>
39
+ <active>true</active>
40
+ <codePool>community</codePool>
41
+ <depends>
42
+ <Mage_Shipping />
43
+ <Eabi_Livehandler />
44
+ </depends>
45
+ <version>0.1.2</version>
46
+ </Eabi_Postoffice>
47
+ </modules>
48
+ </config>
app/locale/en_US/Eabi_DpdEE.csv ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "I have packing slips","I have packing slips"
2
+ "Envelopes (≤ 0,5kg)","Envelopes (≤ 0,5kg)"
3
+ "Parcels (≤ 31,5kg)","Parcels (≤ 31,5kg)"
4
+ "Pallets","Pallets"
5
+ "Pickup date","Pickup date"
6
+ "Pickup time","Pickup time"
7
+ " - select pickup date - "," - select pickup date - "
8
+ "Select pickup date first","Select pickup date first"
9
+ "Courier cannot be called for orders %s","Courier cannot be called for orders %s"
10
+ "Cannot call courier.","Cannot call courier."
11
+ "Country","Country"
12
+ "Base shipping price","Base shipping price"
13
+ "Price per additional 10kg over base 10kg","Price per additional 10kg over base 10kg"
14
+ "Free shipping from price","Free shipping from price"
15
+ "Add shipping country","Add shipping country"
16
+ "Comment to courier","Comment to courier"
17
+ "Courier comes to pick up your shipment on %1$s between %2$s","Courier comes to pick up your shipment on %1$s between %2$s"
18
+ "and","and"
19
+ "DPD - Pakivedu.ee - Pakipood","DPD - Pakivedu.ee - Pakipood"
20
+ "Price per country","Price per country"
21
+ "If country is not listed here, but this method is available, then general handling fee is applied","If country is not listed here, but this method is available, then general handling fee is applied"
22
+ "Disable this carrier if product's short description contains HTML comment &lt;!-- no dpd_ee_module --&gt;","Disable this carrier if product's short description contains HTML comment &lt;!-- no dpd_ee_module --&gt;"
23
+ "Auto send data to DPD server","Auto send data to DPD server"
24
+ "Allow courier pickup","Allow courier pickup"
25
+ "DPD Self service username","DPD Self service username"
26
+ "DPD Self-service password","DPD Self-service password"
27
+ "When to send parcel data","When to send parcel data"
28
+ "Pickup address name","Pickup address name"
29
+ "Pickup address company","Pickup address company"
30
+ "Pickup address e-mail","Pickup address e-mail"
31
+ "Pickup address phone","Pickup address phone"
32
+ "Pickup address street","Pickup address street"
33
+ "Pickup address city, county","Pickup address city, county"
34
+ "Pickup address zip code","Pickup address zip code"
35
+ "Pickup address country","Pickup address country"
36
+ "Show pickup address on packing label","Show pickup address on packing label"
37
+ "Save address for current customer","Save address for current customer"
38
+ "Labels position on packing slip","Labels position on packing slip"
39
+ "Api URL","Api URL"
40
+ "DPD - Pakivedu.ee - Courier service","DPD - Pakivedu.ee - Courier service"
41
+ "Position: %s","Position: %s"
42
+ "Order courier to pick up goods","Order courier to pick up goods"
43
+ "Tomorrow","Tomorrow"
44
+ "Today","Today"
45
+ "Http request timeout","Http request timeout"
46
+ "If timeout is greater than 10 seconds, then parcel data can only be sent manually. This field with the limitation will be removed latest 17th of February","If timeout is greater than 10 seconds, then parcel data can only be sent manually. This field with the limitation will be removed latest 17th of February"
47
+
app/locale/en_US/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Rebuild successful"
2
+ "Rebuild postoffices for this carrier","Rebuild postoffices for this carrier"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Rebuilding postoffices for the carrier %s takes a little while... Continue?"
4
+ "Automatic data sending not applicable","Automatic data sending not applicable"
5
+ "Loading offices...","Loading offices..."
6
+ "After successful checkout","After successful checkout"
7
+ "After successful shipment creation","After successful shipment creation"
8
+ "-- select --","-- select --"
9
+ "I will send data myself by clicking on the button","I will send data myself by clicking on the button"
10
+ "Print packing slip","Print packing slip"
11
+ "Send shipping data to server","Send shipping data to server"
12
+ "Data sent to server, please verify the status from the order comments","Data sent to server, please verify the status from the order comments"
13
+ "Disable populating list of last selected parcel terminals","Disable populating list of last selected parcel terminals"
14
+ "Show customer one dropdown instead of two","Show customer one dropdown instead of two"
15
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city."
16
+ "Enable Cash on Delivery (requires extra plugin)","Enable Cash on Delivery (requires extra plugin)"
17
+ "Extra fee, when using Cash on delivery","Extra fee, when using Cash on delivery"
18
+ "Enabled","Enabled"
19
+ "Title","Title"
20
+ "Price","Price"
21
+ "Maximum allowed package weight for this carrier","Maximum allowed package weight for this carrier"
22
+ "Handling action","Handling action"
23
+ "Enable free shipping","Enable free shipping"
24
+ "Free shipping subtotal","Free shipping subtotal"
25
+ "Show method if not applicable","Show method if not applicable"
26
+ "Error message displayed to the user","Error message displayed to the user"
27
+ "Ship to applicable countries","Ship to applicable countries"
28
+ "Ship to Specific countries","Ship to Specific countries"
29
+ "Width in pixels for city select menu","Width in pixels for city select menu"
30
+ "Width in pixels for office select menu","Width in pixels for office select menu"
31
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
32
+ "Rebuild Postoffice List","Rebuild Postoffice List"
33
+ "Sort order","Sort order"
34
+ "Show short office names","Show short office names"
35
+ "Sort offices by priority","Sort offices by priority"
36
+ "Auto send data to server","Auto send data to server"
37
+ "Only if the order has been paid for or the order is COD","Only if the order has been paid for or the order is COD"
38
+ "Yes: Shows only office name<br/>No: Shows office name and address","Yes: Shows only office name<br/>No: Shows office name and address"
39
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
40
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
41
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
42
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
app/locale/et_EE/Eabi_DpdEE.csv ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "I have packing slips","Mul on pakikaardid olemas"
2
+ "Envelopes (≤ 0,5kg)","Ümbrikku (≤ 0,5kg)"
3
+ "Parcels (≤ 31,5kg)","Pakki (≤ 31,5kg)"
4
+ "Pallets","Alust"
5
+ "Pickup date","Pealekorje kuupäev"
6
+ "Pickup time","Pealekorje ajavahemik"
7
+ " - select pickup date - "," - vali pealekorje kuupäev - "
8
+ "Select pickup date first","Vali kuupäev ..."
9
+ "Courier cannot be called for orders %s","Kullerit ei saa kutsuda tellimustele: %s"
10
+ "Cannot call courier.","Kulleri kutsumisega tekkis tõrge."
11
+ "Country","Riik"
12
+ "Base shipping price","Baastarnehind"
13
+ "Price per additional 10kg over base 10kg","Lisahind iga 10kg mis ületab paki 10kg kaalu"
14
+ "Free shipping from price","Tasuta tarne alates summast"
15
+ "Add shipping country","Lisa tarneriik"
16
+ "Comment to courier","Märkus kullerile"
17
+ "Courier comes to pick up your shipment on %1$s between %2$s","Kuller tuleb saadetisele järgi kuupäeval %1$s, kella %2$s vahel"
18
+ "and","ja"
19
+ "DPD - Pakivedu.ee - Pakipood","DPD - Pakivedu.ee - Pakipood"
20
+ "Price per country","Tarne hind riigiti"
21
+ "If country is not listed here, but this method is available, then general handling fee is applied","Kui riiki pole nimekirjas kuid käesolev tarne on saadaval - kasutatakse üldist tarnehinda"
22
+ "Disable this carrier if product's short description contains HTML comment &lt;!-- no dpd_ee_module --&gt;","Keela käesolev tarneviis kui toote lühikirjeldus sisaldab HTML kommentaari: &lt;!-- no dpd_ee_module --&gt;"
23
+ "Auto send data to DPD server","Luba andmete saatmine DPD serverisse"
24
+ "Allow courier pickup","Luba kulleri järelekutsumine saadetisele"
25
+ "DPD Self service username","DPD teenuse kasutajanimi"
26
+ "DPD Self-service password","DPD teenuse salasõna"
27
+ "When to send parcel data","Paki andmete saatmise hetk"
28
+ "Pickup address name","Nimi pealekorje aadressil"
29
+ "Pickup address company","Firma pealekorje aadressil"
30
+ "Pickup address e-mail","E-post pealekorje aadressil"
31
+ "Pickup address phone","Telefon pealekorje aadressil"
32
+ "Pickup address street","Tänav pealekorje aadressil"
33
+ "Pickup address city, county","Linn, maakond pealekorje aadressil"
34
+ "Pickup address zip code","Postiindeks pealekorje aadressil"
35
+ "Pickup address country","Riik pealekorje aadressil"
36
+ "Show pickup address on packing label","Näita pealekorje aadressi pakisildil"
37
+ "Save address for current customer","Salvesta tarneaadress kliendi kohta"
38
+ "Labels position on packing slip","Pakisiltide asend"
39
+ "Api URL","Api URL"
40
+ "DPD - Pakivedu.ee - Courier service","DPD - Pakivedu.ee - Pakiveoteenus"
41
+ "Position: %s","Positsioon: %s"
42
+ "Order courier to pick up goods","Kutsu DPD kuller"
43
+ "Tomorrow","Homme"
44
+ "Today","Täna"
45
+ "Http request timeout","Http päringu ajapiirang"
46
+ "If timeout is greater than 10 seconds, then parcel data can only be sent manually. This field with the limitation will be removed latest 17th of February","Kui üle 10 sekundi, siis saab kaupmees ainult käsitsi paki andmed saata. Käesolev väli koos piiranguga kaotatakse hiljemalt 17. veebruariks."
app/locale/et_EE/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Nimekirja uuendus edukas"
2
+ "Rebuild postoffices for this carrier","Uuenda kontorite nimekirja"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Kontorite nimekirja uuendamine meetodile %s võtab veidi aega... Kas jätkad?"
4
+ "Automatic data sending not applicable","Automaatne andmete saatmine pole lubatud"
5
+ "Loading offices...","Laen kontoreid..."
6
+ "After successful checkout","Peale edukat tellimust"
7
+ "After successful shipment creation","Tellimuse väljasaatmise hetkel"
8
+ "-- select --","-- vali --"
9
+ "I will send data myself by clicking on the button","Saadan andmed ise vajutades nupule tellimuse juures"
10
+ "Print packing slip","Trüki pakikaart"
11
+ "Send shipping data to server","Saada paki andmed serverisse"
12
+ "Data sent to server, please verify the status from the order comments","Paki andmed saadetud serverisse, vaata tellimuse kommentaaridest saatmise õnnestumist"
13
+ "Disable populating list of last selected parcel terminals","Ära kuva viimati valitud automaatide nimekirja rippmenüü all"
14
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","Kui lubatud, siis kliendile näidatakse väljastuspunkte ühes rippmenüüs.<br/>Kui keelatud, siis klient valib algul sobiva maakonna/linna ning seejärel kuvatakse talle teine rippmenüü, milles asuvad väljastuspunktid eelnevalt valitud maakonnast/linnast."
15
+ "Show customer one dropdown instead of two","Kuva kliendile kahe rippmenüü asemel üks rippmenüü väljastuspunktidega"
16
+ "Enable Cash on Delivery (requires extra plugin)","Luba lunamaksega kohaletoimetamine (vajab lisapluginat)"
17
+ "Extra fee, when using Cash on delivery","Lisatasu, kui on valitud lunamakse"
18
+ "Enabled","Lubatud"
19
+ "Title","Nimetus"
20
+ "Price","Hind"
21
+ "Maximum allowed package weight for this carrier","Maksimaalne lubatud saadetise kaal"
22
+ "Handling action","Kohaletoimetamise hinna arvutusmetoodika"
23
+ "Enable free shipping","Luba tasuta kohaletoimetamine"
24
+ "Free shipping subtotal","Minimaalne ostukorvi summa, et kohaletoimetamine oleks tasuta"
25
+ "Show method if not applicable","Kui kohaletoimetus keelatud, siis kuva kasutajale veateadet"
26
+ "Error message displayed to the user","Kasutajale kuvatav veateade"
27
+ "Ship to applicable countries","Luba kohaletoimetus vaid osades riikides"
28
+ "Ship to Specific countries","Riigid, kuhu kohaletoimetamine on lubatud"
29
+ "Width in pixels for city select menu","Gruppide rippmenüü laius pikslites"
30
+ "Width in pixels for office select menu","Kontorite rippmenüü laius pikslites"
31
+ "Update interval for the postoffice list in minutes","Automaatne nimekirja uuendamise intervall minutites"
32
+ "Rebuild Postoffice List","Uuenda kontorite nimekirja"
33
+ "Sort order","Sorteerimise järjekord"
34
+ "Show short office names","Kuva kontorite nimesid lühikestena"
35
+ "Sort offices by priority","Kuva tähtsamad kontorid eespool"
36
+ "Auto send data to server","Saada paki andmed serverisse"
37
+ "Only if the order has been paid for or the order is COD","Kui tellimus on makstud, kohaletoimetamise viisiks on valitud käesolev tarne, siis saadetakse paki andmed käesoleva tarne serverisse. (Ainult makstud tellimused)"
38
+ "Yes: Shows only office name<br/>No: Shows office name and address","Jah: Kuvatakse vaid sihtkoha nimetus<br/>Ei: Kuvatakse sihtkoha nimetus ja aadress"
39
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Jah: suuremate linnade tarnepunktid kuvatakse eespool, ülejäänud tähestikulises järjekorras<br/>Ei: Tarnepunkte ei sorteerita<br/><b>käesoleva seadistuse muutmine nõuab kontorite nimekirja uuendamist</b>"
40
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Tellimuse kohta: Tarnehind on võrdne siin määratud hinnaga<br/>Eseme kohta: Tarne hind on võrdne siin määratud hinna ja ostukorvis olevate esemete arvu korrutisega"
41
+ "It is not recommended to update the list of offices more often than once a day.","On soovitatav mitte uuendada tarnepunktide nimekirja tihedamini kui kord ööpäevas."
42
+ "If post offices are not displayed correctly, then rebuilding the list may help","Kui tarnepunkte ei kuvata korrektselt, võib nimekirja uuendus lahendada probleemi"
app/locale/fi_FI/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Rebuild successful"
2
+ "Rebuild postoffices for this carrier","Rebuild postoffices for this carrier"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Rebuilding postoffices for the carrier %s takes a little while... Continue?"
4
+ "Automatic data sending not applicable","Automatic data sending not applicable"
5
+ "Loading offices...","Loading offices..."
6
+ "After successful checkout","After successful checkout"
7
+ "After successful shipment creation","After successful shipment creation"
8
+ "-- select --","-- select --"
9
+ "I will send data myself by clicking on the button","I will send data myself by clicking on the button"
10
+ "Print packing slip","Print packing slip"
11
+ "Send shipping data to server","Send shipping data to server"
12
+ "Data sent to server, please verify the status from the order comments","Data sent to server, please verify the status from the order comments"
13
+ "Disable populating list of last selected parcel terminals","Disable populating list of last selected parcel terminals"
14
+ "Show customer one dropdown instead of two","Show customer one dropdown instead of two"
15
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city."
16
+ "Enable Cash on Delivery (requires extra plugin)","Enable Cash on Delivery (requires extra plugin)"
17
+ "Extra fee, when using Cash on delivery","Extra fee, when using Cash on delivery"
18
+ "Enabled","Enabled"
19
+ "Title","Title"
20
+ "Price","Price"
21
+ "Maximum allowed package weight for this carrier","Maximum allowed package weight for this carrier"
22
+ "Handling action","Handling action"
23
+ "Enable free shipping","Enable free shipping"
24
+ "Free shipping subtotal","Free shipping subtotal"
25
+ "Show method if not applicable","Show method if not applicable"
26
+ "Error message displayed to the user","Error message displayed to the user"
27
+ "Ship to applicable countries","Ship to applicable countries"
28
+ "Ship to Specific countries","Ship to Specific countries"
29
+ "Width in pixels for city select menu","Width in pixels for city select menu"
30
+ "Width in pixels for office select menu","Width in pixels for office select menu"
31
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
32
+ "Rebuild Postoffice List","Rebuild Postoffice List"
33
+ "Sort order","Sort order"
34
+ "Show short office names","Show short office names"
35
+ "Sort offices by priority","Sort offices by priority"
36
+ "Auto send data to server","Auto send data to server"
37
+ "Only if the order has been paid for or the order is COD","Only if the order has been paid for or the order is COD"
38
+ "Yes: Shows only office name<br/>No: Shows office name and address","Yes: Shows only office name<br/>No: Shows office name and address"
39
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
40
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
41
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
42
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
app/locale/hu_HU/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Rebuild successful"
2
+ "Rebuild postoffices for this carrier","Rebuild postoffices for this carrier"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Rebuilding postoffices for the carrier %s takes a little while... Continue?"
4
+ "Automatic data sending not applicable","Automatic data sending not applicable"
5
+ "Loading offices...","Loading offices..."
6
+ "After successful checkout","After successful checkout"
7
+ "After successful shipment creation","After successful shipment creation"
8
+ "-- select --","-- select --"
9
+ "I will send data myself by clicking on the button","I will send data myself by clicking on the button"
10
+ "Print packing slip","Print packing slip"
11
+ "Send shipping data to server","Send shipping data to server"
12
+ "Data sent to server, please verify the status from the order comments","Data sent to server, please verify the status from the order comments"
13
+ "Disable populating list of last selected parcel terminals","Disable populating list of last selected parcel terminals"
14
+ "Show customer one dropdown instead of two","Show customer one dropdown instead of two"
15
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city."
16
+ "Enable Cash on Delivery (requires extra plugin)","Enable Cash on Delivery (requires extra plugin)"
17
+ "Extra fee, when using Cash on delivery","Extra fee, when using Cash on delivery"
18
+ "Enabled","Enabled"
19
+ "Title","Title"
20
+ "Price","Price"
21
+ "Maximum allowed package weight for this carrier","Maximum allowed package weight for this carrier"
22
+ "Handling action","Handling action"
23
+ "Enable free shipping","Enable free shipping"
24
+ "Free shipping subtotal","Free shipping subtotal"
25
+ "Show method if not applicable","Show method if not applicable"
26
+ "Error message displayed to the user","Error message displayed to the user"
27
+ "Ship to applicable countries","Ship to applicable countries"
28
+ "Ship to Specific countries","Ship to Specific countries"
29
+ "Width in pixels for city select menu","Width in pixels for city select menu"
30
+ "Width in pixels for office select menu","Width in pixels for office select menu"
31
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
32
+ "Rebuild Postoffice List","Rebuild Postoffice List"
33
+ "Sort order","Sort order"
34
+ "Show short office names","Show short office names"
35
+ "Sort offices by priority","Sort offices by priority"
36
+ "Auto send data to server","Auto send data to server"
37
+ "Only if the order has been paid for or the order is COD","Only if the order has been paid for or the order is COD"
38
+ "Yes: Shows only office name<br/>No: Shows office name and address","Yes: Shows only office name<br/>No: Shows office name and address"
39
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
40
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
41
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
42
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
app/locale/lt_LT/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Rebuild successful"
2
+ "Rebuild postoffices for this carrier","Rebuild postoffices for this carrier"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Rebuilding postoffices for the carrier %s takes a little while... Continue?"
4
+ "Automatic data sending not applicable","Automatic data sending not applicable"
5
+ "Loading offices...","Loading offices..."
6
+ "After successful checkout","After successful checkout"
7
+ "After successful shipment creation","After successful shipment creation"
8
+ "-- select --","-- select --"
9
+ "I will send data myself by clicking on the button","I will send data myself by clicking on the button"
10
+ "Print packing slip","Print packing slip"
11
+ "Send shipping data to server","Send shipping data to server"
12
+ "Data sent to server, please verify the status from the order comments","Data sent to server, please verify the status from the order comments"
13
+ "Disable populating list of last selected parcel terminals","Disable populating list of last selected parcel terminals"
14
+ "Show customer one dropdown instead of two","Show customer one dropdown instead of two"
15
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city."
16
+ "Enable Cash on Delivery (requires extra plugin)","Enable Cash on Delivery (requires extra plugin)"
17
+ "Extra fee, when using Cash on delivery","Extra fee, when using Cash on delivery"
18
+ "Enabled","Enabled"
19
+ "Title","Title"
20
+ "Price","Price"
21
+ "Maximum allowed package weight for this carrier","Maximum allowed package weight for this carrier"
22
+ "Handling action","Handling action"
23
+ "Enable free shipping","Enable free shipping"
24
+ "Free shipping subtotal","Free shipping subtotal"
25
+ "Show method if not applicable","Show method if not applicable"
26
+ "Error message displayed to the user","Error message displayed to the user"
27
+ "Ship to applicable countries","Ship to applicable countries"
28
+ "Ship to Specific countries","Ship to Specific countries"
29
+ "Width in pixels for city select menu","Width in pixels for city select menu"
30
+ "Width in pixels for office select menu","Width in pixels for office select menu"
31
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
32
+ "Rebuild Postoffice List","Rebuild Postoffice List"
33
+ "Sort order","Sort order"
34
+ "Show short office names","Show short office names"
35
+ "Sort offices by priority","Sort offices by priority"
36
+ "Auto send data to server","Auto send data to server"
37
+ "Only if the order has been paid for or the order is COD","Only if the order has been paid for or the order is COD"
38
+ "Yes: Shows only office name<br/>No: Shows office name and address","Yes: Shows only office name<br/>No: Shows office name and address"
39
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
40
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
41
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
42
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
app/locale/ru_RU/Eabi_DpdEE.csv ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "I have packing slips","I have packing slips"
2
+ "Envelopes (≤ 0,5kg)","Envelopes (≤ 0,5kg)"
3
+ "Parcels (≤ 31,5kg)","Parcels (≤ 31,5kg)"
4
+ "Pallets","Pallets"
5
+ "Pickup date","Pickup date"
6
+ "Pickup time","Pickup time"
7
+ " - select pickup date - "," - select pickup date - "
8
+ "Select pickup date first","Select pickup date first"
9
+ "Courier cannot be called for orders %s","Courier cannot be called for orders %s"
10
+ "Cannot call courier.","Cannot call courier."
11
+ "Country","Country"
12
+ "Base shipping price","Base shipping price"
13
+ "Price per additional 10kg over base 10kg","Price per additional 10kg over base 10kg"
14
+ "Free shipping from price","Free shipping from price"
15
+ "Add shipping country","Add shipping country"
16
+ "Comment to courier","Comment to courier"
17
+ "Courier comes to pick up your shipment on %1$s between %2$s","Courier comes to pick up your shipment on %1$s between %2$s"
18
+ "and","and"
19
+ "DPD - Pakivedu.ee - Pakipood","DPD - Pakivedu.ee - Pakipood"
20
+ "Price per country","Price per country"
21
+ "If country is not listed here, but this method is available, then general handling fee is applied","If country is not listed here, but this method is available, then general handling fee is applied"
22
+ "Disable this carrier if product's short description contains HTML comment &lt;!-- no dpd_ee_module --&gt;","Disable this carrier if product's short description contains HTML comment &lt;!-- no dpd_ee_module --&gt;"
23
+ "Auto send data to DPD server","Auto send data to DPD server"
24
+ "Allow courier pickup","Allow courier pickup"
25
+ "DPD Self service username","DPD Self service username"
26
+ "DPD Self-service password","DPD Self-service password"
27
+ "When to send parcel data","When to send parcel data"
28
+ "Pickup address name","Pickup address name"
29
+ "Pickup address company","Pickup address company"
30
+ "Pickup address e-mail","Pickup address e-mail"
31
+ "Pickup address phone","Pickup address phone"
32
+ "Pickup address street","Pickup address street"
33
+ "Pickup address city, county","Pickup address city, county"
34
+ "Pickup address zip code","Pickup address zip code"
35
+ "Pickup address country","Pickup address country"
36
+ "Show pickup address on packing label","Show pickup address on packing label"
37
+ "Save address for current customer","Save address for current customer"
38
+ "Labels position on packing slip","Labels position on packing slip"
39
+ "Api URL","Api URL"
40
+ "DPD - Pakivedu.ee - Courier service","DPD - Pakivedu.ee - Courier service"
41
+ "Position: %s","Position: %s"
42
+ "Order courier to pick up goods","Order courier to pick up goods"
43
+ "Tomorrow","Tomorrow"
44
+ "Today","Today"
45
+ "Http request timeout","Http request timeout"
46
+ "If timeout is greater than 10 seconds, then parcel data can only be sent manually. This field with the limitation will be removed latest 17th of February","If timeout is greater than 10 seconds, then parcel data can only be sent manually. This field with the limitation will be removed latest 17th of February"
app/locale/ru_RU/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Rebuild successful"
2
+ "Rebuild postoffices for this carrier","Rebuild postoffices for this carrier"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Rebuilding postoffices for the carrier %s takes a little while... Continue?"
4
+ "Automatic data sending not applicable","Automatic data sending not applicable"
5
+ "Loading offices...","Loading offices..."
6
+ "After successful checkout","After successful checkout"
7
+ "After successful shipment creation","After successful shipment creation"
8
+ "-- select --","-- select --"
9
+ "I will send data myself by clicking on the button","I will send data myself by clicking on the button"
10
+ "Print packing slip","Print packing slip"
11
+ "Send shipping data to server","Send shipping data to server"
12
+ "Data sent to server, please verify the status from the order comments","Data sent to server, please verify the status from the order comments"
13
+ "Disable populating list of last selected parcel terminals","Disable populating list of last selected parcel terminals"
14
+ "Show customer one dropdown instead of two","Show customer one dropdown instead of two"
15
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city."
16
+ "Enable Cash on Delivery (requires extra plugin)","Enable Cash on Delivery (requires extra plugin)"
17
+ "Extra fee, when using Cash on delivery","Extra fee, when using Cash on delivery"
18
+ "Enabled","Enabled"
19
+ "Title","Title"
20
+ "Price","Price"
21
+ "Maximum allowed package weight for this carrier","Maximum allowed package weight for this carrier"
22
+ "Handling action","Handling action"
23
+ "Enable free shipping","Enable free shipping"
24
+ "Free shipping subtotal","Free shipping subtotal"
25
+ "Show method if not applicable","Show method if not applicable"
26
+ "Error message displayed to the user","Error message displayed to the user"
27
+ "Ship to applicable countries","Ship to applicable countries"
28
+ "Ship to Specific countries","Ship to Specific countries"
29
+ "Width in pixels for city select menu","Width in pixels for city select menu"
30
+ "Width in pixels for office select menu","Width in pixels for office select menu"
31
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
32
+ "Rebuild Postoffice List","Rebuild Postoffice List"
33
+ "Sort order","Sort order"
34
+ "Show short office names","Show short office names"
35
+ "Sort offices by priority","Sort offices by priority"
36
+ "Auto send data to server","Auto send data to server"
37
+ "Only if the order has been paid for or the order is COD","Only if the order has been paid for or the order is COD"
38
+ "Yes: Shows only office name<br/>No: Shows office name and address","Yes: Shows only office name<br/>No: Shows office name and address"
39
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
40
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
41
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
42
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
app/locale/sv_SE/Eabi_Postoffice.csv ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Rebuild successful","Ombyggnad lyckad"
2
+ "Rebuild postoffices for this carrier","Uppdatera postkontor för fraktbolag"
3
+ "Rebuilding postoffices for the carrier %s takes a little while... Continue?","Bygg om postkontor för denna bärare %s kan ta en stund... Fortsätta?"
4
+ "Automatic data sending not applicable","Sändning av Automatisk data ej tillämpad"
5
+ "Loading offices...","Laddar postkontor..."
6
+ "After successful checkout","Efter lyckad Checkout"
7
+ "After successful shipment creation","Efter lyckad leverans skapad"
8
+ "-- select --","-- Välj --"
9
+ "I will send data myself by clicking on the button","Jag kommer att skicka data själv genom att klicka på knappen"
10
+ "Print packing slip","Skriv ut frakt handlingar"
11
+ "Send shipping data to server","Sänder frakt information till servern"
12
+ "Data sent to server, please verify the status from the order comments","Uppgifterna har sänds till servern, kontrollera status på ordern i kommentarerna"
13
+ "Disable populating list of last selected parcel terminals","Inaktivera listan med de senast valda terminalerna"
14
+ "Show customer one dropdown instead of two","Visar kunden en listrutan stället för två"
15
+ "If this setting is enabled, then customer will be displayed only with a list of stores you entered.<br/>If this setting is disabled, then customer has to pick country/city first and then customer will be displayed second select menu, which contains stores in the selected county/city.","Om den här inställningen är aktiverad, så kommer kunden att visas enbart en lista över butiker du angett. <br/> Om inställningen är inaktiverad, så kommer kunden vbehöva älja land/stad först och sedan kan kunden välja ifrån nästa meny, som innehåller butiker i länet/staden."
16
+ "Enable Cash on Delivery (requires extra plugin)","Aktivera Postförskott (kräver extra plugin)"
17
+ "Extra fee, when using Cash on delivery","Extra avgift vid användning Postförskott"
18
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
19
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
20
+ "Use only when you feel that select menu is too wide.","Use only when you feel that select menu is too wide."
21
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
22
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
23
+ "Yes: Offices from bigger cities will be in front<br>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
24
+ "Enabled","Enabled"
25
+ "Title","Title"
26
+ "Price","Price"
27
+ "Maximum allowed package weight for this carrier","Maximum allowed package weight for this carrier"
28
+ "Handling action","Handling action"
29
+ "Enable free shipping","Enable free shipping"
30
+ "Free shipping subtotal","Free shipping subtotal"
31
+ "Show method if not applicable","Show method if not applicable"
32
+ "Error message displayed to the user","Error message displayed to the user"
33
+ "Ship to applicable countries","Ship to applicable countries"
34
+ "Ship to Specific countries","Ship to Specific countries"
35
+ "Width in pixels for city select menu","Width in pixels for city select menu"
36
+ "Width in pixels for office select menu","Width in pixels for office select menu"
37
+ "Update interval for the postoffice list in minutes","Update interval for the postoffice list in minutes"
38
+ "Rebuild Postoffice List","Rebuild Postoffice List"
39
+ "Sort order","Sort order"
40
+ "Show short office names","Show short office names"
41
+ "Sort offices by priority","Sort offices by priority"
42
+ "Auto send data to server","Auto send data to server"
43
+ "Only if the order has been paid for or the order is COD","Only if the order has been paid for or the order is COD"
44
+ "Yes: Shows only office name<br/>No: Shows office name and address","Yes: Shows only office name<br/>No: Shows office name and address"
45
+ "Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>","Yes: Offices from bigger cities will be in front<br/>No: Offices are sorted alphabetically<br/><b>changing this setting requires rebuild</b>"
46
+ "Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price","Per Order: Shipping cost equals Shipping price<br/>Per Package: Shipping cost equals Number of Items in cart multiplied by shipping price"
47
+ "It is not recommended to update the list of offices more often than once a day.","It is not recommended to update the list of offices more often than once a day."
48
+ "If post offices are not displayed correctly, then rebuilding the list may help","If post offices are not displayed correctly, then rebuilding the list may help"
js/eabi_js/eabi_dpdee.js ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * or OpenGPL v3 license (GNU Public License V3.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
+ * or
12
+ * http://www.gnu.org/licenses/gpl-3.0.txt
13
+ * If you did not receive a copy of the license and are unable to
14
+ * obtain it through the world-wide-web, please send an email
15
+ * to info@e-abi.ee so we can send you a copy immediately.
16
+ *
17
+ * DISCLAIMER
18
+ *
19
+ * Do not edit or add to this file if you wish to upgrade this module to newer
20
+ * versions in the future.
21
+ *
22
+ * @category Eabi
23
+ * @package Eabi_Dpd
24
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
27
+ * @author Matis Halmann
28
+ *
29
+
30
+ */
31
+
32
+ var EabiDpdEE = new Class.create();
33
+
34
+ /**
35
+ * <p>Helper class for displaying/submitting DPD courier on-demand-call-block under order management for Merchant.</p>
36
+ * <p>on-demand-call-block is called as infoBox</p>
37
+ * @type EabiDpdEE
38
+ */
39
+ EabiDpdEE.prototype = {
40
+ /**
41
+ * <p>Initialize on-demand-courier-call-block</p>
42
+ * @param {string} infoBoxId unique HTML id to track this block
43
+ * @param {object} styleRules CSS style rules prototype js format.
44
+ * @param {function} afterCreate function to execute after this infoblock has been created. Parameter is created infoblock.
45
+ * @param {function} afterShow function to execute after block is shown. Parameter is created infoblock.
46
+ * @param {function} afterEndResult function to execute after data is submitted. Parameter is submitted form data and function must return same data or false in order to prevent the form to be posted.
47
+ * @returns {EabiDpdEE}
48
+ */
49
+ initialize: function(infoBoxId, styleRules, afterCreate, afterShow, afterEndResult) {
50
+ this.infoBoxId = infoBoxId;
51
+ this.styleRules = styleRules;
52
+ this.afterCreate = afterCreate;
53
+ this.afterShow = afterShow;
54
+ this.afterEndResult = afterEndResult;
55
+ this.offset = $(this.infoBoxId).positionedOffset();
56
+ this.orderId = false;
57
+ this.created = false;
58
+ },
59
+ /**
60
+ * <p>Creates or returns block instance.</p>
61
+ * @returns {Element} created on-demand-courier-call-block
62
+ */
63
+ getInfoBox: function() {
64
+ if (!this.infoBox || !$(this.infoBoxId + '_box')) {
65
+ if (Control.Modal.current) {
66
+ $$('.eabi_window .button_box').invoke('hide');
67
+ this.infoBox = new Element('div');
68
+ this.infoBox.setAttribute('id', this.infoBoxId + '_box');
69
+ this.infoBox.setAttribute('class', 'button_box');
70
+ this.infoBox.setStyle({
71
+ position: 'absolute',
72
+ top: (this.offset.top - 135) + 'px',
73
+ left: (this.offset.left) + 'px'
74
+ });
75
+ if (this.styleRules) {
76
+ this.infoBox.setStyle(this.styleRules);
77
+ }
78
+ Control.Modal.current.container.insert({bottom: this.infoBox});
79
+
80
+ //create after goes here
81
+ if (this.afterCreate) {
82
+ this.afterCreate(this.infoBox);
83
+ }
84
+ this.created = true;
85
+
86
+ } else {
87
+ this.infoBox = new Element('div');
88
+ this.infoBox.setAttribute('id', this.infoBoxId + '_box');
89
+ this.infoBox.setAttribute('class', 'button_box');
90
+ this.infoBox.setStyle({
91
+ position: 'absolute',
92
+ top: (this.offset.top - 135) + 'px',
93
+ left: (this.offset.left) + 'px'
94
+ });
95
+ if (this.styleRules) {
96
+ this.infoBox.setStyle(this.styleRules);
97
+ }
98
+ $$('body').first().insert({bottom: this.infoBox});
99
+
100
+ //create after goes here
101
+ if (this.afterCreate) {
102
+ this.afterCreate(this.infoBox);
103
+ }
104
+ this.created = true;
105
+
106
+ }
107
+ }
108
+ return this.infoBox;
109
+ },
110
+ /**
111
+ * <p>Updates infobox instance with supplied HTML contents</p>
112
+ * <p>Executes check action on the massaction object for supplied orderId.</p>
113
+ * <p>Updates number of parcels in accordance of selected orders under massActionObject.</p>
114
+ * @param {string} htmlContents
115
+ * @param {string|int} orderId
116
+ * @param {varienGridMassaction} massActionObject
117
+ * @returns {undefined}
118
+ */
119
+ update: function(htmlContents, orderId, massActionObject) {
120
+ var isOrderSelected = false,
121
+ parcelQty = 1,
122
+ orders = orderId,
123
+ orderMassActionCheckbox;
124
+ //if trying to call the courier, check the current order
125
+ if (orderId) {
126
+ orderMassActionCheckbox = $$('.eabi_window .window_checkbox input[value=' + orderId + ']');
127
+ if (orderMassActionCheckbox) {
128
+ orderMassActionCheckbox = orderMassActionCheckbox.first();
129
+ if (orderMassActionCheckbox && orderMassActionCheckbox.getValue()) {
130
+ isOrderSelected = true;
131
+ }
132
+ }
133
+ if (!isOrderSelected && orderMassActionCheckbox) {
134
+ orderMassActionCheckbox.click();
135
+ }
136
+ }
137
+ if (massActionObject) {
138
+ parcelQty = varienStringArray.count(massActionObject.getCheckedValues());
139
+ orders = massActionObject.getCheckedValues();
140
+ }
141
+ if (this.orderId && orderId !== this.orderId || !$(this.infoBoxId + '_box')) {
142
+ this.infoBox = false;
143
+ this.getInfoBox();
144
+ if (htmlContents) {
145
+ this.infoBox.update(htmlContents);
146
+ //update the parcels
147
+ $('Po_parcel_qty').writeAttribute('value', parcelQty);
148
+ $('eabi_dpdee_order_ids').writeAttribute('value', orders);
149
+ }
150
+ } else if (!this.orderId) {
151
+ this.getInfoBox();
152
+ if (htmlContents) {
153
+ this.infoBox.update(htmlContents);
154
+ //update the parcels
155
+ $('Po_parcel_qty').writeAttribute('value', parcelQty);
156
+ $('eabi_dpdee_order_ids').writeAttribute('value', orders);
157
+ }
158
+ }
159
+ this.orderId = orderId;
160
+ },
161
+ /**
162
+ *
163
+ * <p>Attempts to submit data from infoBox form fields to server.</p>
164
+ * <p>If submit cannot be done, then it hides infoBox.</p>
165
+ * <p>If infoBox is hidden, then it displays infoBox.</p>
166
+ * @param {string} url not required, when provided, ajax request also is sent.
167
+ * @returns {object|Boolean}
168
+ */
169
+ submit: function(url, successFunction) {
170
+ var endResult = false;
171
+ if (this.infoBox) {
172
+ if (this.infoBox.visible()) {
173
+ endResult = Form.serializeElements(this.infoBox.select('input, text, textarea, select'), {"hash":true});
174
+ if (endResult === {} || endResult === []) {
175
+ endResult = false;
176
+ }
177
+ if (this.afterEndResult) {
178
+ endResult = this.afterEndResult(endResult);
179
+ }
180
+ if (endResult && url) {
181
+ new Ajax.Request(url, {
182
+ method: 'post',
183
+ parameters: endResult,
184
+ evalJSON: 'force',
185
+ onSuccess: function(transport){
186
+ if (successFunction) {
187
+ successFunction(transport.responseJSON, this.infoBox);
188
+ }
189
+ }.bind(this),
190
+ onFailure: function(transport){
191
+ alert('Request failed, check your error logs');
192
+ }
193
+ });
194
+ }
195
+ if (!endResult && !this.created) {
196
+ this.infoBox.hide();
197
+ }
198
+ if (this.created) {
199
+ this.created = false;
200
+ }
201
+ } else {
202
+ this.infoBox.show();
203
+ if (this.afterShow) {
204
+ this.afterShow(this.infoBox);
205
+ }
206
+ }
207
+
208
+ }
209
+ return endResult;
210
+ }
211
+ };
package.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Eabi_DpdEE</name>
4
+ <version>0.1.5</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.txt">GNU Public License V3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>&lt;p&gt;Adds DPD shipping method with parcel info sending and courier call functionality&lt;/p&gt;</summary>
10
+ <description>&lt;p&gt;Adds DPD parcel store shipping method&lt;/p&gt;&#xD;
11
+ &lt;p&gt;Adds DPD courier shipping method&lt;/p&gt;&#xD;
12
+ &lt;p&gt;Allows to define shipping price per country&lt;/p&gt;&#xD;
13
+ &lt;p&gt;Allows to define free shipping per country&lt;/p&gt;&#xD;
14
+ &lt;p&gt;Pre-filled with Estonia, Latvia, Lithuania shipping prices&lt;/p&gt;&#xD;
15
+ &lt;p&gt;Refreshes list of parcel terminal automatically&lt;/p&gt;&#xD;
16
+ &lt;p&gt;Allows to create and print DPD packing slips&lt;/p&gt;&#xD;
17
+ &lt;p&gt;Allows to call the courier from Magento admin&lt;/p&gt;&#xD;
18
+ &lt;p&gt;Intended to use for Estonian merchant who sends parcels to all Baltic states&lt;/p&gt;&#xD;
19
+ </description>
20
+ <notes>* Packing slip displays Pakipood address at the packing slip instead of customers address&#xD;
21
+ * Courier call in menu displays available times now properly.</notes>
22
+ <authors><author><name>Matis Matis</name><user>mhalmann</user><email>info@e-abi.ee</email></author></authors>
23
+ <date>2014-02-25</date>
24
+ <time>20:53:43</time>
25
+ <contents><target name="magecommunity"><dir name="Eabi"><dir name="DpdEE"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Country.php" hash="248931633c577c16670d8c055f83bc07"/></dir></dir></dir></dir><dir name="Order"><file name="Courier.php" hash="d719026b8baa83a61410d7c3d3a7b2b8"/></dir></dir><file name="CHANGELOG.txt" hash="c1462eeb9d109135e8d451c7341c4e3b"/><dir name="Helper"><file name="Data.php" hash="2b01e482067b51d29cd539b19ed91422"/></dir><file name="LICENCE.txt" hash="0191312e121c0b3e1165619b96efcf9f"/><dir name="Model"><dir name="Action"><dir name="Carrier"><dir name="Order"><file name="Courier.php" hash="4320003600c3711269ceb793c79f1a0e"/></dir></dir></dir><file name="Api.php" hash="769e780f959008fcf0e3e42eaefd9ded"/><dir name="Button"><file name="Courier.php" hash="dcf458fc84b12e9656d9e5b9d607786e"/></dir><file name="Config.php" hash="6d1767803078b10fff7fca5c9a8fce73"/><file name="Flat.php" hash="3411b2d21a3bcec64aef52c3bf55425c"/><file name="Observer.php" hash="0cd4bff03583da0ac8f2acc7408ab7fe"/><file name="Post.php" hash="22f5532294dc87849c7930fd80437c2a"/><dir name="Source"><dir name="Label"><file name="Position.php" hash="7f95f8570328962b88a36d51b6f3e542"/></dir><file name="Service.php" hash="0d7ec71a6322c4b993d0335f76cc9ee4"/></dir></dir><dir name="etc"><file name="config.xml" hash="5906be5cb2c7f76b82543d64ab7e2898"/><file name="system.xml" hash="e9fbade4b810a0ade868685c146f28a0"/></dir><dir name="sql"><dir name="eabi_dpdee_setup"><file name="mysql4-install-0.1.0.php" hash="82be7ae5961aa797bf5944da67bf5155"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="9d6d7a5eaf6fe21b383bd1d010a70fb0"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="3ac820366b298aa7f124aac777ed20da"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="dcd90c42f16e8dca6ea567f196256796"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="1018891e649edaac75704ccc454c5d0f"/></dir></dir></dir><dir name="Postoffice"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Remove.php" hash="36582578ccfc5348053f6fd5876d95df"/></dir></dir></dir></dir><dir name="Config"><file name="Rebuildbutton.php" hash="5df4fd9f74bdd664d43b5e9debf95260"/></dir></dir><dir name="Helper"><file name="Countrycode.php" hash="b2f6e253d3351edff9b551eb6d86dce8"/><file name="Data.php" hash="52e2798a55bc60a2956251a5fe37bb06"/></dir><dir name="Model"><dir name="Carrier"><file name="Abstract.php" hash="64afe3c0fe9d687cace03689e798605f"/><file name="Result.php" hash="fbb58545e0dea7ce6b277c2d27405e17"/></dir><file name="Carriermodule.php" hash="97bcd9821511a55697247514c8dc280f"/><dir name="Mysql4"><dir name="Carriermodule"><file name="Collection.php" hash="b125174c7a7532b27cb7736eecd984aa"/></dir><file name="Carriermodule.php" hash="4033f81a6ed9d15439e022525825c550"/><dir name="Office"><file name="Collection.php" hash="08b82e1b2067da8c6f62f026bd0f289c"/></dir><file name="Office.php" hash="11295e3d59cb440ece5a31c59793579a"/></dir><file name="Office.php" hash="e119cd9055075ddb68aa90e9413868e8"/><file name="Orderview.php" hash="a4a36ada9222c03863eb1b0415ecd681"/><dir name="Source"><file name="Sendevent.php" hash="e2a1a255ebe31f4a737df76b83cc0612"/></dir><file name="Updater.php" hash="a96e1e6fcba4302f0f108f22a2416767"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PostofficeController.php" hash="b2c5e190e3ab7224c0e7e3bb192f65ab"/></dir><file name="IndexController.php" hash="0a1b21c56ac5ced18f7308cb1b7b2779"/></dir><dir name="etc"><file name="config.xml" hash="996174238756263f6e6fbe6de9778907"/></dir><dir name="sql"><dir name="eabi_postoffice_setup"><file name="mysql4-install-0.1.0.php" hash="8834196075d52491ab67e141dd89466d"/><file name="mysql4-upgrade-0.1.0-0.1.1.php" hash="21443cd02970fa62a90a83348623edf2"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="04dc9a59623a21354d31b67533f8c081"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="eabi_dpdee.xml" hash="85311cb850eb13eadaed47cdc9c44fb3"/><file name="eabi_postoffice.xml" hash="f549aec3cab6d7f4be38ad16c9878ad0"/></dir><dir name="template"><dir name="eabi_dpdee"><dir name="order"><file name="courier.phtml" hash="0310f24e96ca3873e78e0e2a0ab26743"/></dir></dir><dir name="eabi_postoffice"><file name="shipping_method_form.phtml" hash="e932b7215c23ec7457a7dbca1e757209"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="eabi_dpdee.xml" hash="27179eee219a0a8c85b87b8d670ae9e1"/><file name="eabi_postoffice.xml" hash="2324cf0537e7128907f1e82952d2428b"/></dir><dir name="template"><dir name="eabi_postoffice"><file name="available.phtml" hash="c6e12f338e2c328fd39ef4d28f76c4cd"/><file name="multishipping.phtml" hash="1d3b1ec07fb7253204bc6d404e0c297a"/><file name="shipping.phtml" hash="0ffb21b42357907addc225021ff90b87"/><dir name="tracking"><file name="popup.phtml" hash="9141744241fc4add47ed20b91405fa8e"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eabi_Postoffice.xml" hash="5985cb591c22d86ba55575ef55fc5d73"/><file name="Eabi_DpdEE.xml" hash="579869b5e97549b10cb060987a96910a"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Eabi_DpdEE.csv" hash="73f89704ae83dcd6c30b8feadeaf77b1"/><file name="Eabi_Postoffice.csv" hash="efd07c7191b6787abe38bf13ee199714"/></dir><dir name="et_EE"><file name="Eabi_DpdEE.csv" hash="8a4cedf5cf88f9b0a904293ff4900a6b"/><file name="Eabi_Postoffice.csv" hash="c70858d1325cb13428695e71582cd598"/></dir><dir name="ru_RU"><file name="Eabi_DpdEE.csv" hash="a4680d315a6b14009ffaac8f6756bb2a"/><file name="Eabi_Postoffice.csv" hash="efd07c7191b6787abe38bf13ee199714"/></dir><dir name="hu_HU"><file name="Eabi_Postoffice.csv" hash="efd07c7191b6787abe38bf13ee199714"/></dir><dir name="fi_FI"><file name="Eabi_Postoffice.csv" hash="efd07c7191b6787abe38bf13ee199714"/></dir><dir name="lt_LT"><file name="Eabi_Postoffice.csv" hash="efd07c7191b6787abe38bf13ee199714"/></dir><dir name="sv_SE"><file name="Eabi_Postoffice.csv" hash="fc105fd30ae95f5502e784aca5d8017d"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="eabi_dpdee.css" hash="9cfe785b8d341c290c1b6b084cc9e770"/></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="eabi_js"><file name="eabi_dpdee.js" hash="05db7b35460896b54fc4a6fe4791205e"/></dir></dir></target></contents>
26
+ <compatible/>
27
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Eabi_Livehandler</name><channel>community</channel><min>0.1.5</min><max>1.0.0</max></package></required></dependencies>
28
+ </package>
skin/adminhtml/default/default/eabi_dpdee.css ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * or OpenGPL v3 license (GNU Public License V3.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
+ * or
12
+ * http://www.gnu.org/licenses/gpl-3.0.txt
13
+ * If you did not receive a copy of the license and are unable to
14
+ * obtain it through the world-wide-web, please send an email
15
+ * to info@e-abi.ee so we can send you a copy immediately.
16
+ *
17
+ * DISCLAIMER
18
+ *
19
+ * Do not edit or add to this file if you wish to upgrade this module to newer
20
+ * versions in the future.
21
+ *
22
+ * @category Eabi
23
+ * @package Eabi_Dpd
24
+ * @copyright Copyright (c) 2013 Aktsiamaailm LLC (http://en.e-abi.ee/)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ * @license http://www.gnu.org/licenses/gpl-3.0.txt GNU Public License V3.0
27
+ * @author Matis Halmann
28
+ *
29
+
30
+ */
31
+
32
+ #eabi_dpdee__button_courier_box {
33
+ width: 296px;
34
+ background: #fff;
35
+ border: 1px solid #111;
36
+ padding: 10px;
37
+ margin-left: -202px;
38
+ margin-top: 155px;
39
+ }
40
+ #eabi_dpdee__button_courier_box .time_range ,
41
+ #eabi_dpdee__button_courier_box .date_range ,
42
+ #eabi_dpdee__button_courier_box .label_info
43
+ {
44
+ text-align: left;
45
+ padding-left: 20px;
46
+ }
47
+ #eabi_dpdee__button_courier_box .date_range {
48
+ }
49
+ #eabi_dpdee__button_courier_box .label_info {
50
+ }
51
+
52
+
53
+ #eabi_dpdee__button_courier_box .shipment_info label {
54
+ font-size: 8px;
55
+ width: 40px;
56
+ }
57
+
58
+ #eabi_dpdee__button_courier_box .shipment_info input {
59
+ width: 20px;
60
+ }
61
+