dpdshipping - Version 1.0.1

Version Notes

First release

Download this release

Release Info

Developer PHPro
Extension dpdshipping
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

Files changed (52) hide show
  1. app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order.php +26 -0
  2. app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order/Grid.php +245 -0
  3. app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order/Grid/Renderer/Shippingmethod.php +31 -0
  4. app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order/View/Tab/Returnlabels.php +83 -0
  5. app/code/community/DPD/Shipping/Block/Adminhtml/Shipping/Carrier/Dpdclassic/Tablerate/Grid.php +137 -0
  6. app/code/community/DPD/Shipping/Block/Adminhtml/Shipping/Carrier/Dpdparcelshops/Tablerate/Grid.php +133 -0
  7. app/code/community/DPD/Shipping/Block/Adminhtml/System/Config/Form/Availability.php +96 -0
  8. app/code/community/DPD/Shipping/Block/Adminhtml/System/Config/Form/Dpdclassicexport.php +38 -0
  9. app/code/community/DPD/Shipping/Block/Adminhtml/System/Config/Form/Dpdparcelshopsexport.php +38 -0
  10. app/code/community/DPD/Shipping/Block/Carrier/Parcelshop.php +294 -0
  11. app/code/community/DPD/Shipping/Helper/Data.php +171 -0
  12. app/code/community/DPD/Shipping/Model/Adminhtml/Dpdgrid.php +215 -0
  13. app/code/community/DPD/Shipping/Model/Adminhtml/System/Config/Backend/Shipping/Dpdclassic/Tablerate.php +22 -0
  14. app/code/community/DPD/Shipping/Model/Adminhtml/System/Config/Backend/Shipping/Dpdparcelshops/Tablerate.php +22 -0
  15. app/code/community/DPD/Shipping/Model/Adminhtml/System/Config/Backend/Shipping/Specialparcelshops.php +22 -0
  16. app/code/community/DPD/Shipping/Model/Carrier/Dpdclassic.php +200 -0
  17. app/code/community/DPD/Shipping/Model/Carrier/Dpdparcelshops.php +204 -0
  18. app/code/community/DPD/Shipping/Model/Dpdclassic/Tablerate.php +22 -0
  19. app/code/community/DPD/Shipping/Model/Dpdparcelshops/Tablerate.php +22 -0
  20. app/code/community/DPD/Shipping/Model/Mysql4/Dpdclassic/Tablerate.php +433 -0
  21. app/code/community/DPD/Shipping/Model/Mysql4/Dpdclassic/Tablerate/Collection.php +107 -0
  22. app/code/community/DPD/Shipping/Model/Mysql4/Dpdparcelshops/Tablerate.php +433 -0
  23. app/code/community/DPD/Shipping/Model/Mysql4/Dpdparcelshops/Tablerate/Collection.php +106 -0
  24. app/code/community/DPD/Shipping/Model/Mysql4/Returnlabels.php +22 -0
  25. app/code/community/DPD/Shipping/Model/Mysql4/Returnlabels/Collection.php +23 -0
  26. app/code/community/DPD/Shipping/Model/Mysql4/Specialparcelshops.php +218 -0
  27. app/code/community/DPD/Shipping/Model/Mysql4/Specialparcelshops/Collection.php +23 -0
  28. app/code/community/DPD/Shipping/Model/Observer.php +105 -0
  29. app/code/community/DPD/Shipping/Model/Returnlabels.php +160 -0
  30. app/code/community/DPD/Shipping/Model/Specialparcelshops.php +22 -0
  31. app/code/community/DPD/Shipping/Model/System/Config/Source/Display.php +45 -0
  32. app/code/community/DPD/Shipping/Model/System/Config/Source/Paperformat.php +45 -0
  33. app/code/community/DPD/Shipping/Model/System/Config/Source/Ratetypes.php +46 -0
  34. app/code/community/DPD/Shipping/Model/System/Config/Source/Weightunit.php +47 -0
  35. app/code/community/DPD/Shipping/Model/Webservice.php +451 -0
  36. app/code/community/DPD/Shipping/controllers/Adminhtml/DpdconfigController.php +53 -0
  37. app/code/community/DPD/Shipping/controllers/Adminhtml/DpdorderController.php +222 -0
  38. app/code/community/DPD/Shipping/controllers/AjaxController.php +60 -0
  39. app/code/community/DPD/Shipping/etc/adminhtml.xml +30 -0
  40. app/code/community/DPD/Shipping/etc/config.xml +210 -0
  41. app/code/community/DPD/Shipping/etc/system.xml +484 -0
  42. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-install-0.0.1.php +21 -0
  43. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.1-0.0.2.php +16 -0
  44. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.2-0.0.3.php +24 -0
  45. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.3-0.0.4.php +15 -0
  46. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.4-0.0.5.php +15 -0
  47. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.5-0.0.6.php +13 -0
  48. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.6-0.0.7.php +13 -0
  49. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.7-0.0.8.php +37 -0
  50. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.8-0.0.9.php +25 -0
  51. app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.9-0.1.0.php +25 -0
  52. package.xml +3 -3
app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_Sales_Order
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_Sales_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
14
+ {
15
+ /**
16
+ * Sets blockgroup for our DPD Orders page.
17
+ */
18
+ public function __construct()
19
+ {
20
+ $this->_blockGroup = 'dpd';
21
+ $this->_controller = 'adminhtml_sales_order';
22
+ $this->_headerText = Mage::helper('dpd')->__('DPD Orders');
23
+ parent::__construct();
24
+ $this->_removeButton('add');
25
+ }
26
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order/Grid.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_Sales_Order_Grid
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
14
+ {
15
+ /**
16
+ * Constructs the grid and sets basic parameters.
17
+ */
18
+ public function __construct()
19
+ {
20
+ parent::__construct();
21
+ $this->setId('dpd_shipping_grid');
22
+ $this->setDefaultSort('created_at');
23
+ $this->setDefaultDir('DESC');
24
+ $this->setSaveParametersInSession(true);
25
+ $this->setUseAjax(true);
26
+ }
27
+
28
+ /**
29
+ * prepare collection to use for the grid.
30
+ *
31
+ * @return $this
32
+ */
33
+ protected function _prepareCollection()
34
+ {
35
+ $collection = Mage::getResourceModel('sales/order_grid_collection');
36
+ $collection->getSelect()->join('sales_flat_order', '`sales_flat_order`.entity_id=`main_table`.entity_id', array(
37
+ 'shipping_method' => 'shipping_method',
38
+ 'total_qty_ordered' => 'ROUND(total_qty_ordered,0)',
39
+ 'dpd_label_exported' => 'dpd_label_exported',
40
+ 'dpd_label_exists' => 'dpd_label_exists'
41
+ ));
42
+ $collection->addAttributeToFilter('shipping_method', array('like' => '%dpd%'));
43
+ $this->setCollection($collection);
44
+ parent::_prepareCollection();
45
+ return $this;
46
+ }
47
+
48
+ /**
49
+ * prepare columns used in the grid.
50
+ *
51
+ * @return $this
52
+ */
53
+ protected function _prepareColumns()
54
+ {
55
+ $helper = Mage::helper('dpd');
56
+ $currency = (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
57
+ $this->addColumn('real_order_id', array(
58
+ 'header' => $helper->__('Order #'),
59
+ 'width' => '80px',
60
+ 'type' => 'text',
61
+ 'index' => 'increment_id',
62
+ 'filter_index' => 'main_table.increment_id'
63
+ ));
64
+
65
+ if (!Mage::app()->isSingleStoreMode()) {
66
+ $this->addColumn('store_id', array(
67
+ 'header' => $helper->__('Purchased From (Store)'),
68
+ 'index' => 'store_id',
69
+ 'type' => 'store',
70
+ 'store_view' => true,
71
+ 'display_deleted' => true,
72
+ 'filter_index' => 'sales_flat_order.store_id'
73
+ ));
74
+ }
75
+ $this->addColumn('created_at', array(
76
+ 'header' => $helper->__('Purchased On'),
77
+ 'index' => 'created_at',
78
+ 'type' => 'datetime',
79
+ 'width' => '100px',
80
+ 'filter_index' => 'main_table.created_at'
81
+ ));
82
+
83
+ $this->addColumn('billing_name', array(
84
+ 'header' => $helper->__('Bill to Name'),
85
+ 'index' => 'billing_name',
86
+ 'filter_index' => 'main_table.billing_name'
87
+ ));
88
+ $this->addColumn('shipping_name', array(
89
+ 'header' => $helper->__('Ship to Name'),
90
+ 'index' => 'shipping_name',
91
+ 'filter_index' => 'main_table.shipping_name'
92
+ ));
93
+ $this->addColumn('base_grand_total', array(
94
+ 'header' => $helper->__('G.T. (Base)'),
95
+ 'index' => 'base_grand_total',
96
+ 'type' => 'currency',
97
+ 'currency' => 'base_currency_code',
98
+ 'filter_index' => 'main_table.base_grand_total'
99
+ ));
100
+
101
+ $this->addColumn('grand_total', array(
102
+ 'header' => $helper->__('G.T. (Purchased)'),
103
+ 'index' => 'grand_total',
104
+ 'type' => 'currency',
105
+ 'currency' => 'order_currency_code',
106
+ 'filter_index' => 'main_table.grand_total'
107
+ ));
108
+
109
+ $this->addColumn('total_qty_ordered', array(
110
+ 'header' => $helper->__('# of Items'),
111
+ 'type' => 'int',
112
+ 'index' => 'total_qty_ordered',
113
+ 'width' => '100px',
114
+ ));
115
+
116
+ $this->addColumn('status', array(
117
+ 'header' => $helper->__('Status'),
118
+ 'index' => 'status',
119
+ 'type' => 'options',
120
+ 'width' => '70px',
121
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
122
+ 'filter_index' => 'main_table.status'
123
+ ));
124
+ $this->addColumn('shipping_method', array(
125
+ 'header' => $helper->__('DPD Type'),
126
+ 'index' => 'shipping_method',
127
+ 'type' => 'options',
128
+ 'options' => $this->getDpdTypeOptions(),
129
+ 'renderer' => 'DPD_Shipping_Block_Adminhtml_Sales_Order_Grid_Renderer_Shippingmethod'
130
+ ));
131
+ $this->addColumn('dpd_label_exists', array(
132
+ 'header' => $helper->__('DPD Label'),
133
+ 'index' => 'dpd_label_exists',
134
+ 'type' => 'options',
135
+ 'width' => '100px',
136
+ 'options' => array(
137
+ 0 => 'No',
138
+ 1 => 'Yes',
139
+ )
140
+ ));
141
+ $this->addColumn('dpd_label_exported', array(
142
+ 'header' => $helper->__('Label Downloaded'),
143
+ 'index' => 'dpd_label_exported',
144
+ 'type' => 'options',
145
+ 'width' => '100px',
146
+ 'options' => array(
147
+ 0 => 'No',
148
+ 1 => 'Yes',
149
+ )
150
+ ));
151
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
152
+ $this->addColumn('action',
153
+ array(
154
+ 'header' => $helper->__('Action'),
155
+ 'width' => '50px',
156
+ 'type' => 'action',
157
+ 'getter' => 'getId',
158
+ 'actions' => array(
159
+ array(
160
+ 'caption' => $helper->__('View'),
161
+ 'url' => array('base' => '*/sales_order/view', 'params' => array('dpdReturn' => '1')),
162
+ 'field' => 'order_id',
163
+ )
164
+ ),
165
+ 'filter' => false,
166
+ 'sortable' => false,
167
+ 'index' => 'stores',
168
+ 'is_system' => true,
169
+ ));
170
+ }
171
+ $this->addExportType('*/*/exportDPDOrdersCsv', $helper->__('CSV'));
172
+ $this->addExportType('*/*/exportDPDOrdersExcel', $helper->__('Excel XML'));
173
+ return parent::_prepareColumns();
174
+ }
175
+
176
+ /**
177
+ * Gets grid url for callbacks.
178
+ *
179
+ * @return string
180
+ */
181
+ public function getGridUrl()
182
+ {
183
+ return $this->getUrl('*/*/grid', array('_current' => true));
184
+ }
185
+
186
+
187
+ /**
188
+ * Returns possible filters for DPD type column.
189
+ *
190
+ * @return array
191
+ */
192
+ public function getDpdTypeOptions()
193
+ {
194
+ $options = array();
195
+ $optionText = "";
196
+ $collection = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('shipping_method', array('like' => '%dpd%'))->addAttributeToSelect('shipping_method');
197
+ $collection->getSelect()->group('shipping_method');
198
+ foreach ($collection as $option) {
199
+ if ($option->getShippingMethod() == "dpdparcelshops_dpdparcelshops") {
200
+ $optionText = 'DPD parcelshop';
201
+ } elseif ($option->getShippingMethod() == "dpdclassic_dpdclassic") {
202
+ $optionText = 'DPD classic';
203
+ }
204
+ $options[$option->getShippingMethod()] = $optionText;
205
+ }
206
+ return $options;
207
+ }
208
+
209
+ /**
210
+ * Prepares Massactions for the grid.
211
+ *
212
+ * @return $this
213
+ */
214
+ protected function _prepareMassaction()
215
+ {
216
+ $this->setMassactionIdField('`main_table`.entity_id');
217
+ $this->getMassactionBlock()->setFormFieldName('entity_id');
218
+ $this->getMassactionBlock()->addItem('generateAndComplete', array(
219
+ 'label' => Mage::helper('dpd')->__('Generate Label and Complete'),
220
+ 'url' => $this->getUrl('*/*/generateAndComplete'),
221
+ 'confirm' => Mage::helper('dpd')->__('Generating a label can take up to 1 second per label, please be patient during this process. It can take up to maximum 2 minutes. Do you want to continue?')
222
+ ));
223
+ $this->getMassactionBlock()->addItem('dowloadAllUndownloaded', array(
224
+ 'label' => Mage::helper('dpd')->__('Download all undownloaded'),
225
+ 'url' => $this->getUrl('*/*/dowloadAllUndownloaded'),
226
+ 'confirm' => Mage::helper('dpd')->__('Please refresh the page after downloading to review the confirmation messages including any problems encountered. Continue?')
227
+ ));
228
+ return $this;
229
+ }
230
+
231
+
232
+ /**
233
+ * Generate rowurl.
234
+ *
235
+ * @param $row
236
+ * @return string
237
+ */
238
+ public function getRowUrl($row)
239
+ {
240
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
241
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId(), 'dpdReturn' => '1'));
242
+ }
243
+ return false;
244
+ }
245
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order/Grid/Renderer/Shippingmethod.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_Sales_Order_Grid_Renderer_Shippingmethod
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_Sales_Order_Grid_Renderer_Shippingmethod extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
14
+ {
15
+ /**
16
+ * Renders select between DPD parcelshop or DPD classic.
17
+ *
18
+ * @param Varien_Object $row
19
+ * @return string
20
+ */
21
+ public function render(Varien_Object $row)
22
+ {
23
+ $value = $row->getData($this->getColumn()->getIndex());
24
+ if ($value == "dpdparcelshops_dpdparcelshops") {
25
+ return 'DPD parcelshop';
26
+ } elseif ($value == "dpdclassic_dpdclassic") {
27
+ return 'DPD classic';
28
+ }
29
+ return $this;
30
+ }
31
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/Sales/Order/View/Tab/Returnlabels.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Returnlabels
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_Sales_Order_View_Tab_Returnlabels
14
+ extends Mage_Adminhtml_Block_Template
15
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface{
16
+
17
+ /**
18
+ * Constructs the block and sets template on it.
19
+ *
20
+ */
21
+ protected function _construct()
22
+ {
23
+ parent::_construct();
24
+ $this->setTemplate('dpd/order/view/tab/returnlabels.phtml');
25
+ }
26
+
27
+ /**
28
+ * Returns tab label.
29
+ *
30
+ * @return string
31
+ */
32
+ public function getTabLabel() {
33
+ return Mage::helper('dpd')->__('DPD Return Labels');
34
+ }
35
+
36
+ /**
37
+ * Returns tab title.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getTabTitle() {
42
+ return Mage::helper('dpd')->__('DPD Return Labels');
43
+ }
44
+
45
+ /**
46
+ * Checks if tab can be shown.
47
+ *
48
+ * @return bool
49
+ */
50
+ public function canShowTab() {
51
+ return true;
52
+ }
53
+
54
+ /**
55
+ * Checks if the tab has to be hidden.
56
+ *
57
+ * @return bool
58
+ */
59
+ public function isHidden() {
60
+ return false;
61
+ }
62
+
63
+ /**
64
+ * Returns the order object.
65
+ *
66
+ * @return mixed
67
+ */
68
+ public function getOrder(){
69
+ return Mage::registry('current_order');
70
+ }
71
+
72
+ /**
73
+ * Returns return labels for current order.
74
+ *
75
+ * @return mixed
76
+ */
77
+ public function getReturnLabels(){
78
+ $returnlabels = Mage::getModel('dpd/returnlabels')->
79
+ getCollection()
80
+ ->addFieldToFilter('order_id',array('eq' => $this->getOrder()->getId()));
81
+ return $returnlabels;
82
+ }
83
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/Shipping/Carrier/Dpdclassic/Tablerate/Grid.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_Shipping_Carrier_Dpdclassic_Tablerate_Grid
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_Shipping_Carrier_Dpdclassic_Tablerate_Grid extends Mage_Adminhtml_Block_Widget_Grid
14
+ {
15
+ /**
16
+ * Website filter
17
+ *
18
+ * @var int
19
+ */
20
+ protected $_websiteId;
21
+
22
+ /**
23
+ * Condition filter
24
+ *
25
+ * @var string
26
+ */
27
+ protected $_conditionName;
28
+
29
+
30
+ /**
31
+ * Init the block.
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ $this->setId('shippingDpdclassicTablerateGrid');
37
+ $this->_exportPageSize = 10000;
38
+ }
39
+
40
+
41
+ /**
42
+ * Set website Id for export to global variable.
43
+ *
44
+ * @param $websiteId
45
+ * @return $this
46
+ */
47
+ public function setWebsiteId($websiteId)
48
+ {
49
+ $this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
50
+ return $this;
51
+ }
52
+
53
+
54
+ /**
55
+ * Fallback if website Id is not set in global variable.
56
+ *
57
+ * @return int|mixed
58
+ */
59
+ public function getWebsiteId()
60
+ {
61
+ if (is_null($this->_websiteId)) {
62
+ $this->_websiteId = Mage::app()->getWebsite()->getId();
63
+ }
64
+ return $this->_websiteId;
65
+ }
66
+
67
+
68
+ /**
69
+ * @param $name
70
+ * @return $this
71
+ */
72
+ public function setConditionName($name)
73
+ {
74
+ $this->_conditionName = $name;
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * @return string
80
+ */
81
+ public function getConditionName()
82
+ {
83
+ return $this->_conditionName;
84
+ }
85
+
86
+ /**
87
+ * @return Mage_Adminhtml_Block_Widget_Grid
88
+ */
89
+ protected function _prepareCollection()
90
+ {
91
+ $collection = Mage::getResourceModel('dpd/dpdclassic_tablerate_collection');
92
+ $collection->setConditionFilter($this->getConditionName())
93
+ ->setWebsiteFilter($this->getWebsiteId());
94
+
95
+ $this->setCollection($collection);
96
+
97
+ return parent::_prepareCollection();
98
+ }
99
+
100
+ /**
101
+ * @return $this
102
+ */
103
+ protected function _prepareColumns()
104
+ {
105
+ $this->addColumn('dest_country', array(
106
+ 'header' => Mage::helper('dpd')->__('Country'),
107
+ 'index' => 'dest_country',
108
+ 'default' => '*',
109
+ ));
110
+
111
+ $this->addColumn('dest_region', array(
112
+ 'header' => Mage::helper('dpd')->__('Region/State'),
113
+ 'index' => 'dest_region',
114
+ 'default' => '*',
115
+ ));
116
+
117
+ $this->addColumn('dest_zip', array(
118
+ 'header' => Mage::helper('dpd')->__('Zip/Postal Code'),
119
+ 'index' => 'dest_zip',
120
+ 'default' => '*',
121
+ ));
122
+
123
+ $label = Mage::getSingleton('shipping/carrier_tablerate')
124
+ ->getCode('condition_name_short', $this->getConditionName());
125
+ $this->addColumn('condition_value', array(
126
+ 'header' => $label,
127
+ 'index' => 'condition_value',
128
+ ));
129
+
130
+ $this->addColumn('price', array(
131
+ 'header' => Mage::helper('dpd')->__('Shipping Price'),
132
+ 'index' => 'price',
133
+ ));
134
+
135
+ return parent::_prepareColumns();
136
+ }
137
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/Shipping/Carrier/Dpdparcelshops/Tablerate/Grid.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_Shipping_Carrier_Dpdparcelshops_Tablerate_Grid
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_Shipping_Carrier_Dpdparcelshops_Tablerate_Grid extends Mage_Adminhtml_Block_Widget_Grid
14
+ {
15
+ /**
16
+ * Website filter
17
+ *
18
+ * @var int
19
+ */
20
+ protected $_websiteId;
21
+
22
+ /**
23
+ * Condition filter
24
+ *
25
+ * @var string
26
+ */
27
+ protected $_conditionName;
28
+
29
+
30
+ /**
31
+ *
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+ $this->setId('shippingDpdparcelshopsTablerateGrid');
37
+ $this->_exportPageSize = 10000;
38
+ }
39
+
40
+
41
+ /**
42
+ * @param $websiteId
43
+ * @return $this
44
+ */
45
+ public function setWebsiteId($websiteId)
46
+ {
47
+ $this->_websiteId = Mage::app()->getWebsite($websiteId)->getId();
48
+ return $this;
49
+ }
50
+
51
+
52
+ /**
53
+ * @return int|mixed
54
+ */
55
+ public function getWebsiteId()
56
+ {
57
+ if (is_null($this->_websiteId)) {
58
+ $this->_websiteId = Mage::app()->getWebsite()->getId();
59
+ }
60
+ return $this->_websiteId;
61
+ }
62
+
63
+
64
+ /**
65
+ * @param $name
66
+ * @return $this
67
+ */
68
+ public function setConditionName($name)
69
+ {
70
+ $this->_conditionName = $name;
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * @return string
76
+ */
77
+ public function getConditionName()
78
+ {
79
+ return $this->_conditionName;
80
+ }
81
+
82
+ /**
83
+ * @return Mage_Adminhtml_Block_Widget_Grid
84
+ */
85
+ protected function _prepareCollection()
86
+ {
87
+ $collection = Mage::getResourceModel('dpd/dpdparcelshops_tablerate_collection');
88
+ $collection->setConditionFilter($this->getConditionName())
89
+ ->setWebsiteFilter($this->getWebsiteId());
90
+
91
+ $this->setCollection($collection);
92
+
93
+ return parent::_prepareCollection();
94
+ }
95
+
96
+ /**
97
+ * @return $this
98
+ */
99
+ protected function _prepareColumns()
100
+ {
101
+ $this->addColumn('dest_country', array(
102
+ 'header' => Mage::helper('dpd')->__('Country'),
103
+ 'index' => 'dest_country',
104
+ 'default' => '*',
105
+ ));
106
+
107
+ $this->addColumn('dest_region', array(
108
+ 'header' => Mage::helper('dpd')->__('Region/State'),
109
+ 'index' => 'dest_region',
110
+ 'default' => '*',
111
+ ));
112
+
113
+ $this->addColumn('dest_zip', array(
114
+ 'header' => Mage::helper('dpd')->__('Zip/Postal Code'),
115
+ 'index' => 'dest_zip',
116
+ 'default' => '*',
117
+ ));
118
+
119
+ $label = Mage::getSingleton('shipping/carrier_tablerate')
120
+ ->getCode('condition_name_short', $this->getConditionName());
121
+ $this->addColumn('condition_value', array(
122
+ 'header' => $label,
123
+ 'index' => 'condition_value',
124
+ ));
125
+
126
+ $this->addColumn('price', array(
127
+ 'header' => Mage::helper('dpd')->__('Shipping Price'),
128
+ 'index' => 'price',
129
+ ));
130
+
131
+ return parent::_prepareColumns();
132
+ }
133
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/System/Config/Form/Availability.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_System_Config_Form_Availability
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_System_Config_Form_Availability extends Mage_Adminhtml_Block_System_Config_Form_Field
14
+ {
15
+
16
+ /**
17
+ * Construct the block and set the corresponding template.
18
+ */
19
+ protected function _construct()
20
+ {
21
+ parent::_construct();
22
+ $this->setTemplate('dpd/system/config/availability.phtml');
23
+ }
24
+
25
+ /**
26
+ * Return element html.
27
+ *
28
+ * @param Varien_Data_Form_Element_Abstract $element
29
+ * @return string
30
+ */
31
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
32
+ {
33
+ return $this->_toHtml();
34
+ }
35
+
36
+ /**
37
+ * Return ajax url for button.
38
+ *
39
+ * @return string
40
+ */
41
+ public function getAjaxCheckUrl()
42
+ {
43
+ return Mage::helper('adminhtml')->getUrl('adminhtml/dpdorder/check');
44
+ }
45
+
46
+ /**
47
+ * Check if there are any custom parcelshops for this website and return corresponding html.
48
+ *
49
+ * @return string
50
+ */
51
+ public function getAvailabilityHtml(){
52
+ if($this->getParcelshopsAvailableForThisWebsite() != 0){
53
+ return Mage::helper('dpd')->__("CSV Uploaded (%s shops). ", $this->getParcelshopsAvailableForThisWebsite());
54
+ }
55
+ else{
56
+ return Mage::helper('dpd')->__("No CSV uploaded.");
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Returns the size of the parcelshopcollection for this website.
62
+ *
63
+ * @return mixed
64
+ */
65
+ public function getParcelshopsAvailableForThisWebsite(){
66
+ $websiteId = $this->getWebsiteScopeId();
67
+ $collection = Mage::getModel('dpd/specialparcelshops')->getCollection()->addFieldToFilter('parcelshop_website_id', array('eq' => $websiteId));
68
+ return $collection->getSize();
69
+ }
70
+
71
+ /**
72
+ * Generate button html.
73
+ *
74
+ * @return string
75
+ */
76
+ public function getButtonHtml()
77
+ {
78
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
79
+ ->setData(array(
80
+ 'id' => 'dpd_button',
81
+ 'label' => $this->helper('adminhtml')->__('Delete'),
82
+ 'onclick' => 'javascript:check(); return false;'
83
+ ));
84
+
85
+ return $button->toHtml();
86
+ }
87
+
88
+ /**
89
+ * Get the website id for the selected scope in sysconfig.
90
+ *
91
+ * @return mixed
92
+ */
93
+ public function getWebsiteScopeId(){
94
+ return Mage::app()->getWebsite(Mage::app()->getRequest()->getParam('website'))->getId();
95
+ }
96
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/System/Config/Form/Dpdclassicexport.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_System_Config_Form_Dpdclassicexport
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_System_Config_Form_Dpdclassicexport extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
14
+ {
15
+ /**
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return mixed
18
+ */
19
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
20
+ {
21
+ $buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
22
+
23
+ $params = array(
24
+ 'website' => $buttonBlock->getRequest()->getParam('website')
25
+ );
26
+
27
+ $data = array(
28
+ 'label' => Mage::helper('adminhtml')->__('Export CSV'),
29
+ 'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/dpdconfig/exportDpdClassicTablerates", $params) . 'conditionName/\' + $(\'carriers_dpdclassic_condition_name\').value + \'/dpdclassictablerates.csv\' )',
30
+ 'class' => '',
31
+ 'id' => 'carriers_dpdclassic_export'
32
+ );
33
+
34
+ $html = $buttonBlock->setData($data)->toHtml();
35
+
36
+ return $html;
37
+ }
38
+ }
app/code/community/DPD/Shipping/Block/Adminhtml/System/Config/Form/Dpdparcelshopsexport.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Adminhtml_System_Config_Form_Dpdparcelshopsexport
12
+ */
13
+ class DPD_Shipping_Block_Adminhtml_System_Config_Form_Dpdparcelshopsexport extends Mage_Adminhtml_Block_System_Config_Form_Field implements Varien_Data_Form_Element_Renderer_Interface
14
+ {
15
+ /**
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return mixed
18
+ */
19
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
20
+ {
21
+ $buttonBlock = Mage::app()->getLayout()->createBlock('adminhtml/widget_button');
22
+
23
+ $params = array(
24
+ 'website' => $buttonBlock->getRequest()->getParam('website')
25
+ );
26
+
27
+ $data = array(
28
+ 'label' => Mage::helper('adminhtml')->__('Export CSV'),
29
+ 'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl("adminhtml/dpdconfig/exportDpdParcelshopsTablerates", $params) . 'conditionName/\' + $(\'carriers_dpdparcelshops_condition_name\').value + \'/dpdparcelshopstablerates.csv\' )',
30
+ 'class' => '',
31
+ 'id' => 'carriers_dpdparcelshops_export'
32
+ );
33
+
34
+ $html = $buttonBlock->setData($data)->toHtml();
35
+
36
+ return $html;
37
+ }
38
+ }
app/code/community/DPD/Shipping/Block/Carrier/Parcelshop.php ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Block_Carrier_Parcelshop
12
+ */
13
+ class DPD_Shipping_Block_Carrier_Parcelshop extends Mage_Core_Block_Template
14
+ {
15
+ /**
16
+ * Used to check if the url has to be shown or not. (click here to select..)
17
+ *
18
+ * @var
19
+ */
20
+ private $_showurl;
21
+ /**
22
+ * Array of all configdata to pass to javascript.
23
+ *
24
+ * @var array
25
+ */
26
+ private $_configArray = array();
27
+
28
+ /**
29
+ * Check if the url has to be shown or not. (click here to select..)
30
+ *
31
+ * @param $bool
32
+ */
33
+ public function setShowUrl($bool)
34
+ {
35
+ if ($bool && !Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_display'))
36
+ $this->_showurl = $bool;
37
+ return;
38
+ }
39
+
40
+ /**
41
+ * Returns showurl variable.
42
+ *
43
+ * @return mixed
44
+ */
45
+ public function getShowUrl()
46
+ {
47
+ return $this->_showurl;
48
+ }
49
+
50
+ /**
51
+ * Gets all parcelshops from dpd webservice based on shipping address.
52
+ *
53
+ * @return mixed
54
+ */
55
+ public function getParcelShops()
56
+ {
57
+ $coordinates = explode(',', Mage::Helper('dpd')->getGoogleMapsCenter());
58
+ $parcelshops = Mage::getSingleton('dpd/webservice')->getParcelShops($coordinates[1], $coordinates[0]);
59
+ return $parcelshops;
60
+ }
61
+
62
+ /**
63
+ * Get all config data to pass to javascript (array) and jsonencode.
64
+ *
65
+ * @return mixed
66
+ */
67
+ public function getConfig()
68
+ {
69
+ $center = explode(",", Mage::Helper('dpd')->getGoogleMapsCenter());
70
+ $this->_configArray["saveParcelUrl"] = $this->getUrl('dpd/ajax/saveparcel');
71
+ $this->_configArray["invalidateParcelUrl"] = $this->getUrl('dpd/ajax/invalidateparcel');
72
+ $this->_configArray["windowParcelUrl"] = $this->getUrl('dpd/ajax/windowindex');
73
+ $this->_configArray["ParcelUrl"] = $this->getUrl('dpd/ajax/index');
74
+ $this->_configArray["gmapsCenterlat"] = $center[0];
75
+ $this->_configArray["gmapsCenterlng"] = $center[1];
76
+ $this->_configArray["gmapsHeight"] = Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_height') . 'px';
77
+ $this->_configArray["loadingmessage"] = '<span class="message">'.$this->__('Loading DPD parcelshop map based on your address...').'</span>';
78
+ $this->_configArray["gmapsWidth"] = Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_width') . 'px';
79
+ $this->_configArray["gmapsIcon"] = Mage::getDesign()->getSkinUrl('images/dpd/icon_parcelshop.png');
80
+ $this->_configArray["gmapsIconShadow"] = Mage::getDesign()->getSkinUrl('images/dpd/icon_parcelshop_shadow.png');
81
+ $this->_configArray["gmapsCustomIcon"] = (Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_icon') ? Mage::getBaseUrl('media') . "dpd/" . Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_icon') : "");
82
+ $this->_configArray["gmapsDisplay"] = (bool)Mage::getStoreConfig('carriers/dpdparcelshops/google_maps_display');
83
+ $this->_configArray["loaderimage"] = $this->getSkinUrl('images/dpd/ajax-loader.gif');
84
+ return Mage::helper('core')->jsonEncode($this->_configArray);
85
+ }
86
+
87
+ /**
88
+ * Render the html to show all shops. (to keep template files clean from to much functional php)
89
+ *
90
+ * @return string
91
+ */
92
+ public function getShopsHtml()
93
+ {
94
+ $html = "";
95
+ $openinghours = "";
96
+ $counter = 0;
97
+ foreach ($this->getParcelShops()->parcelShop as $shop) {
98
+ $html .= '<div class="shop-data" id="shop' . $shop->parcelShopId . '">';
99
+ $html .= '<ul class="shop-details"><li><a href="#" id="' . $counter . '" class="show-info-bubble" /><strong>' . $shop->company . '</strong></a></li>';
100
+ $html .= '<li>' . $shop->street . " " . $shop->houseNo . '</li>';
101
+ $html .= '<li>' . $shop->zipCode . ' ' . $shop->city . '</li></ul>';
102
+ $html .= '<a id="shop' . $shop->parcelShopId . '" class="parcelshoplink" href="#">';
103
+ $html .= '<img src="' . Mage::getDesign()->getSkinUrl('images/dpd/icon_route.png') . '" alt="route" width="16" height="16" style="margin-right: 5px; margin-bottom:10px;">';
104
+ $html .= '<strong>' . Mage::helper('dpd')->__('Ship to this ParcelShop.') . '</strong>';
105
+ $html .= '</a>';
106
+ $html .= '</div>';
107
+ $this->_configArray['shop' . $shop->parcelShopId]['company'] = trim($shop->company);
108
+ $this->_configArray['shop' . $shop->parcelShopId]['houseno'] = $shop->street . " " . $shop->houseNo;
109
+ $this->_configArray['shop' . $shop->parcelShopId]['zipcode'] = $shop->zipCode;
110
+ $this->_configArray['shop' . $shop->parcelShopId]['city'] = $shop->city;
111
+ $this->_configArray['shop' . $shop->parcelShopId]['country'] = $shop->isoAlpha2;
112
+ $this->_configArray['shop' . $shop->parcelShopId]['parcelShopId'] = $shop->parcelShopId;
113
+ $this->_configArray['shop' . $shop->parcelShopId]['gmapsCenterlat'] = $shop->latitude;
114
+ $this->_configArray['shop' . $shop->parcelShopId]['gmapsCenterlng'] = $shop->longitude;
115
+ $this->_configArray['shop' . $shop->parcelShopId]['special'] = false;
116
+ $this->_configArray['shop' . $shop->parcelShopId]['extra_info'] = Mage::helper('core')->jsonEncode(array_filter(array(
117
+ 'Opening hours' => (isset($shop->openingHours) && $shop->openingHours != "" ? Mage::helper('core')->jsonEncode($shop->openingHours) : ''),
118
+ 'Telephone' => (isset($shop->phone) && $shop->phone != "" ? $shop->phone : ''),
119
+ 'Website' => (isset($shop->homepage) && $shop->homepage != "" ? '<a href="' . 'http://' . $shop->homepage . '" target="_blank">' . $shop->homepage . '</a>' : ''),
120
+ 'Extra info' => (isset($shop->extraInfo) && $shop->extraInfo != "" ? $shop->extraInfo : ''))));
121
+ $this->_configArray['shop' . $shop->parcelShopId]['gmapsMarkerContent'] = $this->_getMarkerHtml($shop, false);
122
+ $counter++;
123
+ }
124
+ if ($html) {
125
+ return $this->_getSpecialShopsHtml($html, $counter);
126
+ }
127
+ return $html;
128
+ }
129
+
130
+ /**
131
+ * Render the html for openinghours. (to keep template files clean from to much functional php)
132
+ *
133
+ * @param $dpdExtraInfo
134
+ * @return string
135
+ */
136
+ public function getOpeningHoursHtml($dpdExtraInfo)
137
+ {
138
+ $html = "";
139
+ if (is_array(json_decode($dpdExtraInfo))) {
140
+ foreach (json_decode($dpdExtraInfo) as $hours) {
141
+ $html .= '<ul class="daywrapper left">';
142
+ $html .= '<li class="day">' . Mage::helper('dpd')->__($hours->weekday) . '</li>';
143
+ if ($hours->openMorning != "") {
144
+ $html .= '<li class="hour">' . $hours->openMorning . ' - ' . $hours->closeMorning . '</li>';
145
+ } else {
146
+ $html .= '<li class="hour">' . Mage::helper('dpd')->__('closed') . '</li>';
147
+ }
148
+ if ($hours->openAfternoon != "") {
149
+ $html .= '<li class="hour">' . $hours->openAfternoon . ' - ' . $hours->closeAfternoon . '</li>';
150
+ } else {
151
+ $html .= '<li class="hour">' . Mage::helper('dpd')->__('closed') . '</li>';
152
+ }
153
+ $html .= '</ul>';
154
+ }
155
+ } else {
156
+ $html .= $dpdExtraInfo;
157
+ }
158
+ return $html;
159
+ }
160
+
161
+ /**
162
+ * Gets html for the custom shops if available.
163
+ *
164
+ * @param $html
165
+ * @param $counter
166
+ * @return bool|string
167
+ */
168
+ protected function _getSpecialShopsHtml($html, $counter)
169
+ {
170
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
171
+ $billingAddress = $quote->getBillingAddress();
172
+ $countryCode = $billingAddress->getCountryId();
173
+ $websiteId = Mage::app()->getWebsite()->getId();
174
+ $specialShopsCollection = Mage::getModel('dpd/specialparcelshops')->getCollection()->addFieldToFilter('parcelshop_country', array('eq' => $countryCode))->addFieldToFilter('parcelshop_website_id', array('eq' => $websiteId));
175
+
176
+ foreach ($specialShopsCollection as $specialShop) {
177
+ $html .= '<div class="shop-data" id="shop' . $specialShop->getParcelshopDelicomId() . '">';
178
+ if (Mage::getStoreConfig('carriers/dpdparcelshops/special_parcelshop_icon') != "") {
179
+ $html .= '<img class="specialparcelshopImage" height="50" width="50" src="' . Mage::getBaseUrl('media') . "dpd/" . Mage::getStoreConfig('carriers/dpdparcelshops/special_parcelshop_icon') . '"/>';
180
+ }
181
+ $html .= '<ul class="shop-details"><li><a href="#" id="' . $counter . '" class="show-info-bubble" /><strong>' . $specialShop->getParcelshopPudoName() . '</strong></a></li>';
182
+ $html .= '<li>' . $specialShop->getData('parcelshop_address_1') . '</li>';
183
+ $html .= '<li>' . $specialShop->getParcelshopPostCode() . ' ' . $specialShop->getParcelshopTown() . '</li></ul>';
184
+ $html .= '<a id="shop' . $specialShop->getParcelshopDelicomId() . '" class="parcelshoplink" href="#">';
185
+ $html .= '<img src="' . Mage::getDesign()->getSkinUrl('images/dpd/icon_route.png') . '" alt="route" width="16" height="16" style="margin-right: 5px; margin-bottom:10px;">';
186
+ $html .= '<strong>' . Mage::helper('dpd')->__('Ship to this ParcelShop.') . '</strong>';
187
+ $html .= '</a>';
188
+ $html .= '</div>';
189
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['company'] = trim($specialShop->getParcelshopPudoName());
190
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['houseno'] = $specialShop->getData('parcelshop_address_1');
191
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['zipcode'] = $specialShop->getParcelshopPostCode();
192
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['city'] = $specialShop->getParcelshopTown();
193
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['country'] = $specialShop->getParcelshopCountry();
194
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['parcelShopId'] = $specialShop->getParcelshopDelicomId();
195
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['gmapsCenterlat'] = $specialShop->getParcelshopLatitude();
196
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['gmapsCenterlng'] = $specialShop->getParcelshopLongitude();
197
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['specialImage'] = (Mage::getStoreConfig('carriers/dpdparcelshops/special_parcelshop_icon') != "" ? Mage::getBaseUrl('media') . "dpd/" . Mage::getStoreConfig('carriers/dpdparcelshops/special_parcelshop_icon') : "");
198
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['special'] = true;
199
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['extra_info'] = Mage::helper('core')->jsonEncode(array_filter(array(
200
+ 'Opening hours' => ($specialShop->getParcelshopOpeninghours() && $specialShop->getParcelshopOpeninghours() != "" ? $specialShop->getParcelshopOpeninghours() : ''),
201
+ 'Telephone' => "",
202
+ 'Website' => "",
203
+ 'Extra info' => "")));
204
+ $this->_configArray['shop' . $specialShop->getParcelshopDelicomId()]['gmapsMarkerContent'] = $this->_getMarkerHtml($specialShop, true);
205
+ $counter++;
206
+ }
207
+ return ($html == "" ? false : $html);
208
+ }
209
+
210
+ /**
211
+ * Gets html for the marker info bubbles.
212
+ *
213
+ * @param $shop
214
+ * @param $special
215
+ * @return string
216
+ */
217
+ protected function _getMarkerHtml($shop, $special)
218
+ {
219
+ if ($special && Mage::getStoreConfig('carriers/dpdparcelshops/special_parcelshop_icon')) {
220
+ $image = Mage::getBaseUrl('media') . "dpd/" . Mage::getStoreConfig('carriers/dpdparcelshops/special_parcelshop_icon');
221
+ } else {
222
+ $image = Mage::getDesign()->getSkinUrl('images/dpd/dpd_parcelshop_logo.png');
223
+ }
224
+ $html = '<div class="content">
225
+ <table style="min-width:250px" cellpadding="3" cellspacing="3" border="0">
226
+ <tbody>
227
+ <tr>
228
+ <td rowspan="3" width="90"><img class="parcelshoplogo bubble" style="width:80px; height:62px;" src="' . $image . '" alt="extrainfo"/></td>
229
+ <td><strong>' . ($special ? $shop->getParcelshopPudoName() : $shop->company) . '</strong></td>
230
+ </tr>
231
+ <tr>
232
+ <td>' . ($special ? $shop->getData('parcelshop_address_1') : $shop->street . " " . $shop->houseNo) . '</td>
233
+ </tr>
234
+ <tr>
235
+ <td>' . ($special ? $shop->getParcelshopPostCode() . ' ' . $shop->getParcelshopTown() : $shop->zipCode . ' ' . $shop->city) . '</td>
236
+ </tr>
237
+ </tbody>
238
+ </table>
239
+ <div class="dpdclear"></div>
240
+ ';
241
+
242
+
243
+ if (!$special && isset($shop->openingHours) && $shop->openingHours != "") {
244
+ $html .= '<div class="dotted-line">
245
+ <table>
246
+ <tbody>';
247
+ foreach ($shop->openingHours as $openinghours) {
248
+ $html .= '<tr><td style="padding-right:10px;"><strong>' . $openinghours->weekday . '</strong></td><td style="padding-right:10px;">' . $openinghours->openMorning . ' - ' . $openinghours->closeMorning . '
249
+ </td><td>' . $openinghours->openAfternoon . ' - ' . $openinghours->closeAfternoon . '</td></tr>';
250
+ }
251
+ $html .= '</tbody>
252
+ </table>
253
+ </div><div class="dpdclear"></div>';
254
+ }
255
+ elseif($special && $shop->getParcelshopOpeninghours() && $shop->getParcelshopOpeninghours()!=""){
256
+
257
+ $html .= '<div class="dotted-line">
258
+ <table>
259
+ <tbody>';
260
+ foreach (Mage::helper('core')->jsonDecode($shop->getParcelshopOpeninghours()) as $openinghours) {
261
+
262
+ $html .= '<tr><td style="padding-right:10px;"><strong>' . $openinghours['weekday'] . '</strong></td><td style="padding-right:10px;">' . $openinghours['openMorning'] . ' - ' . $openinghours['closeMorning'] . '
263
+ </td><td>' . $openinghours['openAfternoon'] . ' - ' . $openinghours['closeAfternoon'] . '</td></tr>';
264
+ }
265
+ $html .= '</tbody>
266
+ </table>
267
+ </div><div class="dpdclear"></div>';
268
+ }
269
+
270
+
271
+ $html .= '<div class="dotted-line">
272
+ <table>
273
+ <tbody>
274
+ <tr class="pointer">
275
+ <td id="' . 'shop' . ($special ? $shop->getParcelshopDelicomId() : $shop->parcelShopId) . '" class="parcelshoplink" onclick="window.dpdShipping.saveParcelShop(event);" style="width: 25px;"><img src="' . Mage::getDesign()->getSkinUrl('images/dpd/icon_route.png') . '" alt="route" width="16" height="16" ></td>
276
+ <td id="' . 'shop' . ($special ? $shop->getParcelshopDelicomId() : $shop->parcelShopId) . '" class="parcelshoplink" onclick="window.dpdShipping.saveParcelShop(event);"><strong>' . Mage::helper('dpd')->__('Ship to this ParcelShop.') . '</strong></td>
277
+ </tr>
278
+ </tbody>
279
+ </table>
280
+ </div></div><div class="dpdclear"></div>';
281
+ return $html;
282
+ }
283
+
284
+ /**
285
+ * Returns quote object.
286
+ *
287
+ * @return mixed
288
+ */
289
+ public function getQuote()
290
+ {
291
+ return Mage::getModel('checkout/cart')->getQuote();
292
+ }
293
+
294
+ }
app/code/community/DPD/Shipping/Helper/Data.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Helper_Data
12
+ */
13
+ class DPD_Shipping_Helper_Data extends Mage_Core_Helper_Abstract
14
+ {
15
+ /**
16
+ * Sets default shipping method when selected in admin.
17
+ *
18
+ * @param $html
19
+ * @return mixed
20
+ */
21
+ public function checkShippingDefault($html)
22
+ {
23
+ if ((Mage::getStoreConfig('carriers/dpdclassic/default') &&
24
+ Mage::getStoreConfig('carriers/dpdclassic/sort_order') <= Mage::getStoreConfig('carriers/dpdparcelshops/sort_order')) ||
25
+ (Mage::getStoreConfig('carriers/dpdclassic/default') && !Mage::getStoreConfig('carriers/dpdparcelshops/default'))
26
+ ) {
27
+ $html = $this->_selectNode($html, 's_method_dpdclassic_dpdclassic');
28
+ } elseif (Mage::getStoreConfig('carriers/dpdparcelshops/default')) {
29
+ $html = $this->_selectNode($html, 's_method_dpdparcelshops_dpdparcelshops');
30
+ }
31
+ return $html;
32
+ }
33
+
34
+ /**
35
+ * Selects the radiobutton for default selected shipping method.
36
+ *
37
+ * @param $html
38
+ * @param $node
39
+ * @return mixed
40
+ */
41
+ protected function _selectNode($html, $node)
42
+ {
43
+ preg_match('(<input[^>]+id="' . $node . '"[^>]+>)', $html, $matches);
44
+ if (isset($matches[0])) {
45
+ $checked = str_replace('/>', ' checked="checked" />', $matches[0]);
46
+ $html = str_replace($matches[0],
47
+ $checked, $html);
48
+ }
49
+ return $html;
50
+ }
51
+
52
+ /**
53
+ * Adds custom html to parcelshops shipping method.
54
+ *
55
+ * @param $html
56
+ * @return mixed
57
+ */
58
+ public function addHTML($html)
59
+ {
60
+ $quote = Mage::getModel('checkout/cart')->getQuote();
61
+ $block = Mage::app()->getLayout()->createBlock('dpd/carrier_parcelshop');
62
+ $block->setShowUrl(true);
63
+ preg_match('!<label for="(.*?)parcelshops">(.*?)<\/label>!', $html, $matches);
64
+ if (isset($matches[0])) {
65
+ if ($quote->getDpdSelected()) {
66
+ $html = str_replace($matches[0],
67
+ $matches[0] . '<div id="dpd">' . $block->setTemplate('dpd/parcelshopselected.phtml')->toHtml() . '</div>',
68
+ $html);
69
+ } else {
70
+ $html = str_replace($matches[0],
71
+ $matches[0] . '<div id="dpd">' . $block->setTemplate('dpd/parcelshoplink.phtml')->toHtml() . '</div>',
72
+ $html);
73
+ }
74
+ }
75
+ return $html;
76
+ }
77
+
78
+ /**
79
+ * Returns shipping address lat lng.
80
+ *
81
+ * @return string
82
+ */
83
+ public function getGoogleMapsCenter()
84
+ {
85
+ $address = Mage::getModel('checkout/cart')->getQuote()->getShippingAddress();
86
+ $addressToInsert = $address->getStreet(1) . " ";
87
+ if ($address->getStreet(2)) {
88
+ $addressToInsert .= $address->getStreet(2) . " ";
89
+ }
90
+ $addressToInsert .= $address->getPostcode() . " " . $address->getCity() . " " . $address->getCountry();
91
+ $url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($addressToInsert) . '&sensor=false';
92
+ $source = file_get_contents($url);
93
+ $obj = json_decode($source);
94
+ $LATITUDE = $obj->results[0]->geometry->location->lat;
95
+ $LONGITUDE = $obj->results[0]->geometry->location->lng;
96
+ return $LATITUDE . ',' . $LONGITUDE;
97
+ }
98
+
99
+ /**
100
+ * Logs bugs/info.
101
+ * Zend_Log::DEBUG = 7
102
+ * Zend_Log::ERR = 3
103
+ * Zend_Log::INFO = 6
104
+ *
105
+ * @param $message
106
+ * @param $level
107
+ */
108
+ public function log($message,$level){
109
+ $allowedLogLevel = Mage::getStoreConfig('carriers/dpdparcelshops/log_level');
110
+ if($level <= $allowedLogLevel){
111
+ Mage::log($message,$level,'dpd.log');
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Creates new IO object and inputs base 64 pdf string fetched from webservice.
117
+ *
118
+ * @param $pdfString
119
+ * @param $folder
120
+ * @param $name
121
+ */
122
+ public function generatePdfAndSave($pdfString, $folder, $name){
123
+ $io = new Varien_Io_File();
124
+ $io->setAllowCreateFolders(true);
125
+ $io->open(array('path' => Mage::getBaseDir('media')."/dpd/".$folder));
126
+ $io->streamOpen($name.'.pdf', 'w+');
127
+ $io->streamLock(true);
128
+ $io->streamWrite($pdfString);
129
+ $io->streamUnlock();
130
+ $io->streamClose();
131
+ }
132
+
133
+ /**
134
+ * True if the current version of Magento is Enterprise Edition.
135
+ *
136
+ * @return bool
137
+ */
138
+ public function isMageEnterprise() {
139
+ return Mage::getConfig()->getModuleConfig('Enterprise_Enterprise') && Mage::getConfig()->getModuleConfig('Enterprise_AdminGws') && Mage::getConfig()->getModuleConfig('Enterprise_Checkout') && Mage::getConfig()->getModuleConfig('Enterprise_Customer');
140
+ }
141
+
142
+ /**
143
+ * Returns the language based on storeId.
144
+ *
145
+ * @param $storeId
146
+ * @return string language
147
+ */
148
+ public function getLanguageFromStore($storeId)
149
+ {
150
+ $locale = Mage::app()->getStore($storeId)->getConfig('general/locale/code');
151
+ $localeCode = explode('_' , $locale);
152
+
153
+ return strtoupper($localeCode[0]);
154
+ }
155
+
156
+ /**
157
+ * Calculates total weight of a shipment.
158
+ *
159
+ * @param $shipment
160
+ * @return int
161
+ */
162
+ public function calculateTotalShippingWeight($shipment){
163
+ $weight = 0;
164
+ $shipmentItems = $shipment->getAllItems();
165
+ foreach ($shipmentItems as $shipmentItem) {
166
+ $weight = $weight + $shipmentItem->getWeight();
167
+ }
168
+
169
+ return $weight;
170
+ }
171
+ }
app/code/community/DPD/Shipping/Model/Adminhtml/Dpdgrid.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Adminhtml_DpdGrid
12
+ */
13
+ class DPD_Shipping_Model_Adminhtml_Dpdgrid extends Mage_Core_Model_Abstract
14
+ {
15
+
16
+ /**
17
+ * Generates and completes an order, reference: generateAndCompleteAction.
18
+ *
19
+ * @param $orderId
20
+ * @return $this
21
+ */
22
+ public function generateAndCompleteOrder($orderId)
23
+ {
24
+ $order = Mage::getModel('sales/order')->load($orderId);
25
+ $shipmentCollection = $order->getShipmentsCollection();
26
+ if ($shipmentCollection->count() > 0 && !$order->getDpdLabelExists()) {
27
+ $dpdused = false;
28
+ foreach ($shipmentCollection as $shipment) {
29
+ foreach ($shipment->getAllTracks() as $tracker) {
30
+ if (strpos($tracker->getCarrierCode(), 'dpd') !== false) {
31
+ $labelName = $this->_generateLabelAndReturnLabel($order, $shipment);
32
+ if (!$labelName) {
33
+ $message = Mage::helper('dpd')->__("Something went wrong while processing order %s, please check your error logs.", $order->getIncrementId());
34
+ Mage::getSingleton('core/session')->addError($message);
35
+ continue;
36
+ } else {
37
+ $dpdused = true;
38
+ $locale = Mage::app()->getStore($order->getStoreId())->getConfig('general/locale/code');
39
+ $localeCode = explode('_', $locale);
40
+ $shipment->setDpdLabelPath($labelName . ".pdf");
41
+ $shipment->setDpdTrackingUrl('<a target="_blank" href="' . "http://tracking.dpd.de/cgi-bin/delistrack?typ=32&lang=" . $localeCode[0] . "&pknr=" . $labelName . "&var=" . Mage::getStoreConfig('shipping/dpd_classic/userid') . '">' . Mage::helper('dpd')->__('Track this shipment') . '</a>');
42
+ $tracker->setData('number', $labelName);
43
+ $transactionSave = Mage::getModel('core/resource_transaction')
44
+ ->addObject($shipment)
45
+ ->addObject($tracker)
46
+ ->save();
47
+ }
48
+ }
49
+ }
50
+ }
51
+ if ($dpdused) {
52
+ $order->addStatusHistoryComment(Mage::helper('dpd')->__('Shipped with DPD generateLabelAndComplete'), true);
53
+ $order->setDpdLabelExists(1);
54
+ $order->save();
55
+ return true;
56
+ } else {
57
+ $message = Mage::helper('dpd')->__("The order with id %s has only none DPD shipments.", $order->getIncrementId());
58
+ Mage::getSingleton('core/session')->addNotice($message);
59
+ return false;
60
+ }
61
+ } elseif (!$order->getDpdLabelExists()) {
62
+ $shipment = $order->prepareShipment();
63
+ $shipment->register();
64
+ $weight = Mage::helper('dpd')->calculateTotalShippingWeight($shipment);
65
+ $shipment->setTotalWeight($weight);
66
+ $labelName = $this->_generateLabelAndReturnLabel($order, $shipment);
67
+ if (!$labelName) {
68
+ $message = Mage::helper('dpd')->__("Something went wrong while processing order %s, please check your error logs.", $order->getIncrementId());
69
+ Mage::getSingleton('core/session')->addError($message);
70
+ return false;
71
+ } else {
72
+ $explodeForCarrier = explode('_', $order->getShippingMethod(), 3);
73
+ $locale = Mage::app()->getStore($order->getStoreId())->getConfig('general/locale/code');
74
+ $localeCode = explode('_', $locale);
75
+ $shipment->setDpdLabelPath($labelName . ".pdf");
76
+ $shipment->setDpdTrackingUrl('<a target="_blank" href="' . "http://tracking.dpd.de/cgi-bin/delistrack?typ=32&lang=" . $localeCode[0] . "&pknr=" . $labelName . "&var=" . Mage::getStoreConfig('shipping/dpd_classic/userid') . '">' . Mage::helper('dpd')->__('Track this shipment') . '</a>');
77
+ $order->setIsInProcess(true);
78
+ $order->addStatusHistoryComment(Mage::helper('dpd')->__('Shipped with DPD generateLabelAndComplete'), true);
79
+ $order->setDpdLabelExists(1);
80
+ $tracker = Mage::getModel('sales/order_shipment_track')
81
+ ->setShipment($shipment)
82
+ ->setData('title', 'DPD')
83
+ ->setData('number', $labelName)
84
+ ->setData('carrier_code', $explodeForCarrier[0])
85
+ ->setData('order_id', $shipment->getData('order_id'));
86
+ $transactionSave = Mage::getModel('core/resource_transaction')
87
+ ->addObject($shipment)
88
+ ->addObject($shipment->getOrder())
89
+ ->addObject($tracker)
90
+ ->save();
91
+ return true;
92
+ }
93
+ } else {
94
+ $message = Mage::helper('dpd')->__("The order with id %s is not ready to be shipped or has already been shipped.", $order->getIncrementId());
95
+ Mage::getSingleton('core/session')->addNotice($message);
96
+ return false;
97
+ }
98
+ return $this;
99
+ }
100
+
101
+ /**
102
+ * Generates a shipment label and saves it on the harddisk.
103
+ *
104
+ * @param $order
105
+ * @param $shipment
106
+ * @return mixed
107
+ */
108
+ protected function _generateLabelAndReturnLabel($order, $shipment)
109
+ {
110
+ $parcelshop = false;
111
+ $billingAddress = $order->getBillingAddress();
112
+ $recipient = array(
113
+ 'name1' => $billingAddress->getFirstname() . " " . $billingAddress->getLastname(),
114
+ 'street' => $billingAddress->getStreet(1) . " " . $billingAddress->getStreet(2),
115
+ 'country' => $billingAddress->getCountry(),
116
+ 'zipCode' => $billingAddress->getPostcode(),
117
+ 'city' => $billingAddress->getCity()
118
+ );
119
+ if (strpos($order->getShippingMethod(), 'parcelshop') !== false) {
120
+ $parcelshop = true;
121
+ }
122
+ $labelWebserviceCallback = Mage::getSingleton('dpd/webservice')->getShippingLabel($recipient, $order, $shipment, $parcelshop);
123
+
124
+ if ($labelWebserviceCallback) {
125
+ Mage::helper('dpd')->generatePdfAndSave($labelWebserviceCallback->parcellabelsPDF, 'orderlabels', $order->getIncrementId(). "-" .$labelWebserviceCallback->shipmentResponses->parcelInformation->parcelLabelNumber);
126
+ return $order->getIncrementId(). "-" .$labelWebserviceCallback->shipmentResponses->parcelInformation->parcelLabelNumber;
127
+ } else {
128
+ return false;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Processes the undownloadable labels. (set mark and zip)
134
+ *
135
+ * @param $orderIds
136
+ * @return bool|string
137
+ */
138
+ public function processUndownloadedLabels($orderIds)
139
+ {
140
+ $labelPdfArray = array();
141
+ $i = 0;
142
+ $err = false;
143
+ foreach ($orderIds as $orderId) {
144
+ $order = Mage::getModel('sales/order')->load($orderId);
145
+ $exported = false;
146
+ if (!$order->getDpdLabelExported()) {
147
+ $shippingCollection = Mage::getResourceModel('sales/order_shipment_collection')
148
+ ->setOrderFilter($order)
149
+ ->load();
150
+ if (count($shippingCollection)) {
151
+ foreach ($shippingCollection as $shipment) {
152
+ if ($shipment->getDpdLabelPath() != "" && file_exists(Mage::getBaseDir('media') . "/dpd/orderlabels/" . $shipment->getDpdLabelPath()) && $shipment->getDpdLabelPath() != ".pdf") {
153
+ $labelPdfArray[] = Mage::getBaseDir('media') . "/dpd/orderlabels/" . $shipment->getDpdLabelPath();
154
+ $exported = true;
155
+ }
156
+ }
157
+ if ($exported) {
158
+ $order->setDpdLabelExported(1)->save();
159
+ }
160
+ }
161
+ } else {
162
+ $i++;
163
+ }
164
+ }
165
+ if (!count($labelPdfArray)) {
166
+ return false;
167
+ }
168
+ if ($i > 0) {
169
+ $message = Mage::helper('dpd')->__('%s orders already had downloaded labels.', $i);
170
+ Mage::getSingleton('core/session')->addNotice($message);
171
+ } else {
172
+ $message = Mage::helper('dpd')->__('All labels have been downloaded.');
173
+ Mage::getSingleton('core/session')->addSuccess($message);
174
+ }
175
+ return $this->_zipLabelPdfArray($labelPdfArray, Mage::getBaseDir('media') . "/dpd/orderlabels/undownloaded.zip", true);
176
+ }
177
+
178
+ /**
179
+ * Zips the labels.
180
+ *
181
+ * @param array $files
182
+ * @param string $destination
183
+ * @param bool $overwrite
184
+ * @return bool|string
185
+ */
186
+ protected function _zipLabelPdfArray($files = array(), $destination = '', $overwrite = false)
187
+ {
188
+ if (file_exists($destination) && !$overwrite) {
189
+ return false;
190
+ }
191
+ $valid_files = array();
192
+ if (is_array($files)) {
193
+ foreach ($files as $file) {
194
+ if (file_exists($file)) {
195
+ $valid_files[] = $file;
196
+ }
197
+ }
198
+ }
199
+ if (count($valid_files)) {
200
+ $zip = new ZipArchive();
201
+ if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) {
202
+ return false;
203
+ }
204
+ foreach ($valid_files as $file) {
205
+ $zip->addFile($file, basename($file));
206
+ }
207
+ $zip->close();
208
+
209
+ return $destination;
210
+ } else {
211
+ return false;
212
+ }
213
+ }
214
+
215
+ }
app/code/community/DPD/Shipping/Model/Adminhtml/System/Config/Backend/Shipping/Dpdclassic/Tablerate.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Adminhtml_System_Config_Backend_Shipping_Dpdclassic_Tablerate
12
+ */
13
+ class DPD_Shipping_Model_Adminhtml_System_Config_Backend_Shipping_Dpdclassic_Tablerate extends Mage_Core_Model_Config_Data
14
+ {
15
+ /**
16
+ * Call the uploadAndImport function from the classic tablerate recourcemodel.
17
+ */
18
+ public function _afterSave()
19
+ {
20
+ Mage::getResourceModel('dpd/dpdclassic_tablerate')->uploadAndImport($this);
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/Adminhtml/System/Config/Backend/Shipping/Dpdparcelshops/Tablerate.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Adminhtml_System_Config_Backend_Shipping_Dpdparcelshops_Tablerate
12
+ */
13
+ class DPD_Shipping_Model_Adminhtml_System_Config_Backend_Shipping_Dpdparcelshops_Tablerate extends Mage_Core_Model_Config_Data
14
+ {
15
+ /**
16
+ * Call the uploadAndImport function from the parcelshops tablerate recourcemodel.
17
+ */
18
+ public function _afterSave()
19
+ {
20
+ Mage::getResourceModel('dpd/dpdparcelshops_tablerate')->uploadAndImport($this);
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/Adminhtml/System/Config/Backend/Shipping/Specialparcelshops.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_System_Config_Backend_Shipping_Specialparcelshops
12
+ */
13
+ class DPD_Shipping_Model_Adminhtml_System_Config_Backend_Shipping_Specialparcelshops extends Mage_Core_Model_Config_Data
14
+ {
15
+ /**
16
+ * Call the uploadAndImport function from the parcelshops recoursemodel.
17
+ */
18
+ public function _afterSave()
19
+ {
20
+ Mage::getResourceModel('dpd/specialparcelshops')->uploadAndImport($this);
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/Carrier/Dpdclassic.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Carrier_Dpdclassic
12
+ */
13
+ class DPD_Shipping_Model_Carrier_Dpdclassic extends Mage_Shipping_Model_Carrier_Abstract
14
+ implements Mage_Shipping_Model_Carrier_Interface
15
+ {
16
+ /**
17
+ * Shipping method code.
18
+ *
19
+ * @var string
20
+ */
21
+ protected $_code = 'dpdclassic';
22
+
23
+ /**
24
+ * Collect shipping method price and set all data selected in config.
25
+ *
26
+ * @param Mage_Shipping_Model_Rate_Request $request
27
+ * @return bool|false|Mage_Core_Model_Abstract
28
+ */
29
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
30
+ {
31
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
32
+ return false;
33
+ }
34
+ $method = Mage::getModel('shipping/rate_result_method');
35
+ $result = Mage::getModel('shipping/rate_result');
36
+ if (!$this->getConfigData('ratetype')) {
37
+ $price = $this->getConfigData('flatrateprice');
38
+ if ($request->getFreeShipping() === true) {
39
+ $price = 0;
40
+ }
41
+ } else {
42
+ $freeQty = 0;
43
+ if ($request->getAllItems()) {
44
+ $freePackageValue = 0;
45
+ foreach ($request->getAllItems() as $item) {
46
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
47
+ continue;
48
+ }
49
+
50
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
51
+ foreach ($item->getChildren() as $child) {
52
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
53
+ $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
54
+ $freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
55
+ }
56
+ }
57
+ } elseif ($item->getFreeShipping()) {
58
+ $freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
59
+ $freeQty += $item->getQty() - $freeShipping;
60
+ $freePackageValue += $item->getBaseRowTotal();
61
+ }
62
+ }
63
+ $oldValue = $request->getPackageValue();
64
+ $request->setPackageValue($oldValue - $freePackageValue);
65
+ }
66
+
67
+ if ($freePackageValue) {
68
+ $request->setPackageValue($request->getPackageValue() - $freePackageValue);
69
+ }
70
+
71
+ $conditionName = $this->getConfigData('condition_name');
72
+ $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
73
+
74
+ $oldWeight = $request->getPackageWeight();
75
+ $oldQty = $request->getPackageQty();
76
+
77
+ $request->setPackageWeight($request->getFreeMethodWeight());
78
+ $request->setPackageQty($oldQty - $freeQty);
79
+
80
+ $rate = $this->getRate($request);
81
+ $request->setPackageWeight($oldWeight);
82
+ $request->setPackageQty($oldQty);
83
+
84
+ if (!empty($rate) && $rate['price'] >= 0) {
85
+ if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
86
+ $price = 0;
87
+ } else {
88
+ $price = $rate['price'];
89
+ }
90
+ } elseif (empty($rate) && $request->getFreeShipping() === true) {
91
+ $request->setPackageValue($freePackageValue);
92
+ $request->setPackageQty($freeQty);
93
+ $rate = $this->getRate($request);
94
+ if (!empty($rate) && $rate['price'] >= 0) {
95
+ $price = 0;
96
+ }
97
+ } else {
98
+ $error = Mage::getModel('shipping/rate_result_error');
99
+ $error->setCarrier($this->_code);
100
+ $error->setCarrierTitle($this->getConfigData('title'));
101
+ $error->setErrorMessage(Mage::helper('dpd')->__('This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.'));
102
+ $result->append($error);
103
+ return $result;
104
+ }
105
+
106
+ }
107
+ $method->setCarrier($this->_code);
108
+ $method->setMethod($this->_code);
109
+ $method->setMethodTitle($this->getConfigData('name'));
110
+ $method->setCarrierTitle($this->getConfigData('carrier'));
111
+ $method->setPrice($price);
112
+ $method->setCost($price);
113
+ $result->append($method);
114
+ return $result;
115
+ }
116
+
117
+ /**
118
+ * Add this method to list of allowed methods so Magento can display it.
119
+ *
120
+ * @return array
121
+ */
122
+ public function getAllowedMethods()
123
+ {
124
+ return array('classic' => $this->getConfigData('name'));
125
+ }
126
+
127
+ /**
128
+ * Get tracking result object.
129
+ *
130
+ * @param string $tracking_number
131
+ * @return Mage_Shipping_Model_Tracking_Result $tracking_result
132
+ */
133
+ public function getTrackingInfo($tracking_number)
134
+ {
135
+ $tracking_result = $this->getTracking($tracking_number);
136
+
137
+ if ($tracking_result instanceof Mage_Shipping_Model_Tracking_Result) {
138
+ $trackings = $tracking_result->getAllTrackings();
139
+ if (is_array($trackings) && count($trackings) > 0) {
140
+ return $trackings[0];
141
+ }
142
+ }
143
+ return false;
144
+ }
145
+
146
+ /**
147
+ * Get tracking Url.
148
+ *
149
+ * @param string $tracking_number
150
+ * @return Mage_Shipping_Model_Tracking_Result
151
+ */
152
+ public function getTracking($tracking_number)
153
+ {
154
+ $tracking_result = Mage::getModel('shipping/tracking_result');
155
+ $tracking_status = Mage::getModel('shipping/tracking_result_status');
156
+ $localeExploded = explode('_', Mage::app()->getLocale()->getLocaleCode());
157
+ $tracking_status->setCarrier($this->_code);
158
+ $tracking_status->setCarrierTitle($this->getConfigData('title'));
159
+ $tracking_status->setTracking($tracking_number);
160
+ $tracking_status->addData(
161
+ array(
162
+ 'status' => '<a target="_blank" href="' . "http://tracking.dpd.de/cgi-bin/delistrack?typ=32&lang=" . $localeExploded[0] . "&pknr=" . $tracking_number . "&var=" . Mage::getStoreConfig('shipping/dpdclassic/userid') . '">' . Mage::helper('dpd')->__('Track this shipment') . '</a>'
163
+ )
164
+ );
165
+ $tracking_result->append($tracking_status);
166
+
167
+ return $tracking_result;
168
+ }
169
+
170
+ /**
171
+ * Make tracking available for dpd shippingmethods.
172
+ *
173
+ * @return bool
174
+ */
175
+ public function isTrackingAvailable()
176
+ {
177
+ return true;
178
+ }
179
+
180
+ /**
181
+ * Make shippinglabels not available as we provided our own method.
182
+ *
183
+ * @return bool
184
+ */
185
+ public function isShippingLabelsAvailable()
186
+ {
187
+ return false;
188
+ }
189
+
190
+ /**
191
+ * Get the rateobject from our resource model.
192
+ *
193
+ * @param $request
194
+ * @return mixed
195
+ */
196
+ public function getRate($request)
197
+ {
198
+ return Mage::getResourceModel('dpd/dpdclassic_tablerate')->getRate($request);
199
+ }
200
+ }
app/code/community/DPD/Shipping/Model/Carrier/Dpdparcelshops.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Carrier_Dpdparcelshops
12
+ */
13
+ class DPD_Shipping_Model_Carrier_Dpdparcelshops extends Mage_Shipping_Model_Carrier_Abstract
14
+ implements Mage_Shipping_Model_Carrier_Interface
15
+ {
16
+ /**
17
+ * Shipping method code.
18
+ *
19
+ * @var string
20
+ */
21
+ protected $_code = 'dpdparcelshops';
22
+
23
+ /**
24
+ * Collect shipping method price and set all data selected in config.
25
+ *
26
+ * @param Mage_Shipping_Model_Rate_Request $request
27
+ * @return bool|false|Mage_Core_Model_Abstract
28
+ */
29
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
30
+ {
31
+ $quote = Mage::getSingleton('checkout/cart')->getQuote();
32
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active') || Mage::app()->getStore()->isAdmin() || !Mage::getSingleton('dpd/webservice')->getLoginResult() || $quote->getData('is_multi_shipping')) {
33
+ return false;
34
+ }
35
+
36
+ $method = Mage::getModel('shipping/rate_result_method');
37
+ $result = Mage::getModel('shipping/rate_result');
38
+ if (!$this->getConfigData('ratetype')) {
39
+ $price = $this->getConfigData('flatrateprice');
40
+ if ($request->getFreeShipping() === true) {
41
+ $price = 0;
42
+ }
43
+ } else {
44
+ $freeQty = 0;
45
+ if ($request->getAllItems()) {
46
+ $freePackageValue = 0;
47
+ foreach ($request->getAllItems() as $item) {
48
+ if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
49
+ continue;
50
+ }
51
+
52
+ if ($item->getHasChildren() && $item->isShipSeparately()) {
53
+ foreach ($item->getChildren() as $child) {
54
+ if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
55
+ $freeShipping = is_numeric($child->getFreeShipping()) ? $child->getFreeShipping() : 0;
56
+ $freeQty += $item->getQty() * ($child->getQty() - $freeShipping);
57
+ }
58
+ }
59
+ } elseif ($item->getFreeShipping()) {
60
+ $freeShipping = is_numeric($item->getFreeShipping()) ? $item->getFreeShipping() : 0;
61
+ $freeQty += $item->getQty() - $freeShipping;
62
+ $freePackageValue += $item->getBaseRowTotal();
63
+ }
64
+ }
65
+ $oldValue = $request->getPackageValue();
66
+ $request->setPackageValue($oldValue - $freePackageValue);
67
+ }
68
+
69
+ if ($freePackageValue) {
70
+ $request->setPackageValue($request->getPackageValue() - $freePackageValue);
71
+ }
72
+
73
+ $conditionName = $this->getConfigData('condition_name');
74
+ $request->setConditionName($conditionName ? $conditionName : $this->_default_condition_name);
75
+
76
+ $oldWeight = $request->getPackageWeight();
77
+ $oldQty = $request->getPackageQty();
78
+
79
+ $request->setPackageWeight($request->getFreeMethodWeight());
80
+ $request->setPackageQty($oldQty - $freeQty);
81
+
82
+ $rate = $this->getRate($request);
83
+
84
+ $request->setPackageWeight($oldWeight);
85
+ $request->setPackageQty($oldQty);
86
+
87
+ if (!empty($rate) && $rate['price'] >= 0) {
88
+ if ($request->getFreeShipping() === true || ($request->getPackageQty() == $freeQty)) {
89
+ $price = 0;
90
+ } else {
91
+ $price = $rate['price'];
92
+ }
93
+ } elseif (empty($rate) && $request->getFreeShipping() === true) {
94
+ $request->setPackageValue($freePackageValue);
95
+ $request->setPackageQty($freeQty);
96
+ $rate = $this->getRate($request);
97
+ if (!empty($rate) && $rate['price'] >= 0) {
98
+ $price = 0;
99
+ }
100
+ } else {
101
+ $error = Mage::getModel('shipping/rate_result_error');
102
+ $error->setCarrier($this->_code);
103
+ $error->setCarrierTitle($this->getConfigData('title'));
104
+ $error->setErrorMessage(Mage::helper('dpd')->__('This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us.'));
105
+ $result->append($error);
106
+ return $result;
107
+ }
108
+
109
+ }
110
+ $method->setCarrier($this->_code);
111
+ $method->setMethod($this->_code);
112
+ $method->setMethodTitle($this->getConfigData('name'));
113
+ $method->setCarrierTitle($this->getConfigData('carrier'));
114
+ $method->setPrice($price);
115
+ $method->setCost($price);
116
+ $result->append($method);
117
+
118
+ return $result;
119
+ }
120
+
121
+ /**
122
+ * Add this shipping method to list of allowed methods so Magento can display it.
123
+ *
124
+ * @return array
125
+ */
126
+ public function getAllowedMethods()
127
+ {
128
+ return array('dpdparcelshops' => $this->getConfigData('name'));
129
+ }
130
+
131
+ /**
132
+ * Get tracking result object.
133
+ *
134
+ * @param string $tracking_number
135
+ * @return Mage_Shipping_Model_Tracking_Result $tracking_result
136
+ */
137
+ public function getTrackingInfo($tracking_number)
138
+ {
139
+ $tracking_result = $this->getTracking($tracking_number);
140
+
141
+ if ($tracking_result instanceof Mage_Shipping_Model_Tracking_Result) {
142
+ $trackings = $tracking_result->getAllTrackings();
143
+ if (is_array($trackings) && count($trackings) > 0) {
144
+ return $trackings[0];
145
+ }
146
+ }
147
+ return false;
148
+ }
149
+
150
+ /**
151
+ * Get tracking Url.
152
+ *
153
+ * @param string $tracking_number
154
+ * @return Mage_Shipping_Model_Tracking_Result
155
+ */
156
+ public function getTracking($tracking_number)
157
+ {
158
+ $tracking_result = Mage::getModel('shipping/tracking_result');
159
+ $tracking_status = Mage::getModel('shipping/tracking_result_status');
160
+ $localeExploded = explode('_', Mage::app()->getLocale()->getLocaleCode());
161
+ $tracking_status->setCarrier($this->_code);
162
+ $tracking_status->setCarrierTitle($this->getConfigData('title'));
163
+ $tracking_status->setTracking($tracking_number);
164
+ $tracking_status->addData(
165
+ array(
166
+ 'status' => '<a target="_blank" href="' . "http://tracking.dpd.de/cgi-bin/delistrack?typ=32&lang=" . $localeExploded[0] . "&pknr=" . $tracking_number . "&var=" . Mage::getStoreConfig('shipping/dpdclassic/userid') . '">' . Mage::helper('dpd')->__('Track this shipment') . '</a>'
167
+ )
168
+ );
169
+ $tracking_result->append($tracking_status);
170
+
171
+ return $tracking_result;
172
+ }
173
+
174
+ /**
175
+ * Make tracking available for dpd shippingmethods.
176
+ *
177
+ * @return bool
178
+ */
179
+ public function isTrackingAvailable()
180
+ {
181
+ return true;
182
+ }
183
+
184
+ /**
185
+ * Make shippinglabels not available as we provided our own method.
186
+ *
187
+ * @return bool
188
+ */
189
+ public function isShippingLabelsAvailable()
190
+ {
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * Get the rateobject from our resource model.
196
+ *
197
+ * @param $request
198
+ * @return mixed
199
+ */
200
+ public function getRate($request)
201
+ {
202
+ return Mage::getResourceModel('dpd/dpdparcelshops_tablerate')->getRate($request);
203
+ }
204
+ }
app/code/community/DPD/Shipping/Model/Dpdclassic/Tablerate.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Dpdclassic_Tablerate
12
+ */
13
+ class DPD_Shipping_Model_Dpdclassic_Tablerate extends Mage_Core_Model_Abstract
14
+ {
15
+ /**
16
+ * Initialise the model.
17
+ */
18
+ protected function _construct()
19
+ {
20
+ $this->_init("dpd/dpdclassic_tablerate");
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/Dpdparcelshops/Tablerate.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Dpdparcelshops_Tablerate
12
+ */
13
+ class DPD_Shipping_Model_Dpdparcelshops_Tablerate extends Mage_Core_Model_Abstract
14
+ {
15
+ /**
16
+ * Initialise the model.
17
+ */
18
+ protected function _construct()
19
+ {
20
+ $this->_init("dpd/dpdparcelshops_tablerate");
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/Mysql4/Dpdclassic/Tablerate.php ADDED
@@ -0,0 +1,433 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Dpdclassic_Tablerate
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Dpdclassic_Tablerate extends Mage_Core_Model_Resource_Db_Abstract{
14
+
15
+ /**
16
+ * Website Id selected in scope.
17
+ *
18
+ * @var int
19
+ */
20
+ protected $_importWebsiteId = 0;
21
+
22
+ /**
23
+ * Array to fill with possible errors.
24
+ *
25
+ * @var array
26
+ */
27
+ protected $_importErrors = array();
28
+
29
+ /**
30
+ * Number of rows imported.
31
+ *
32
+ * @var int
33
+ */
34
+ protected $_importedRows = 0;
35
+
36
+ /**
37
+ * Conversion.
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_importUniqueHash = array();
42
+
43
+ /**
44
+ * Conversion.
45
+ *
46
+ * @var
47
+ */
48
+ protected $_importIso2Countries;
49
+
50
+ /**
51
+ * Conversion.
52
+ *
53
+ * @var
54
+ */
55
+ protected $_importIso3Countries;
56
+
57
+ /**
58
+ * Regions to import.
59
+ *
60
+ * @var
61
+ */
62
+ protected $_importRegions;
63
+
64
+ /**
65
+ * Condition name selected in sysconfig.
66
+ *
67
+ * @var
68
+ */
69
+ protected $_importConditionName;
70
+
71
+ /**
72
+ * Full name of condition selected in sysconfig.
73
+ *
74
+ * @var array
75
+ */
76
+ protected $_conditionFullNames = array();
77
+
78
+
79
+ /**
80
+ * Initialise the model.
81
+ */
82
+ protected function _construct()
83
+ {
84
+ $this->_init("dpd/dpdclassic_tablerate", "pk");
85
+ }
86
+
87
+
88
+ /**
89
+ * Fetch rate from the table for selected shipping address.
90
+ *
91
+ * @param Mage_Shipping_Model_Rate_Request $request
92
+ * @return array
93
+ */
94
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
95
+ {
96
+ $adapter = $this->_getReadAdapter();
97
+ $bind = array(
98
+ ':website_id' => (int) $request->getWebsiteId(),
99
+ ':country_id' => $request->getDestCountryId(),
100
+ ':region_id' => (int) $request->getDestRegionId(),
101
+ ':postcode' => $request->getDestPostcode()
102
+ );
103
+ $select = $adapter->select()
104
+ ->from($this->getMainTable())
105
+ ->where('website_id = :website_id')
106
+ ->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
107
+ ->limit(1);
108
+
109
+ // Render destination condition
110
+ $orWhere = '(' . implode(') OR (', array(
111
+ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
112
+ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
113
+
114
+ // Handle asterix in dest_zip field
115
+ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
116
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
117
+ "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
118
+ "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
119
+
120
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
121
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
122
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
123
+ )) . ')';
124
+ $select->where($orWhere);
125
+
126
+ // Render condition by condition name
127
+ if (is_array($request->getConditionName())) {
128
+ $orWhere = array();
129
+ $i = 0;
130
+ foreach ($request->getConditionName() as $conditionName) {
131
+ $bindNameKey = sprintf(':condition_name_%d', $i);
132
+ $bindValueKey = sprintf(':condition_value_%d', $i);
133
+ $orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
134
+ $bind[$bindNameKey] = $conditionName;
135
+ $bind[$bindValueKey] = $request->getData($conditionName);
136
+ $i++;
137
+ }
138
+
139
+ if ($orWhere) {
140
+ $select->where(implode(' OR ', $orWhere));
141
+ }
142
+ } else {
143
+ $bind[':condition_name'] = $request->getConditionName();
144
+ $bind[':condition_value'] = $request->getData($request->getConditionName());
145
+
146
+ $select->where('condition_name = :condition_name');
147
+ $select->where('condition_value <= :condition_value');
148
+ }
149
+ $result = $adapter->fetchRow($select, $bind);
150
+ // Normalize destination zip code
151
+ if ($result && $result['dest_zip'] == '*') {
152
+ $result['dest_zip'] = '';
153
+ }
154
+ return $result;
155
+ }
156
+
157
+
158
+ /**
159
+ * Upload and import table rates csv.
160
+ *
161
+ * @param Varien_Object $object
162
+ * @return $this
163
+ */
164
+ public function uploadAndImport(Varien_Object $object)
165
+ {
166
+ if (empty($_FILES['groups']['tmp_name']['dpdclassic']['fields']['import_classic']['value'])) {
167
+ return $this;
168
+ }
169
+
170
+ $csvFile = $_FILES['groups']['tmp_name']['dpdclassic']['fields']['import_classic']['value'];
171
+ $website = Mage::app()->getWebsite($object->getScopeId());
172
+
173
+ $this->_importWebsiteId = (int)$website->getId();
174
+ $this->_importUniqueHash = array();
175
+ $this->_importErrors = array();
176
+ $this->_importedRows = 0;
177
+
178
+ $io = new Varien_Io_File();
179
+ $info = pathinfo($csvFile);
180
+ $io->open(array('path' => $info['dirname']));
181
+ $io->streamOpen($info['basename'], 'r');
182
+
183
+ // check and skip headers
184
+ $headers = $io->streamReadCsv();
185
+ if ($headers === false || count($headers) < 5) {
186
+ $io->streamClose();
187
+ Mage::throwException(Mage::helper('dpd')->__('Invalid Table Rates File Format'));
188
+ }
189
+ if ($object->getData('groups/dpdclassic/fields/condition_name/inherit') == '1') {
190
+ $conditionName = (string)Mage::getConfig()->getNode('default/carriers/dpdclassic/condition_name');
191
+ } else {
192
+ $conditionName = $object->getData('groups/dpdclassic/fields/condition_name/value');
193
+ }
194
+ Mage::log((string)Mage::getConfig()->getNode('default/carriers/dpdclassic/condition_name'));
195
+ Mage::log($object->getData('groups/dpdclassic/fields/condition_name/value'));
196
+ $this->_importConditionName = $conditionName;
197
+ $adapter = $this->_getWriteAdapter();
198
+ $adapter->beginTransaction();
199
+
200
+ try {
201
+ $rowNumber = 1;
202
+ $importData = array();
203
+
204
+ $this->_loadDirectoryCountries();
205
+ $this->_loadDirectoryRegions();
206
+
207
+ // delete old data by website and condition name
208
+ $condition = array(
209
+ 'website_id = ?' => $this->_importWebsiteId,
210
+ 'condition_name = ?' => $this->_importConditionName
211
+ );
212
+ $adapter->delete($this->getMainTable(), $condition);
213
+
214
+ while (false !== ($csvLine = $io->streamReadCsv())) {
215
+ $rowNumber ++;
216
+
217
+ if (empty($csvLine)) {
218
+ continue;
219
+ }
220
+
221
+ $row = $this->_getImportRow($csvLine, $rowNumber);
222
+ if ($row !== false) {
223
+ $importData[] = $row;
224
+ }
225
+
226
+ if (count($importData) == 5000) {
227
+ $this->_saveImportData($importData);
228
+ $importData = array();
229
+ }
230
+ }
231
+ $this->_saveImportData($importData);
232
+ $io->streamClose();
233
+ } catch (Mage_Core_Exception $e) {
234
+ $adapter->rollback();
235
+ $io->streamClose();
236
+ Mage::throwException($e->getMessage());
237
+ } catch (Exception $e) {
238
+ $adapter->rollback();
239
+ $io->streamClose();
240
+ Mage::logException($e);
241
+ Mage::throwException(Mage::helper('dpd')->__('An error occurred while importing table rates.'));
242
+ }
243
+
244
+ $adapter->commit();
245
+
246
+ if ($this->_importErrors) {
247
+ $error = Mage::helper('dpd')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
248
+ Mage::throwException($error);
249
+ }
250
+
251
+ return $this;
252
+ }
253
+
254
+ /**
255
+ * Load directory countries.
256
+ *
257
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate
258
+ */
259
+ protected function _loadDirectoryCountries()
260
+ {
261
+ if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
262
+ return $this;
263
+ }
264
+
265
+ $this->_importIso2Countries = array();
266
+ $this->_importIso3Countries = array();
267
+
268
+ /** @var $collection Mage_Directory_Model_Resource_Country_Collection */
269
+ $collection = Mage::getResourceModel('directory/country_collection');
270
+ foreach ($collection->getData() as $row) {
271
+ $this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
272
+ $this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
273
+ }
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * Load directory regions.
280
+ *
281
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate
282
+ */
283
+ protected function _loadDirectoryRegions()
284
+ {
285
+ if (!is_null($this->_importRegions)) {
286
+ return $this;
287
+ }
288
+
289
+ $this->_importRegions = array();
290
+
291
+ /** @var $collection Mage_Directory_Model_Resource_Region_Collection */
292
+ $collection = Mage::getResourceModel('directory/region_collection');
293
+ foreach ($collection->getData() as $row) {
294
+ $this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
295
+ }
296
+
297
+ return $this;
298
+ }
299
+
300
+ /**
301
+ * Return import condition full name by condition name code.
302
+ *
303
+ * @param string $conditionName
304
+ * @return string
305
+ */
306
+ protected function _getConditionFullName($conditionName)
307
+ {
308
+ if (!isset($this->_conditionFullNames[$conditionName])) {
309
+ $name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
310
+ $this->_conditionFullNames[$conditionName] = $name;
311
+ }
312
+ return $this->_conditionFullNames[$conditionName];
313
+ }
314
+
315
+ /**
316
+ * Validate row for import and return table rate array or false.
317
+ * Error will be add to _importErrors array.
318
+ *
319
+ * @param array $row
320
+ * @param int $rowNumber
321
+ * @return array|false
322
+ */
323
+ protected function _getImportRow($row, $rowNumber = 0)
324
+ {
325
+ // validate row
326
+ if (count($row) < 5) {
327
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
328
+ return false;
329
+ }
330
+
331
+ // strip whitespace from the beginning and end of each row
332
+ foreach ($row as $k => $v) {
333
+ $row[$k] = trim($v);
334
+ }
335
+
336
+ // validate country
337
+ if (isset($this->_importIso2Countries[$row[0]])){
338
+ $countryId = $this->_importIso2Countries[$row[0]];
339
+ } elseif (isset($this->_importIso3Countries[$row[0]])) {
340
+ $countryId = $this->_importIso3Countries[$row[0]];
341
+ } elseif ($row[0] == '*' || $row[0] == '') {
342
+ $countryId = '0';
343
+ } else {
344
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
345
+ return false;
346
+ }
347
+
348
+ // validate region
349
+ if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
350
+ $regionId = $this->_importRegions[$countryId][$row[1]];
351
+ } elseif ($row[1] == '*' || $row[1] == '') {
352
+ $regionId = 0;
353
+ } else {
354
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
355
+ return false;
356
+ }
357
+
358
+ // detect zip code
359
+ if ($row[2] == '*' || $row[2] == '') {
360
+ $zipCode = '*';
361
+ } else {
362
+ $zipCode = $row[2];
363
+ }
364
+
365
+ // validate condition value
366
+ $value = $this->_parseDecimalValue($row[3]);
367
+ if ($value === false) {
368
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
369
+ return false;
370
+ }
371
+
372
+ // validate price
373
+ $price = $this->_parseDecimalValue($row[4]);
374
+ if ($price === false) {
375
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
376
+ return false;
377
+ }
378
+
379
+ // protect from duplicate
380
+ $hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
381
+ if (isset($this->_importUniqueHash[$hash])) {
382
+ $this->_importErrors[] = Mage::helper('dpd')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
383
+ return false;
384
+ }
385
+ $this->_importUniqueHash[$hash] = true;
386
+
387
+ return array(
388
+ $this->_importWebsiteId, // website_id
389
+ $countryId, // dest_country_id
390
+ $regionId, // dest_region_id,
391
+ $zipCode, // dest_zip
392
+ $this->_importConditionName,// condition_name,
393
+ $value, // condition_value
394
+ $price // price
395
+ );
396
+ }
397
+
398
+ /**
399
+ * Save all import data.
400
+ *
401
+ * @param array $data
402
+ * @return $this
403
+ */
404
+ protected function _saveImportData(array $data)
405
+ {
406
+ if (!empty($data)) {
407
+ $columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
408
+ 'condition_name', 'condition_value', 'price');
409
+ $this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
410
+ $this->_importedRows += count($data);
411
+ }
412
+
413
+ return $this;
414
+ }
415
+
416
+ /**
417
+ * Conversion.
418
+ *
419
+ * @param $value
420
+ * @return bool|float
421
+ */
422
+ protected function _parseDecimalValue($value)
423
+ {
424
+ if (!is_numeric($value)) {
425
+ return false;
426
+ }
427
+ $value = (float)sprintf('%.4F', $value);
428
+ if ($value < 0.0000) {
429
+ return false;
430
+ }
431
+ return $value;
432
+ }
433
+ }
app/code/community/DPD/Shipping/Model/Mysql4/Dpdclassic/Tablerate/Collection.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Dpdclassic_Tablerate_Collection
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Dpdclassic_Tablerate_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
14
+ {
15
+ /**
16
+ * main table name
17
+ *
18
+ * @deprecated since 1.4.1.0
19
+ * @var string
20
+ */
21
+ protected $_shipTable;
22
+
23
+ /**
24
+ * directory/country table name
25
+ *
26
+ * @var string
27
+ */
28
+ protected $_countryTable;
29
+
30
+ /**
31
+ * directory/country_region table name
32
+ *
33
+ * @var string
34
+ */
35
+ protected $_regionTable;
36
+
37
+ /**
38
+ * Define resource model and item
39
+ *
40
+ */
41
+ protected function _construct()
42
+ {
43
+ $this->_init('dpd/dpdclassic_tablerate');
44
+ $this->_shipTable = $this->getMainTable();
45
+ $this->_countryTable = $this->getTable('directory/country');
46
+ $this->_regionTable = $this->getTable('directory/country_region');
47
+ }
48
+
49
+ /**
50
+ * Initialize select, add country iso3 code and region name
51
+ *
52
+ * @return void
53
+ */
54
+ public function _initSelect()
55
+ {
56
+ parent::_initSelect();
57
+
58
+ $this->_select
59
+ ->joinLeft(
60
+ array('country_table' => $this->_countryTable),
61
+ 'country_table.country_id = main_table.dest_country_id',
62
+ array('dest_country' => 'iso3_code'))
63
+ ->joinLeft(
64
+ array('region_table' => $this->_regionTable),
65
+ 'region_table.region_id = main_table.dest_region_id',
66
+ array('dest_region' => 'code'));
67
+
68
+ $this->addOrder('dest_country', self::SORT_ORDER_ASC);
69
+ $this->addOrder('dest_region', self::SORT_ORDER_ASC);
70
+ $this->addOrder('dest_zip', self::SORT_ORDER_ASC);
71
+ $this->addOrder('condition_value', self::SORT_ORDER_ASC);
72
+ }
73
+
74
+ /**
75
+ * Add website filter to collection
76
+ *
77
+ * @param int $websiteId
78
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
79
+ */
80
+ public function setWebsiteFilter($websiteId)
81
+ {
82
+ return $this->addFieldToFilter('website_id', $websiteId);
83
+ }
84
+
85
+ /**
86
+ * Add condition name (code) filter to collection
87
+ *
88
+ * @param string $conditionName
89
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
90
+ */
91
+ public function setConditionFilter($conditionName)
92
+ {
93
+ return $this->addFieldToFilter('condition_name', $conditionName);
94
+ }
95
+
96
+ /**
97
+ * Add country filter to collection
98
+ *
99
+ * @param string $countryId
100
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
101
+ */
102
+ public function setCountryFilter($countryId)
103
+ {
104
+ return $this->addFieldToFilter('dest_country_id', $countryId);
105
+ }
106
+ }
107
+
app/code/community/DPD/Shipping/Model/Mysql4/Dpdparcelshops/Tablerate.php ADDED
@@ -0,0 +1,433 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Dpdparcelshops_Tablerate
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Dpdparcelshops_Tablerate extends Mage_Core_Model_Resource_Db_Abstract{
14
+
15
+ /**
16
+ * Website Id selected in scope.
17
+ *
18
+ * @var int
19
+ */
20
+ protected $_importWebsiteId = 0;
21
+
22
+ /**
23
+ * Array to fill with possible errors.
24
+ *
25
+ * @var array
26
+ */
27
+ protected $_importErrors = array();
28
+
29
+ /**
30
+ * Number of rows imported.
31
+ *
32
+ * @var int
33
+ */
34
+ protected $_importedRows = 0;
35
+
36
+ /**
37
+ * Conversion.
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_importUniqueHash = array();
42
+
43
+ /**
44
+ * Conversion.
45
+ *
46
+ * @var
47
+ */
48
+ protected $_importIso2Countries;
49
+
50
+ /**
51
+ * Conversion.
52
+ *
53
+ * @var
54
+ */
55
+ protected $_importIso3Countries;
56
+
57
+ /**
58
+ * Regions to import.
59
+ *
60
+ * @var
61
+ */
62
+ protected $_importRegions;
63
+
64
+ /**
65
+ * Condition name selected in sysconfig.
66
+ *
67
+ * @var
68
+ */
69
+ protected $_importConditionName;
70
+
71
+ /**
72
+ * Full name of condition selected in sysconfig.
73
+ *
74
+ * @var array
75
+ */
76
+ protected $_conditionFullNames = array();
77
+
78
+
79
+ /**
80
+ * Initialise the model.
81
+ */
82
+ protected function _construct()
83
+ {
84
+ $this->_init("dpd/dpdparcelshops_tablerate", "pk");
85
+ }
86
+
87
+
88
+ /**
89
+ * Fetch rate from the table for selected shipping address.
90
+ *
91
+ * @param Mage_Shipping_Model_Rate_Request $request
92
+ * @return array
93
+ */
94
+ public function getRate(Mage_Shipping_Model_Rate_Request $request)
95
+ {
96
+ $adapter = $this->_getReadAdapter();
97
+ $bind = array(
98
+ ':website_id' => (int) $request->getWebsiteId(),
99
+ ':country_id' => $request->getDestCountryId(),
100
+ ':region_id' => (int) $request->getDestRegionId(),
101
+ ':postcode' => $request->getDestPostcode()
102
+ );
103
+ $select = $adapter->select()
104
+ ->from($this->getMainTable())
105
+ ->where('website_id = :website_id')
106
+ ->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'condition_value DESC'))
107
+ ->limit(1);
108
+
109
+ // Render destination condition
110
+ $orWhere = '(' . implode(') OR (', array(
111
+ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode",
112
+ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''",
113
+
114
+ // Handle asterix in dest_zip field
115
+ "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = '*'",
116
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
117
+ "dest_country_id = '0' AND dest_region_id = :region_id AND dest_zip = '*'",
118
+ "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = '*'",
119
+
120
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''",
121
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode",
122
+ "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = '*'",
123
+ )) . ')';
124
+ $select->where($orWhere);
125
+
126
+ // Render condition by condition name
127
+ if (is_array($request->getConditionName())) {
128
+ $orWhere = array();
129
+ $i = 0;
130
+ foreach ($request->getConditionName() as $conditionName) {
131
+ $bindNameKey = sprintf(':condition_name_%d', $i);
132
+ $bindValueKey = sprintf(':condition_value_%d', $i);
133
+ $orWhere[] = "(condition_name = {$bindNameKey} AND condition_value <= {$bindValueKey})";
134
+ $bind[$bindNameKey] = $conditionName;
135
+ $bind[$bindValueKey] = $request->getData($conditionName);
136
+ $i++;
137
+ }
138
+
139
+ if ($orWhere) {
140
+ $select->where(implode(' OR ', $orWhere));
141
+ }
142
+ } else {
143
+ $bind[':condition_name'] = $request->getConditionName();
144
+ $bind[':condition_value'] = $request->getData($request->getConditionName());
145
+
146
+ $select->where('condition_name = :condition_name');
147
+ $select->where('condition_value <= :condition_value');
148
+ }
149
+ $result = $adapter->fetchRow($select, $bind);
150
+ // Normalize destination zip code
151
+ if ($result && $result['dest_zip'] == '*') {
152
+ $result['dest_zip'] = '';
153
+ }
154
+ return $result;
155
+ }
156
+
157
+
158
+ /**
159
+ * Upload and import table rates csv.
160
+ *
161
+ * @param Varien_Object $object
162
+ * @return $this
163
+ */
164
+ public function uploadAndImport(Varien_Object $object)
165
+ {
166
+ if (empty($_FILES['groups']['tmp_name']['dpdparcelshops']['fields']['import_parcelshops']['value'])) {
167
+ return $this;
168
+ }
169
+
170
+ $csvFile = $_FILES['groups']['tmp_name']['dpdparcelshops']['fields']['import_parcelshops']['value'];
171
+ $website = Mage::app()->getWebsite($object->getScopeId());
172
+
173
+ $this->_importWebsiteId = (int)$website->getId();
174
+ $this->_importUniqueHash = array();
175
+ $this->_importErrors = array();
176
+ $this->_importedRows = 0;
177
+
178
+ $io = new Varien_Io_File();
179
+ $info = pathinfo($csvFile);
180
+ $io->open(array('path' => $info['dirname']));
181
+ $io->streamOpen($info['basename'], 'r');
182
+
183
+ // check and skip headers
184
+ $headers = $io->streamReadCsv();
185
+ if ($headers === false || count($headers) < 5) {
186
+ $io->streamClose();
187
+ Mage::throwException(Mage::helper('dpd')->__('Invalid Table Rates File Format'));
188
+ }
189
+
190
+ if ($object->getData('groups/dpdparcelshops/fields/condition_name/inherit') == '1') {
191
+ $conditionName = (string)Mage::getConfig()->getNode('default/carriers/dpdparcelshops/condition_name');
192
+ } else {
193
+ $conditionName = $object->getData('groups/dpdparcelshops/fields/condition_name/value');
194
+ }
195
+
196
+ $this->_importConditionName = $conditionName;
197
+ $adapter = $this->_getWriteAdapter();
198
+ $adapter->beginTransaction();
199
+
200
+ try {
201
+ $rowNumber = 1;
202
+ $importData = array();
203
+
204
+ $this->_loadDirectoryCountries();
205
+ $this->_loadDirectoryRegions();
206
+
207
+ // delete old data by website and condition name
208
+ $condition = array(
209
+ 'website_id = ?' => $this->_importWebsiteId,
210
+ 'condition_name = ?' => $this->_importConditionName
211
+ );
212
+ $adapter->delete($this->getMainTable(), $condition);
213
+
214
+ while (false !== ($csvLine = $io->streamReadCsv())) {
215
+ $rowNumber ++;
216
+
217
+ if (empty($csvLine)) {
218
+ continue;
219
+ }
220
+
221
+ $row = $this->_getImportRow($csvLine, $rowNumber);
222
+ if ($row !== false) {
223
+ $importData[] = $row;
224
+ }
225
+
226
+ if (count($importData) == 5000) {
227
+ $this->_saveImportData($importData);
228
+ $importData = array();
229
+ }
230
+ }
231
+ $this->_saveImportData($importData);
232
+ $io->streamClose();
233
+ } catch (Mage_Core_Exception $e) {
234
+ $adapter->rollback();
235
+ $io->streamClose();
236
+ Mage::throwException($e->getMessage());
237
+ } catch (Exception $e) {
238
+ $adapter->rollback();
239
+ $io->streamClose();
240
+ Mage::logException($e);
241
+ Mage::throwException(Mage::helper('dpd')->__('An error occurred while importing table rates.'));
242
+ }
243
+
244
+ $adapter->commit();
245
+
246
+ if ($this->_importErrors) {
247
+ $error = Mage::helper('dpd')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
248
+ Mage::throwException($error);
249
+ }
250
+
251
+ return $this;
252
+ }
253
+
254
+ /**
255
+ * Load directory countries.
256
+ *
257
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate
258
+ */
259
+ protected function _loadDirectoryCountries()
260
+ {
261
+ if (!is_null($this->_importIso2Countries) && !is_null($this->_importIso3Countries)) {
262
+ return $this;
263
+ }
264
+
265
+ $this->_importIso2Countries = array();
266
+ $this->_importIso3Countries = array();
267
+
268
+ /** @var $collection Mage_Directory_Model_Resource_Country_Collection */
269
+ $collection = Mage::getResourceModel('directory/country_collection');
270
+ foreach ($collection->getData() as $row) {
271
+ $this->_importIso2Countries[$row['iso2_code']] = $row['country_id'];
272
+ $this->_importIso3Countries[$row['iso3_code']] = $row['country_id'];
273
+ }
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * Load directory regions.
280
+ *
281
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate
282
+ */
283
+ protected function _loadDirectoryRegions()
284
+ {
285
+ if (!is_null($this->_importRegions)) {
286
+ return $this;
287
+ }
288
+
289
+ $this->_importRegions = array();
290
+
291
+ /** @var $collection Mage_Directory_Model_Resource_Region_Collection */
292
+ $collection = Mage::getResourceModel('directory/region_collection');
293
+ foreach ($collection->getData() as $row) {
294
+ $this->_importRegions[$row['country_id']][$row['code']] = (int)$row['region_id'];
295
+ }
296
+
297
+ return $this;
298
+ }
299
+
300
+ /**
301
+ * Return import condition full name by condition name code.
302
+ *
303
+ * @param string $conditionName
304
+ * @return string
305
+ */
306
+ protected function _getConditionFullName($conditionName)
307
+ {
308
+ if (!isset($this->_conditionFullNames[$conditionName])) {
309
+ $name = Mage::getSingleton('shipping/carrier_tablerate')->getCode('condition_name_short', $conditionName);
310
+ $this->_conditionFullNames[$conditionName] = $name;
311
+ }
312
+ return $this->_conditionFullNames[$conditionName];
313
+ }
314
+
315
+ /**
316
+ * Validate row for import and return table rate array or false.
317
+ * Error will be added to _importErrors array.
318
+ *
319
+ * @param array $row
320
+ * @param int $rowNumber
321
+ * @return array|false
322
+ */
323
+ protected function _getImportRow($row, $rowNumber = 0)
324
+ {
325
+ // validate row
326
+ if (count($row) < 5) {
327
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Table Rates format in the Row #%s', $rowNumber);
328
+ return false;
329
+ }
330
+
331
+ // strip whitespace from the beginning and end of each row
332
+ foreach ($row as $k => $v) {
333
+ $row[$k] = trim($v);
334
+ }
335
+
336
+ // validate country
337
+ if (isset($this->_importIso2Countries[$row[0]])){
338
+ $countryId = $this->_importIso2Countries[$row[0]];
339
+ } elseif (isset($this->_importIso3Countries[$row[0]])) {
340
+ $countryId = $this->_importIso3Countries[$row[0]];
341
+ } elseif ($row[0] == '*' || $row[0] == '') {
342
+ $countryId = '0';
343
+ } else {
344
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Country "%s" in the Row #%s.', $row[0], $rowNumber);
345
+ return false;
346
+ }
347
+
348
+ // validate region
349
+ if ($countryId != '0' && isset($this->_importRegions[$countryId][$row[1]])) {
350
+ $regionId = $this->_importRegions[$countryId][$row[1]];
351
+ } elseif ($row[1] == '*' || $row[1] == '') {
352
+ $regionId = 0;
353
+ } else {
354
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Region/State "%s" in the Row #%s.', $row[1], $rowNumber);
355
+ return false;
356
+ }
357
+
358
+ // detect zip code
359
+ if ($row[2] == '*' || $row[2] == '') {
360
+ $zipCode = '*';
361
+ } else {
362
+ $zipCode = $row[2];
363
+ }
364
+
365
+ // validate condition value
366
+ $value = $this->_parseDecimalValue($row[3]);
367
+ if ($value === false) {
368
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid %s "%s" in the Row #%s.', $this->_getConditionFullName($this->_importConditionName), $row[3], $rowNumber);
369
+ return false;
370
+ }
371
+
372
+ // validate price
373
+ $price = $this->_parseDecimalValue($row[4]);
374
+ if ($price === false) {
375
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid Shipping Price "%s" in the Row #%s.', $row[4], $rowNumber);
376
+ return false;
377
+ }
378
+
379
+ // protect from duplicate
380
+ $hash = sprintf("%s-%d-%s-%F", $countryId, $regionId, $zipCode, $value);
381
+ if (isset($this->_importUniqueHash[$hash])) {
382
+ $this->_importErrors[] = Mage::helper('dpd')->__('Duplicate Row #%s (Country "%s", Region/State "%s", Zip "%s" and Value "%s").', $rowNumber, $row[0], $row[1], $zipCode, $value);
383
+ return false;
384
+ }
385
+ $this->_importUniqueHash[$hash] = true;
386
+
387
+ return array(
388
+ $this->_importWebsiteId, // website_id
389
+ $countryId, // dest_country_id
390
+ $regionId, // dest_region_id,
391
+ $zipCode, // dest_zip
392
+ $this->_importConditionName,// condition_name,
393
+ $value, // condition_value
394
+ $price // price
395
+ );
396
+ }
397
+
398
+ /**
399
+ * Save all import data.
400
+ *
401
+ * @param array $data
402
+ * @return $this
403
+ */
404
+ protected function _saveImportData(array $data)
405
+ {
406
+ if (!empty($data)) {
407
+ $columns = array('website_id', 'dest_country_id', 'dest_region_id', 'dest_zip',
408
+ 'condition_name', 'condition_value', 'price');
409
+ $this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $data);
410
+ $this->_importedRows += count($data);
411
+ }
412
+
413
+ return $this;
414
+ }
415
+
416
+ /**
417
+ * Conversion.
418
+ *
419
+ * @param $value
420
+ * @return bool|float
421
+ */
422
+ protected function _parseDecimalValue($value)
423
+ {
424
+ if (!is_numeric($value)) {
425
+ return false;
426
+ }
427
+ $value = (float)sprintf('%.4F', $value);
428
+ if ($value < 0.0000) {
429
+ return false;
430
+ }
431
+ return $value;
432
+ }
433
+ }
app/code/community/DPD/Shipping/Model/Mysql4/Dpdparcelshops/Tablerate/Collection.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Dpdparcelshops_Tablerate_Collection
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Dpdparcelshops_Tablerate_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
14
+ { /**
15
+ * main table name
16
+ *
17
+ * @deprecated since 1.4.1.0
18
+ * @var string
19
+ */
20
+ protected $_shipTable;
21
+
22
+ /**
23
+ * directory/country table name
24
+ *
25
+ * @var string
26
+ */
27
+ protected $_countryTable;
28
+
29
+ /**
30
+ * directory/country_region table name
31
+ *
32
+ * @var string
33
+ */
34
+ protected $_regionTable;
35
+
36
+ /**
37
+ * Define resource model and item
38
+ *
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->_init("dpd/dpdparcelshops_tablerate");
43
+ $this->_shipTable = $this->getMainTable();
44
+ $this->_countryTable = $this->getTable('directory/country');
45
+ $this->_regionTable = $this->getTable('directory/country_region');
46
+ }
47
+
48
+ /**
49
+ * Initialize select, add country iso3 code and region name
50
+ *
51
+ * @return void
52
+ */
53
+ public function _initSelect()
54
+ {
55
+ parent::_initSelect();
56
+
57
+ $this->_select
58
+ ->joinLeft(
59
+ array('country_table' => $this->_countryTable),
60
+ 'country_table.country_id = main_table.dest_country_id',
61
+ array('dest_country' => 'iso3_code'))
62
+ ->joinLeft(
63
+ array('region_table' => $this->_regionTable),
64
+ 'region_table.region_id = main_table.dest_region_id',
65
+ array('dest_region' => 'code'));
66
+
67
+ $this->addOrder('dest_country', self::SORT_ORDER_ASC);
68
+ $this->addOrder('dest_region', self::SORT_ORDER_ASC);
69
+ $this->addOrder('dest_zip', self::SORT_ORDER_ASC);
70
+ $this->addOrder('condition_value', self::SORT_ORDER_ASC);
71
+ }
72
+
73
+ /**
74
+ * Add website filter to collection
75
+ *
76
+ * @param int $websiteId
77
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
78
+ */
79
+ public function setWebsiteFilter($websiteId)
80
+ {
81
+ return $this->addFieldToFilter('website_id', $websiteId);
82
+ }
83
+
84
+ /**
85
+ * Add condition name (code) filter to collection
86
+ *
87
+ * @param string $conditionName
88
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
89
+ */
90
+ public function setConditionFilter($conditionName)
91
+ {
92
+ return $this->addFieldToFilter('condition_name', $conditionName);
93
+ }
94
+
95
+ /**
96
+ * Add country filter to collection
97
+ *
98
+ * @param string $countryId
99
+ * @return Mage_Shipping_Model_Resource_Carrier_Tablerate_Collection
100
+ */
101
+ public function setCountryFilter($countryId)
102
+ {
103
+ return $this->addFieldToFilter('dest_country_id', $countryId);
104
+ }
105
+ }
106
+
app/code/community/DPD/Shipping/Model/Mysql4/Returnlabels.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Returnlabels
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Returnlabels extends Mage_Core_Model_Mysql4_Abstract
14
+ {
15
+ /**
16
+ * Sets model primary key.
17
+ */
18
+ protected function _construct()
19
+ {
20
+ $this->_init("dpd/returnlabels", "returnlabels_id");
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/Mysql4/Returnlabels/Collection.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Returnlabels_Collection
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Returnlabels_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
14
+ {
15
+ /**
16
+ * Initialises the model, the abstract file will render a collection from it.
17
+ */
18
+ public function _construct()
19
+ {
20
+ $this->_init("dpd/returnlabels");
21
+ }
22
+ }
23
+
app/code/community/DPD/Shipping/Model/Mysql4/Specialparcelshops.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Specialparcelshops
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Specialparcelshops extends Mage_Core_Model_Mysql4_Abstract
14
+ {
15
+ /**
16
+ * Store errors here for display in the session message.
17
+ *
18
+ * @var array
19
+ */
20
+ protected $_importErrors = array();
21
+ /**
22
+ * Website Id of the imported date.
23
+ *
24
+ * @var
25
+ */
26
+ protected $_importWebsiteId;
27
+ /**
28
+ * Csv Rows.
29
+ *
30
+ * @var
31
+ */
32
+ protected $_importedRows;
33
+
34
+ /**
35
+ * Sets model primary key.
36
+ */
37
+ protected function _construct()
38
+ {
39
+ $this->_init("dpd/specialparcelshops", "specialparselshops_id");
40
+ }
41
+
42
+ /**
43
+ * Uploads the file and imports the data into the table.
44
+ *
45
+ * @param Varien_Object $object
46
+ * @return $this
47
+ */
48
+ public function uploadAndImport(Varien_Object $object)
49
+ {
50
+ if (empty($_FILES['groups']['tmp_name']['dpdparcelshops']['fields']['custom_parcelshops_import']['value'])) {
51
+ return $this;
52
+ }
53
+ $website = Mage::app()->getWebsite($object->getScopeId());
54
+ $this->_importWebsiteId = (int)$website->getId();
55
+ $csvFile = $_FILES['groups']['tmp_name']['dpdparcelshops']['fields']['custom_parcelshops_import']['value'];
56
+ $io = new Varien_Io_File();
57
+ $info = pathinfo($csvFile);
58
+ $io->open(array('path' => $info['dirname']));
59
+ $io->streamOpen($info['basename'], 'r');
60
+ $adapter = $this->_getWriteAdapter();
61
+ $adapter->beginTransaction();
62
+
63
+ try {
64
+ $rowNumber = 1;
65
+ $importData = array();
66
+ $parcelShopNumber = 0;
67
+ $totalrows = count(file($csvFile));
68
+ $condition = array(
69
+ 'parcelshop_website_id = ?' => $this->_importWebsiteId
70
+ );
71
+ $adapter->delete($this->getMainTable(), $condition);
72
+
73
+ while (false !== ($csvLine = $io->streamReadCsv(";"))) {
74
+ $rowNumber++;
75
+
76
+ if (empty($csvLine)) {
77
+ continue;
78
+ }
79
+
80
+ $row = $this->_getImportRow($csvLine, $rowNumber, $totalrows);
81
+ if ($row !== false) {
82
+ if ($csvLine[0] == 'GR') {
83
+ $parcelShopNumber++;
84
+ }
85
+ if (!isset($importData[$parcelShopNumber])) {
86
+ $importData[$parcelShopNumber] = array();
87
+ }
88
+ $importData[$parcelShopNumber] = array_merge($importData[$parcelShopNumber], $row);
89
+ }
90
+ }
91
+ $this->_saveImportData($importData);
92
+ $io->streamClose();
93
+
94
+ } catch (Mage_Core_Exception $e) {
95
+ if (count($rowNumber) < 5) {
96
+ $this->_importErrors[] = Mage::helper('dpd')->__('Invalid ParcelShops format in the Row #%s', $rowNumber);
97
+ return false;
98
+ }
99
+ $adapter->rollback();
100
+ $io->streamClose();
101
+ Mage::throwException($e->getMessage());
102
+ } catch (Exception $e) {
103
+ $adapter->rollback();
104
+ $io->streamClose();
105
+ Mage::helper('dpd')->log($e, Zend_Log::ERR);
106
+ Mage::throwException(Mage::helper('dpd')->__('An error occurred while importing ParcelShops. Check the log for details.'));
107
+ }
108
+
109
+ if ($this->_importErrors) {
110
+ $adapter->rollback();
111
+ $error = Mage::helper('dpd')->__('File has not been imported. See the following list of errors: %s', implode(" \n", $this->_importErrors));
112
+ Mage::throwException($error);
113
+ }
114
+ $adapter->commit();
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Gets the row and validates content.
120
+ *
121
+ * @param $row
122
+ * @param int $rowNumber
123
+ * @param $totalrows
124
+ * @return array|bool
125
+ */
126
+ protected function _getImportRow($row, $rowNumber = 0, $totalrows)
127
+ {
128
+ // strip whitespace from the beginning and end of each row
129
+ foreach ($row as $k => $v) {
130
+ $row[$k] = trim($v);
131
+ }
132
+
133
+ // validation
134
+ if ($rowNumber == 2 && $row[0] != "AA") {
135
+ $this->_importErrors[] = Mage::helper('dpd')->__('Your csv does not have the required AA header. Please refer to the manual.');
136
+ } elseif ($row[0] == "ZZ" && $rowNumber != $totalrows + 1) {
137
+ $this->_importErrors[] = Mage::helper('dpd')->__('Your csv closed too soon with the ZZ ending. Please refer to the manual.');
138
+ } elseif ($rowNumber == $totalrows + 1 && $row[0] != "ZZ" && empty($this->_importErrors)) {
139
+ $this->_importErrors[] = Mage::helper('dpd')->__('Your csv does not have the required ZZ ending. Please refer to the manual.');
140
+ }
141
+
142
+ //normalize data
143
+ if ($row[0] == "GR") {
144
+ $requiredAttributes = array("PUDO Id" => $row[1], "Pudo Name" => $row[4], "Pudo Language" => $row[5], "Pudo Country" => $row[6], "Latitude" => $row[7], "Longitude", $row[8]);
145
+ if($missingAttributes = $this->_checkRequired($requiredAttributes)){
146
+ $this->_importErrors[] = Mage::helper('dpd')->__('Your csv does not have the following required attributes %s on row %s. Please refer to the manual.', $missingAttributes, $rowNumber);
147
+ }
148
+ $fillarray = array($this->_importWebsiteId, $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7], $row[8]);
149
+ return $fillarray;
150
+ } elseif ($row[0] == "AD") {
151
+ $requiredAttributes = array("Address 1" => $row[4], "Post Code" => $row[7], "Town" => $row[8]);
152
+ if($missingAttributes = $this->_checkRequired($requiredAttributes)){
153
+ $this->_importErrors[] = Mage::helper('dpd')->__('Your csv does not have the following required attributes %s on row %s. Please refer to the manual.', $missingAttributes, $rowNumber);
154
+ }
155
+ $fillarray = array($row[2], $row[3], $row[4], $row[5], $row[6], $row[7], $row[8], $row[9]);
156
+ return $fillarray;
157
+ } elseif ($row[0] == "HO") {
158
+ $daysArray = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
159
+ $hoursarray = array();
160
+ $count = 2;
161
+ for ($i = 0; $i < 7; $i++) {
162
+ $timetable = new stdClass;
163
+ $timetable->weekday = $daysArray[$i];
164
+ $timetable->openMorning = substr_replace($row[$count++], ":", 2, 0);
165
+ $timetable->closeMorning = substr_replace($row[$count++], ":", 2, 0);
166
+ $timetable->openAfternoon = substr_replace($row[$count++], ":", 2, 0);
167
+ $timetable->closeAfternoon = substr_replace($row[$count++], ":", 2, 0);
168
+ $hoursarray[] = $timetable;
169
+ }
170
+ $fillarray = array(Mage::helper('core')->jsonEncode($hoursarray));
171
+ return $fillarray;
172
+ }
173
+
174
+ return false;
175
+ }
176
+
177
+ /**
178
+ * Save all data.
179
+ *
180
+ * @param array $data
181
+ * @return $this
182
+ */
183
+ protected function _saveImportData(array $data)
184
+ {
185
+ if (!empty($data)) {
186
+ $columns = array('parcelshop_website_id', 'parcelshop_delicom_id', 'parcelshop_carrier_pudo_id', 'parcelshop_manager',
187
+ 'parcelshop_pudo_name', 'parcelshop_pudo_language', 'parcelshop_country', 'parcelshop_latitude',
188
+ 'parcelshop_longitude', 'parcelshop_city_code', 'parcelshop_langue_1', 'parcelshop_address_1', 'parcelshop_address_2',
189
+ 'parcelshop_location_information', 'parcelshop_post_code', 'parcelshop_town', 'parcelshop_region', 'parcelshop_openinghours');
190
+ $values = $data;
191
+ $this->_getWriteAdapter()->insertArray($this->getMainTable(), $columns, $values);
192
+ }
193
+ return $this;
194
+ }
195
+
196
+ /**
197
+ * Check required data row per row.
198
+ *
199
+ * @param array $requiredAttributes
200
+ * @return bool|string
201
+ */
202
+ protected function _checkRequired(array $requiredAttributes)
203
+ {
204
+ $missing = false;
205
+ $missingattributes = array();
206
+ foreach($requiredAttributes as $key => $requiredAttribute){
207
+ if(!$requiredAttribute){
208
+ $missingattributes[] = $key;
209
+ $missing = true;
210
+ }
211
+ }
212
+ if(!$missing){
213
+ return false;
214
+ }
215
+
216
+ return implode(', ',$missingattributes);
217
+ }
218
+ }
app/code/community/DPD/Shipping/Model/Mysql4/Specialparcelshops/Collection.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Mysql4_Specialparcelshops_Collection
12
+ */
13
+ class DPD_Shipping_Model_Mysql4_Specialparcelshops_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
14
+ {
15
+ /**
16
+ * Initialises the model, the abstract file will render a collection from it.
17
+ */
18
+ public function _construct()
19
+ {
20
+ $this->_init("dpd/specialparcelshops");
21
+ }
22
+ }
23
+
app/code/community/DPD/Shipping/Model/Observer.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Observer
12
+ */
13
+ class DPD_Shipping_Model_Observer
14
+ {
15
+ /**
16
+ * Observes html load, this will add html to the Parcelshop shipping method and set default shipping method.
17
+ *
18
+ * @param $observer
19
+ */
20
+ public function core_block_abstract_to_html_after($observer)
21
+ {
22
+ if ($observer->getBlock() instanceof Mage_Checkout_Block_Onepage_Shipping_Method_Available) {
23
+ //get HTML
24
+ $html = $observer->getTransport()->getHtml();
25
+
26
+ //set default if in config
27
+ $html = Mage::helper('dpd')->checkShippingDefault($html);
28
+
29
+ //replace label by html
30
+ $html = Mage::helper('dpd')->addHTML($html);
31
+
32
+ //set HTML
33
+ $observer->getTransport()->setHtml($html);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Triggered when saving a shipping method, this saves dpd data to the customer address without saving it on customer.
39
+ *
40
+ * @param $observer
41
+ */
42
+ public function checkout_controller_onepage_save_shipping_method($observer)
43
+ {
44
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
45
+ $address = $quote->getShippingAddress();
46
+ if ($address->getShippingMethod() == "dpdparcelshops_dpdparcelshops") {
47
+ $address->unsetAddressId()
48
+ ->unsetTelephone()
49
+ ->setSaveInAddressBook(0)
50
+ ->setFirstname('DPD ParcelShop: ')
51
+ ->setLastname($quote->getDpdCompany())
52
+ ->setStreet($quote->getDpdStreet())
53
+ ->setCity($quote->getDpdCity())
54
+ ->setPostcode($quote->getDpdZipcode())
55
+ ->setCountryId($quote->getDpdCountry())
56
+ ->save();
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Sets generate return label button on order detail view in the admin.
62
+ * Sets download dpdlabel button on shipment order detail.
63
+ *
64
+ * @param $observer
65
+ */
66
+ public function core_block_abstract_to_html_before($observer)
67
+ {
68
+ $block = $observer->getBlock();
69
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View && $block->getRequest()->getControllerName() == 'sales_order') {
70
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
71
+ $block->addButton('print_retour_label', array(
72
+ 'label' => Mage::helper('dpd')->__('DPD Return Label'),
73
+ 'onclick' => 'setLocation(\'' . Mage::helper("adminhtml")->getUrl('adminhtml/dpdorder/generateRetourLabel/order_id/' . $orderId) . '\')',
74
+ 'class' => 'go'
75
+ ));
76
+
77
+ }
78
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_Shipment_View && $block->getRequest()->getControllerName() == "sales_order_shipment") {
79
+ $shipment = Mage::registry('current_shipment');
80
+ $shipmentId = $shipment->getId();
81
+ $order = Mage::getModel('sales/order')->load($shipment->getOrderId());
82
+ if (strpos($order->getShippingMethod(), 'dpd') !== false) {
83
+ $block->addButton('download_dpd_label', array(
84
+ 'label' => Mage::helper('dpd')->__('Download DPD Label'),
85
+ 'onclick' => 'setLocation(\'' . Mage::helper("adminhtml")->getUrl('adminhtml/dpdorder/downloadDpdLabel/shipment_id/' . $shipmentId) . '\')',
86
+ 'class' => 'scalable save'
87
+ ));
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Calculate and set the weight on the shipping to pass it to the webservice after a standard shipment save.
94
+ *
95
+ * @param $observer
96
+ */
97
+ public function sales_order_shipment_save_before($observer)
98
+ {
99
+ $shipment = $observer->getEvent()->getShipment();
100
+ if (!$shipment->hasId() && !$shipment->getTotalWeight()) {
101
+ $weight = Mage::helper('dpd')->calculateTotalShippingWeight($shipment);
102
+ $shipment->setTotalWeight($weight);
103
+ }
104
+ }
105
+ }
app/code/community/DPD/Shipping/Model/Returnlabels.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Returnlabels
12
+ */
13
+ class DPD_Shipping_Model_Returnlabels extends Mage_Core_Model_Abstract
14
+ {
15
+ /**
16
+ * Initialise the model.
17
+ */
18
+ protected function _construct()
19
+ {
20
+ $this->_init("dpd/returnlabels");
21
+ }
22
+
23
+ /**
24
+ * Gets label from webservice, saves it and returns the saved id.
25
+ *
26
+ * @param $orderId
27
+ * @return int
28
+ */
29
+ public function generateLabelAndSave($orderId)
30
+ {
31
+ $order = Mage::getModel('sales/order')->load($orderId);
32
+ $billingAddress = $order->getBillingAddress();
33
+ $recipient = array(
34
+ 'name1' => $billingAddress->getFirstname() . " " . $billingAddress->getLastname(),
35
+ 'street' => $billingAddress->getStreet(1) . " " . $billingAddress->getStreet(2),
36
+ 'country' => $billingAddress->getCountry(),
37
+ 'zipCode' => $billingAddress->getPostcode(),
38
+ 'city' => $billingAddress->getCity()
39
+ );
40
+ $returnlabel = Mage::getSingleton('dpd/webservice')->getReturnLabel($recipient);
41
+ if(!$returnlabel){
42
+ return false;
43
+ }
44
+ //convertstring to pdf and save
45
+ Mage::helper('dpd')->generatePdfAndSave($returnlabel->parcellabelsPDF, 'returnlabel', $order->getIncrementId() ."-". $returnlabel->shipmentResponses->parcelInformation->parcelLabelNumber);
46
+
47
+ //save labeldata for admin display
48
+ $returnLabelObject = new DPD_Shipping_Model_Returnlabels;
49
+ $returnLabelObject
50
+ ->setLabelNumber($returnlabel->shipmentResponses->parcelInformation->parcelLabelNumber)
51
+ ->setLabelPdfUrl( $order->getIncrementId() ."-".$returnlabel->shipmentResponses->parcelInformation->parcelLabelNumber . ".pdf")
52
+ ->setLabelInstructionsUrl( $order->getIncrementId() ."-".$returnlabel->shipmentResponses->parcelInformation->parcelLabelNumber . "-instructions.pdf")
53
+ ->setOrderId($orderId)
54
+ ->save();
55
+ return $returnLabelObject->getId();
56
+ }
57
+
58
+ /**
59
+ * Sends email with custom dpd template, attaches both instruction and label pdf.
60
+ *
61
+ * @param $order
62
+ * @param $returnId
63
+ * @return $this
64
+ */
65
+ public function sendEmail($order, $returnId)
66
+ {
67
+ $translate = Mage::getSingleton('core/translate');
68
+ $translate->setTranslateInline(false);
69
+ $returnLabel = Mage::getModel('dpd/returnlabels')->load($returnId);
70
+ $billingAddress = $order->getBillingAddress();
71
+ $attachments = array($returnLabel->getLabelPdfUrl(), $returnLabel->getLabelInstructionsUrl());
72
+ $templateVars = array('returnlabel' => $returnLabel, 'order' => $order, 'store' => Mage::app()->getStore($order->getStoreId()));
73
+ $transactionalEmail = Mage::getModel('core/email_template')
74
+ ->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStoreId()));
75
+ foreach ($attachments as $pdf_attachment) {
76
+ if (!empty($pdf_attachment) && file_exists(Mage::getBaseDir('media')."/dpd/returnlabel/".$pdf_attachment)) {
77
+ $transactionalEmail
78
+ ->getMail()
79
+ ->createAttachment(
80
+ file_get_contents(Mage::getBaseDir('media')."/dpd/returnlabel/".$pdf_attachment),
81
+ Zend_Mime::TYPE_OCTETSTREAM,
82
+ Zend_Mime::DISPOSITION_ATTACHMENT,
83
+ Zend_Mime::ENCODING_BASE64,
84
+ basename($pdf_attachment)
85
+ );
86
+ }
87
+ }
88
+ $transactionalEmail
89
+ ->sendTransactional('dpd_returnlabel_email_template',
90
+ array('name' => Mage::getStoreConfig('trans_email/ident_support/name'),
91
+ 'email' => Mage::getStoreConfig('trans_email/ident_support/email')),
92
+ $billingAddress->getEmail(),
93
+ $billingAddress->getFirstname() . " " . $billingAddress->getLastname(),
94
+ $templateVars);
95
+ $translate->setTranslateInline(true);
96
+ return $this;
97
+ }
98
+
99
+ /**
100
+ * Deletes attachments and pdf when returnlabel call failed, this is to avoid empty/corrupt data.
101
+ *
102
+ * @param $returnId
103
+ */
104
+ public function deleteEntryAndAttachments($returnId){
105
+ $returnLabel = Mage::getModel('dpd/returnlabels')->load($returnId);
106
+ $attachments = array($returnLabel->getLabelPdfUrl(), $returnLabel->getLabelInstructionsUrl());
107
+ foreach ($attachments as $pdf_attachment) {
108
+ $file = Mage::getBaseDir('media')."/dpd/returnlabels/".$pdf_attachment;
109
+ if(file_exists($file)){
110
+ unlink($file);
111
+ }
112
+ }
113
+ $returnLabel->delete();
114
+ }
115
+
116
+ /**
117
+ * Generates and saves the instructions pdf with shoplogo and returnid.
118
+ *
119
+ * @param $orderId
120
+ * @param $returnId
121
+ * @return string
122
+ */
123
+ public function generateInstructionsPdf($orderId, $returnId){
124
+ $returnlabel = Mage::getModel('dpd/returnlabels')->load($returnId);
125
+ $pdf = Zend_Pdf::load(Mage::getBaseDir('skin') . DS . 'adminhtml' . DS . 'default' . DS . 'default' . DS . 'dpd' . DS . 'returnlabel' . DS . 'instructions.pdf');
126
+ $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA_BOLD);
127
+ $page = $pdf->pages[0];
128
+ $page->setFont($font, 15);
129
+ if(Mage::getStoreConfig('design/email/logo') && strpos(Mage::getStoreConfig('design/email/logo'),'.gif') === false && Mage::getVersion() >= "1.7"){
130
+ $uploadDir = Mage_Adminhtml_Model_System_Config_Backend_Email_Logo::UPLOAD_DIR;
131
+ $fullFileName = Mage::getBaseDir('media') . DS . $uploadDir . DS . Mage::getStoreConfig('design/email/logo');
132
+ $image = Zend_Pdf_Image::imageWithPath($fullFileName);
133
+ $imgWidthPts = $image->getPixelWidth() * 72 / 96;
134
+ $imgHeightPts = $image->getPixelHeight() * 72 / 96;
135
+ $x1 = 50;
136
+ $y1 = 687;
137
+ $page->drawImage($image, $x1, $y1, $x1 + $imgWidthPts, $y1 + $imgHeightPts);
138
+ }
139
+ elseif(Mage::getVersion() < "1.7"){
140
+ try{
141
+ $fullFileName = Mage::getBaseDir('skin') . DS . 'frontend' . DS .'default' . DS . 'default' . DS . Mage::getStoreConfig('design/header/logo_src');
142
+ $image = Zend_Pdf_Image::imageWithPath($fullFileName);
143
+ $imgWidthPts = $image->getPixelWidth() * 72 / 96;
144
+ $imgHeightPts = $image->getPixelHeight() * 72 / 96;
145
+ $x1 = 50;
146
+ $y1 = 687;
147
+ $page->drawImage($image, $x1, $y1, $x1 + $imgWidthPts, $y1 + $imgHeightPts);
148
+ }
149
+ catch(Exception $e){
150
+ Mage::helper('dpd')->log('Instructions PDF: No logo found or incorrect file format', Zend_Log::INFO);
151
+ }
152
+ }
153
+ else{
154
+ Mage::helper('dpd')->log('Instructions PDF: No logo found or incorrect file format', Zend_Log::INFO);
155
+ }
156
+ $page->drawText(implode(' ',str_split($returnlabel->getLabelNumber(), 4)), '321', '215');
157
+ $order = Mage::getResourceModel('sales/order_collection')->addAttributeToSelect('increment_id')->addAttributeToFilter('entity_id', array('eq' => $orderId))->getFirstItem();
158
+ Mage::helper('dpd')->generatePdfAndSave($pdf->render(),'returnlabel',$order->getIncrementId().'-'.$returnlabel->getLabelNumber()."-instructions");
159
+ }
160
+ }
app/code/community/DPD/Shipping/Model/Specialparcelshops.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Specialparcelshops
12
+ */
13
+ class DPD_Shipping_Model_Specialparcelshops extends Mage_Core_Model_Abstract
14
+ {
15
+ /**
16
+ * Initialise the model.
17
+ */
18
+ protected function _construct()
19
+ {
20
+ $this->_init("dpd/specialparcelshops");
21
+ }
22
+ }
app/code/community/DPD/Shipping/Model/System/Config/Source/Display.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_System_Config_Source_Display
12
+ */
13
+ class DPD_Shipping_Model_System_Config_Source_Display
14
+ {
15
+ /**
16
+ * Options getter.
17
+ * Returns an option array for Google maps display.
18
+ *
19
+ * @return array
20
+ *
21
+ */
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => 1, 'label' => Mage::helper('dpd')->__('Overlay')),
26
+ array('value' => 0, 'label' => Mage::helper('dpd')->__('Inline')),
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Get options in "key-value" format.
32
+ * Returns an array for Google maps display. (Magento basically expects both functions)
33
+ *
34
+ * @return array
35
+ *
36
+ */
37
+ public function toArray()
38
+ {
39
+ return array(
40
+ 0 => Mage::helper('dpd')->__('Inline'),
41
+ 1 => Mage::helper('dpd')->__('Overlay'),
42
+ );
43
+ }
44
+
45
+ }
app/code/community/DPD/Shipping/Model/System/Config/Source/Paperformat.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_System_Config_Source_Paperformat
12
+ */
13
+ class DPD_Shipping_Model_System_Config_Source_Paperformat
14
+ {
15
+ /**
16
+ * Options getter.
17
+ * Returns an option array for Label pdf size.
18
+ *
19
+ * @return array
20
+ *
21
+ */
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => 1, 'label' => Mage::helper('dpd')->__('A4')),
26
+ array('value' => 0, 'label' => Mage::helper('dpd')->__('A6')),
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Get options in "key-value" format.
32
+ * Returns an array for Label pdf size. (Magento basically expects both functions)
33
+ *
34
+ * @return array
35
+ *
36
+ */
37
+ public function toArray()
38
+ {
39
+ return array(
40
+ 0 => Mage::helper('dpd')->__('A6'),
41
+ 1 => Mage::helper('dpd')->__('A4'),
42
+ );
43
+ }
44
+
45
+ }
app/code/community/DPD/Shipping/Model/System/Config/Source/Ratetypes.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_System_Config_Source_Ratetypes
12
+ */
13
+ class DPD_Shipping_Model_System_Config_Source_Ratetypes
14
+ {
15
+
16
+ /**
17
+ * Options getter.
18
+ * Returns an option array for Shipping cost handler.
19
+ *
20
+ * @return array
21
+ *
22
+ */
23
+ public function toOptionArray()
24
+ {
25
+ return array(
26
+ array('value' => 1, 'label' => Mage::helper('dpd')->__('Table Rates')),
27
+ array('value' => 0, 'label' => Mage::helper('dpd')->__('Flat Rate')),
28
+ );
29
+ }
30
+
31
+ /**
32
+ * Get options in "key-value" format.
33
+ * Returns an array for Shipping cost handler. (Magento basically expects both functions)
34
+ *
35
+ * @return array
36
+ *
37
+ */
38
+ public function toArray()
39
+ {
40
+ return array(
41
+ 0 => Mage::helper('dpd')->__('Flat Rate'),
42
+ 1 => Mage::helper('dpd')->__('Table Rates'),
43
+ );
44
+ }
45
+
46
+ }
app/code/community/DPD/Shipping/Model/System/Config/Source/Weightunit.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_System_Config_Source_Weightunit
12
+ */
13
+ class DPD_Shipping_Model_System_Config_Source_Weightunit
14
+ {
15
+ /**
16
+ * Options getter.
17
+ * Returns an option array for unit weight to pass to the webservice.
18
+ *
19
+ * @return array
20
+ *
21
+ */
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => 100, 'label' => Mage::helper('dpd')->__('kg')),
26
+ array('value' => 0.1, 'label' => Mage::helper('dpd')->__('g')),
27
+ array('value' => 45.3592, 'label' => Mage::helper('dpd')->__('lb')),
28
+ );
29
+ }
30
+
31
+ /**
32
+ * Get options in "key-value" format.
33
+ * Returns an array for unit weight to pass to the webservice. (Magento basically expects both functions)
34
+ *
35
+ * @return array
36
+ *
37
+ */
38
+ public function toArray()
39
+ {
40
+ return array(
41
+ '100' => Mage::helper('dpd')->__('kg'),
42
+ '0,1' => Mage::helper('dpd')->__('g'),
43
+ '45.3592' => Mage::helper('dpd')->__('lb')
44
+ );
45
+ }
46
+
47
+ }
app/code/community/DPD/Shipping/Model/Webservice.php ADDED
@@ -0,0 +1,451 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Model_Webservice
12
+ */
13
+ class DPD_Shipping_Model_Webservice extends Mage_Core_Model_Abstract
14
+ {
15
+
16
+ /**
17
+ * Max number of times a login should be retried when the authentication token is expired.
18
+ */
19
+ CONST MAX_LOGIN_RETRY = 3;
20
+
21
+ /**
22
+ * The message communication language, should be en_US as instructed by DPD.
23
+ */
24
+ CONST MESSAGE_LANGUAGE = 'en_US';
25
+
26
+ /**
27
+ * Athentication namespace for the authentication header in soap requests.
28
+ */
29
+ CONST AUTHENTICATION_NAMESPACE = 'http://dpd.com/common/service/types/Authentication/2.0';
30
+
31
+ /**
32
+ * Path to login webservice wsdl.
33
+ */
34
+ CONST WEBSERVICE_LOGIN = 'LoginService/V2_0?wsdl';
35
+
36
+ /**
37
+ * Path to ParcelShopFinder webservice wsdl.
38
+ */
39
+ CONST WEBSERVICE_PARCELSHOP = 'ParcelShopFinderService/V3_0?wsdl';
40
+
41
+ /**
42
+ * Path to Shipment webservice wsdl.
43
+ */
44
+ CONST WEBSERVICE_SHIPMENT = 'ShipmentService/V2_0?wsdl';
45
+
46
+ /**
47
+ * Product type for shipmentservice, should be always 'CL' as instructed by DPD.
48
+ */
49
+ CONST SHIPMENTSERVICE_PRODUCT = 'CL';
50
+
51
+ /**
52
+ * Ordertype for shipmentservice, should be always 'consigment' as instructed by DPD.
53
+ */
54
+ CONST SHIPMENTSERVICE_ORDERTYPE = 'consignment';
55
+
56
+ /**
57
+ * Paperformat for Return labels, should always be 'A6' as instructed by DPD.
58
+ */
59
+ CONST SHIPMENTSERVICE_RETURN_PAPERFORMAT = 'A6';
60
+
61
+ /**
62
+ * XML path to configuration setting for webserviceurl.
63
+ */
64
+ CONST XML_PATH_DPD_URL = 'shipping/dpdclassic/webserviceurl';
65
+
66
+ /**
67
+ * XML path to configuration setting for userid.
68
+ */
69
+ CONST XML_PATH_DPD_USERID = 'shipping/dpdclassic/userid';
70
+
71
+ /**
72
+ * XML path to configuration setting for password.
73
+ */
74
+ CONST XML_PATH_DPD_PASSWORD = 'shipping/dpdclassic/password';
75
+
76
+ /**
77
+ * XML path to configuration setting for sender name.
78
+ */
79
+ CONST XML_PATH_DPD_SENDER_NAME = 'shipping/dpdclassic/sender_name';
80
+
81
+ /**
82
+ * XML path to configuration setting for sender street.
83
+ */
84
+ CONST XML_PATH_DPD_SENDER_STREET = 'shipping/dpdclassic/sender_street';
85
+
86
+ /**
87
+ * XML path to configuration setting for sender streetnumber.
88
+ */
89
+ CONST XML_PATH_DPD_SENDER_STREETNUMBER = 'shipping/dpdclassic/sender_streetnumber';
90
+
91
+ /**
92
+ * XML path to configuration setting for sender country.
93
+ */
94
+ CONST XML_PATH_DPD_SENDER_COUNTRY = 'shipping/dpdclassic/sender_country';
95
+
96
+ /**
97
+ * XML path to configuration setting for sender zipcode.
98
+ */
99
+ CONST XML_PATH_DPD_SENDER_ZIPCODE = 'shipping/dpdclassic/sender_zipcode';
100
+
101
+ /**
102
+ * XML path to configuration setting for sender city.
103
+ */
104
+ CONST XML_PATH_DPD_SENDER_CITY = 'shipping/dpdclassic/sender_city';
105
+
106
+ /**
107
+ * XML path to configuration setting for paperformat of shipping labels.
108
+ */
109
+ CONST XML_PATH_DPD_PAPERFORMAT = 'shipping/dpdclassic/paperformat';
110
+
111
+ /**
112
+ * XML path to configuration setting for weight unit to send to webservice;
113
+ */
114
+ CONST XML_PATH_DPD_WEIGHTUNIT = 'shipping/dpdclassic/weight_unit';
115
+
116
+ /**
117
+ * XML path to configuration setting for the maximum number of parcelshops that should be returned by the webservice.
118
+ */
119
+ CONST XML_PATH_PARCELSHOP_MAXPOINTERS = 'carriers/dpdparcelshops/google_maps_maxpointers';
120
+
121
+ /**
122
+ * Add trailing slash to url if not exists.
123
+ *
124
+ * @param $path
125
+ * @return mixed|string
126
+ */
127
+ protected function _getWebserviceUrl($path)
128
+ {
129
+ $url = Mage::getStoreConfig($path);
130
+ if (substr($url, -1) != '/') {
131
+ $url = $url . DS;
132
+ }
133
+
134
+ return $url;
135
+ }
136
+
137
+ /**
138
+ * Login webservice with ParcelShop credentials.
139
+ *
140
+ * @return mixed
141
+ */
142
+ protected function _login()
143
+ {
144
+ $webserviceUrl = $this->_getWebserviceUrl(self::XML_PATH_DPD_URL) . self::WEBSERVICE_LOGIN;
145
+ $delisId = Mage::getStoreConfig(self::XML_PATH_DPD_USERID);
146
+ $password = Mage::helper('core')->decrypt(Mage::getStoreConfig(self::XML_PATH_DPD_PASSWORD));
147
+
148
+ try {
149
+ $client = new SoapClient($webserviceUrl);
150
+
151
+ $result = $client->getAuth(array(
152
+ 'delisId' => $delisId,
153
+ 'password' => $password,
154
+ 'messageLanguage' => self::MESSAGE_LANGUAGE)
155
+ );
156
+
157
+ Mage::helper('dpd')->log('Login for webservice succeeded', Zend_Log::INFO);
158
+ Mage::helper('dpd')->log($result, Zend_Log::DEBUG);
159
+ } catch (SoapFault $soapE) {
160
+ Mage::helper('dpd')->log('Webservice Login failed:', Zend_Log::ERR);
161
+ Mage::helper('dpd')->log($soapE->detail, Zend_Log::ERR);
162
+ Mage::getSingleton('adminhtml/session')->addError('A problem occured with the ParcelShop webservice, please contact the store owner.');
163
+ return false;
164
+ } catch (Exception $e) {
165
+ Mage::helper('dpd')->log($e->getMessage(), Zend_Log::ERR);
166
+ return false;
167
+ }
168
+
169
+ $this->_setDepot($result->return->depot);
170
+ $this->_setAuthToken($result->return->authToken);
171
+ return $result->return;
172
+ }
173
+
174
+ /**
175
+ * Set depot in core/session
176
+ *
177
+ * @param $depot
178
+ */
179
+ protected function _setDepot($depot)
180
+ {
181
+ Mage::getSingleton('core/session')->setDpdDepot($depot);
182
+ }
183
+
184
+ /**
185
+ * Set authToken in core/session
186
+ *
187
+ * @param $authToken
188
+ */
189
+ protected function _setAuthToken($authToken)
190
+ {
191
+ Mage::getSingleton('core/session')->setDpdAuthToken($authToken);
192
+
193
+ }
194
+
195
+ /**
196
+ * Get depot from core/session
197
+ *
198
+ * @return mixed
199
+ */
200
+ protected function _getDepot()
201
+ {
202
+ if(!Mage::getSingleton('core/session')->getDpdDepot()){
203
+ $this->_login();
204
+ }
205
+
206
+ return Mage::getSingleton('core/session')->getDpdDepot();
207
+ }
208
+
209
+ /**
210
+ * Get authToken from core/session
211
+ *
212
+ * @return mixed
213
+ */
214
+ protected function _getAuthToken()
215
+ {
216
+ if(!Mage::getSingleton('core/session')->getDpdAuthToken()){
217
+ $this->_login();
218
+ }
219
+ return Mage::getSingleton('core/session')->getDpdAuthToken();
220
+ }
221
+
222
+ /**
223
+ * Generates an authentication header that needs to be used for parcelshops and labels.
224
+ *
225
+ * @return SOAPHeader
226
+ */
227
+ protected function _getSoapHeader()
228
+ {
229
+ $delisId = Mage::getStoreConfig(self::XML_PATH_DPD_USERID);
230
+
231
+ $soapHeaderBody = array(
232
+ 'delisId' => $delisId,
233
+ 'authToken' => $this->_getAuthToken(),
234
+ 'messageLanguage' => self::MESSAGE_LANGUAGE
235
+ );
236
+
237
+ return new SOAPHeader(self::AUTHENTICATION_NAMESPACE, 'authentication', $soapHeaderBody, false);
238
+ }
239
+
240
+ /**
241
+ * Returns the sender information filled in the backend, is used for the generation of labels.
242
+ *
243
+ * @return array
244
+ */
245
+ protected function _getSenderInformation()
246
+ {
247
+ return array(
248
+ 'name1' => Mage::getStoreConfig(self::XML_PATH_DPD_SENDER_NAME),
249
+ 'street' => Mage::getStoreConfig(self::XML_PATH_DPD_SENDER_STREET),
250
+ 'houseNo' => Mage::getStoreConfig(self::XML_PATH_DPD_SENDER_STREETNUMBER),
251
+ 'country' => Mage::getStoreConfig(self::XML_PATH_DPD_SENDER_COUNTRY),
252
+ 'zipCode' => Mage::getStoreConfig(self::XML_PATH_DPD_SENDER_ZIPCODE),
253
+ 'city' => Mage::getStoreConfig(self::XML_PATH_DPD_SENDER_CITY)
254
+ );
255
+ }
256
+
257
+ /**
258
+ * Does the webservice call towards dpd for functions with authentication.
259
+ * If the authentication token is expired a new token will be asked MAX_LOGIN_RETRY times.
260
+ *
261
+ * @param $webserviceUrl
262
+ * @param $method
263
+ * @param $parameters
264
+ * @return mixed
265
+ */
266
+ protected function _webserviceCall($webserviceUrl, $method, $parameters)
267
+ {
268
+ $stop = false;
269
+ $count = 0;
270
+
271
+ while (!$stop && $count++ < self::MAX_LOGIN_RETRY) {
272
+ try {
273
+ $client = new SoapClient($webserviceUrl);
274
+ $soapHeader = $this->_getSoapHeader();
275
+ $client->__setSoapHeaders($soapHeader);
276
+
277
+ $result = $client->__soapCall($method, array($parameters));
278
+ $stop = true;
279
+
280
+ Mage::helper('dpd')->log('Webservice ' . $method . ' succeeded', Zend_Log::INFO);
281
+ Mage::helper('dpd')->log($result, Zend_Log::DEBUG);
282
+
283
+ } catch (SoapFault $soapE) {
284
+ if (isset($soapE->detail)) {
285
+ if ($soapE->detail->authenticationFault->errorCode == 'LOGIN_5') {
286
+ Mage::helper('dpd')->log('Athentication token expired, retrying...', Zend_Log::INFO);
287
+ $this->_login();
288
+ } else {
289
+ Mage::helper('dpd')->log('Webservice ' . $method . ' failed:', Zend_Log::ERR);
290
+ Mage::helper('dpd')->log($soapE->detail, Zend_Log::ERR);
291
+ Mage::getSingleton('adminhtml/session')->addError($soapE->detail->authenticationFault->errorMessage);
292
+ return false;
293
+ }
294
+ } else {
295
+ Mage::helper('dpd')->log($soapE->getMessage(), Zend_Log::ERR);
296
+ Mage::getSingleton('adminhtml/session')->addError($soapE->getMessage());
297
+ return false;
298
+ }
299
+ } catch (Exception $e) {
300
+ Mage::helper('dpd')->log($e->getMessage(), Zend_Log::ERR);
301
+ Mage::getSingleton('adminhtml/session')->addError('Something went wrong with the webservice, please check the log files.');
302
+ return false;
303
+ }
304
+ }
305
+
306
+ if ($stop == false) {
307
+ Mage::helper('dpd')->log('Athentication went wrong!', Zend_Log::ERR);
308
+ return false;
309
+ } else {
310
+ return $result;
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Returns if the login webservice works.
316
+ *
317
+ * @return bool
318
+ */
319
+ public function getLoginResult()
320
+ {
321
+ if ($this->_getAuthToken() && Mage::getStoreConfig(self::XML_PATH_DPD_USERID) && Mage::getStoreConfig(self::XML_PATH_DPD_PASSWORD)){
322
+ return true;
323
+ }else{
324
+ return false;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Get parcelshops from webservice findParcelShopsByGeoData.
330
+ *
331
+ * @param $longitude
332
+ * @param $latitude
333
+ * @return mixed
334
+ */
335
+ public function getParcelShops($longitude, $latitude)
336
+ {
337
+ $webserviceUrl = $this->_getWebserviceUrl(self::XML_PATH_DPD_URL) . self::WEBSERVICE_PARCELSHOP;
338
+ $limit = Mage::getStoreConfig(self::XML_PATH_PARCELSHOP_MAXPOINTERS);
339
+ $parameters = array(
340
+ 'longitude' => $longitude,
341
+ 'latitude' => $latitude,
342
+ 'limit' => $limit
343
+ );
344
+
345
+ $result = $this->_webserviceCall($webserviceUrl, 'findParcelShopsByGeoData', $parameters);
346
+ return $result;
347
+
348
+ }
349
+
350
+ /**
351
+ * Get a returnlabel from webservice storeOrders.
352
+ * $recipient = array('name1' => '', 'street' => '', 'country' => '', 'zipCode' => '', 'city' => '');
353
+ *
354
+ * @param $recipient
355
+ * @return mixed
356
+ */
357
+ public function getReturnLabel($recipient)
358
+ {
359
+ $webserviceUrl = $this->_getWebserviceUrl(self::XML_PATH_DPD_URL) . self::WEBSERVICE_SHIPMENT;
360
+ $sendingDepot = $this->_getDepot();
361
+ $sender = $this->_getSenderInformation();
362
+
363
+ $parameters = array(
364
+ 'paperFormat' => self::SHIPMENTSERVICE_RETURN_PAPERFORMAT,
365
+ 'order' => array(
366
+ 'generalShipmentData' => array(
367
+ 'sendingDepot' => $sendingDepot,
368
+ 'product' => self::SHIPMENTSERVICE_PRODUCT,
369
+ 'sender' => $sender,
370
+ 'recipient' => $recipient
371
+ ),
372
+ 'parcels' => array(
373
+ 'returns' => 1
374
+ ),
375
+ 'productAndServiceData' => array(
376
+ 'orderType' => self::SHIPMENTSERVICE_ORDERTYPE
377
+ )
378
+ ));
379
+
380
+ $result = $this->_webserviceCall($webserviceUrl, 'storeOrders', $parameters);
381
+ return $result->orderResult;
382
+ }
383
+
384
+ /**
385
+ * Get a shippinglabel from webservice storeOrders.
386
+ * $recipient = array('name1' => '', 'street' => '', 'country' => '', 'zipCode' => '', 'city' => '');
387
+ *
388
+ * @param $recipient
389
+ * @param $order
390
+ * @param $shipment
391
+ * @param bool $parcelshop
392
+ * @return mixed
393
+ */
394
+ public function getShippingLabel($recipient, Mage_Sales_Model_Order $order, $shipment, $parcelshop = false)
395
+ {
396
+ $webserviceUrl = $this->_getWebserviceUrl(self::XML_PATH_DPD_URL) . self::WEBSERVICE_SHIPMENT;
397
+ $sendingDepot = $this->_getDepot();
398
+ $sender = $this->_getSenderInformation();
399
+
400
+ $paperFormatSource = Mage::getModel('dpd/system_config_source_paperformat')->toArray();
401
+ $paperFormat = $paperFormatSource[Mage::getStoreConfig(self::XML_PATH_DPD_PAPERFORMAT)];
402
+
403
+ $language = Mage::helper('dpd')->getLanguageFromStore($order->getStoreId());
404
+
405
+ if ($parcelshop) {
406
+ $productAndServiceData = array(
407
+ 'orderType' => self::SHIPMENTSERVICE_ORDERTYPE,
408
+ 'parcelShopDelivery' => array(
409
+ 'parcelShopId' => $order->getDpdParcelshopId(),
410
+ 'parcelShopNotification' => array(
411
+ 'channel' => 1, //email
412
+ 'value' => $order->getCustomerEmail(),
413
+ 'language' => $language
414
+ )
415
+ ));
416
+ } else {
417
+ $productAndServiceData = array(
418
+ 'orderType' => self::SHIPMENTSERVICE_ORDERTYPE,
419
+ 'predict' => array(
420
+ 'channel' => 1, //email
421
+ 'value' => $order->getCustomerEmail(),
422
+ 'language' => $language
423
+ ));
424
+ }
425
+ if(Mage::getStoreConfig(self::XML_PATH_DPD_WEIGHTUNIT) == ""){
426
+ $weight = $shipment->getTotalWeight() * 100;
427
+ }
428
+ else{
429
+ $weight = $shipment->getTotalWeight() * Mage::getStoreConfig(self::XML_PATH_DPD_WEIGHTUNIT);
430
+ }
431
+ $parameters = array(
432
+ 'paperFormat' => $paperFormat,
433
+ 'order' => array(
434
+ 'generalShipmentData' => array(
435
+ 'mpsCustomerReferenceNumber1' => $order->getIncrementId(),
436
+ 'sendingDepot' => $sendingDepot,
437
+ 'product' => self::SHIPMENTSERVICE_PRODUCT,
438
+ 'sender' => $sender,
439
+ 'recipient' => $recipient
440
+ ),
441
+ 'parcels' => array(
442
+ 'customerReferenceNumber1' => $shipment->getIncrementId(),
443
+ 'weight' => round($weight,0)
444
+ ),
445
+ 'productAndServiceData' => $productAndServiceData
446
+ ));
447
+
448
+ $result = $this->_webserviceCall($webserviceUrl, 'storeOrders', $parameters);
449
+ return $result->orderResult;
450
+ }
451
+ }
app/code/community/DPD/Shipping/controllers/Adminhtml/DpdconfigController.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Adminhtml_DpdconfigController
12
+ */
13
+ class DPD_Shipping_Adminhtml_DpdconfigController extends Mage_Adminhtml_Controller_Action
14
+ {
15
+ /**
16
+ * Export shipping table rates in csv format
17
+ *
18
+ */
19
+ public function exportDpdClassicTableratesAction()
20
+ {
21
+ $fileName = 'dpdclassic_tablerates.csv';
22
+ /** @var $gridBlock Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */
23
+ $gridBlock = $this->getLayout()->createBlock('dpd/adminhtml_shipping_carrier_dpdclassic_tablerate_grid');
24
+ $website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
25
+ if ($this->getRequest()->getParam('conditionName')) {
26
+ $conditionName = $this->getRequest()->getParam('conditionName');
27
+ } else {
28
+ $conditionName = $website->getConfig('carriers/dpdclassic/condition_name');
29
+ }
30
+ $gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName);
31
+ $content = $gridBlock->getCsvFile();
32
+ $this->_prepareDownloadResponse($fileName, $content);
33
+ }
34
+ /**
35
+ * Export shipping table rates in csv format
36
+ *
37
+ */
38
+ public function exportDpdParcelshopsTableratesAction()
39
+ {
40
+ $fileName = 'dpdparcelshops_tablerates.csv';
41
+ /** @var $gridBlock Mage_Adminhtml_Block_Shipping_Carrier_Tablerate_Grid */
42
+ $gridBlock = $this->getLayout()->createBlock('dpd/adminhtml_shipping_carrier_dpdparcelshops_tablerate_grid');
43
+ $website = Mage::app()->getWebsite($this->getRequest()->getParam('website'));
44
+ if ($this->getRequest()->getParam('conditionName')) {
45
+ $conditionName = $this->getRequest()->getParam('conditionName');
46
+ } else {
47
+ $conditionName = $website->getConfig('carriers/dpdparcelshops/condition_name');
48
+ }
49
+ $gridBlock->setWebsiteId($website->getId())->setConditionName($conditionName);
50
+ $content = $gridBlock->getCsvFile();
51
+ $this->_prepareDownloadResponse($fileName, $content);
52
+ }
53
+ }
app/code/community/DPD/Shipping/controllers/Adminhtml/DpdorderController.php ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_Adminhtml_DpdorderController
12
+ */
13
+ class DPD_Shipping_Adminhtml_DpdorderController extends Mage_Adminhtml_Controller_Action
14
+ {
15
+ /**
16
+ * Load indexpage of this controller.
17
+ */
18
+ public function indexAction()
19
+ {
20
+ Mage::getModel('core/session')->setDpdReturn(0);
21
+ $this->_title($this->__('dpd'))->_title($this->__('DPD Orders'));
22
+ $this->loadLayout();
23
+ $this->_setActiveMenu('sales/sales');
24
+ $this->_addContent($this->getLayout()->createBlock('dpd/adminhtml_sales_order'));
25
+ $this->renderLayout();
26
+ }
27
+
28
+ /**
29
+ * Load the grid.
30
+ */
31
+ public function gridAction()
32
+ {
33
+ $this->loadLayout();
34
+ $this->getResponse()->setBody(
35
+ $this->getLayout()->createBlock('dpd/adminhtml_sales_order_grid')->toHtml()
36
+ );
37
+ }
38
+
39
+ /**
40
+ * Export csvs, this fetches all current gridentries.
41
+ */
42
+ public function exportDPDOrdersCsvAction()
43
+ {
44
+ $fileName = 'dpd_orders.csv';
45
+ $grid = $this->getLayout()->createBlock('dpd/adminhtml_sales_order_grid');
46
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
47
+ }
48
+
49
+ /**
50
+ * Export excel (xml), this fetches all current gridentries.
51
+ */
52
+ public function exportDPDOrdersExcelAction()
53
+ {
54
+ $fileName = 'dpd_orders.xml';
55
+ $grid = $this->getLayout()->createBlock('dpd/adminhtml_sales_order_grid');
56
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
57
+ }
58
+
59
+ /**
60
+ * Generate the returnlabel and the instructions pdf, this fetches the label from dpd webservices.
61
+ * On fail this method will remove all db entries / generated pdfs to prevent outputting wrong entries.
62
+ * Logs all errors in try catch.
63
+ */
64
+ public function generateRetourLabelAction()
65
+ {
66
+ $orderId = $this->getRequest()->getParam('order_id');
67
+ try {
68
+ $returnId = Mage::getModel('dpd/returnlabels')->generateLabelAndSave($orderId);
69
+ if($returnId){
70
+ Mage::getModel('dpd/returnlabels')->generateInstructionsPdf($orderId, $returnId);
71
+ $message = Mage::helper('dpd')->__("Your return label and instructions file have been generated and is available under 'DPD Return Labels' in this order.");
72
+ Mage::getSingleton('core/session')->addSuccess($message);
73
+ }
74
+ } catch (Exception $e) {
75
+ Mage::getModel('dpd/returnlabels')->deleteEntryAndAttachments($returnId);
76
+ Mage::getSingleton('core/session')->addError($e->getMessage());
77
+ $this->_redirect('adminhtml/sales_order/view/order_id/' . $orderId);
78
+ return $this;
79
+ }
80
+ $this->_redirect('adminhtml/sales_order/view/order_id/' . $orderId);
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Call this to send an email with the dpd template.
86
+ * This calls the model to handle emails the magento way.
87
+ * Logs all errors in try catch.
88
+ */
89
+ public function sendEmailAction()
90
+ {
91
+ $orderId = $this->getRequest()->getParam('order_id');
92
+ $returnId = $this->getRequest()->getParam('return_id');
93
+ $order = Mage::getModel('sales/order')->load($orderId);
94
+ try {
95
+ Mage::getModel('dpd/returnlabels')->sendEmail($order, $returnId);
96
+ } catch (Exception $e) {
97
+ Mage::getSingleton('core/session')->addError($e->getMessage());
98
+ $this->_redirect('adminhtml/sales_order/view/order_id/' . $orderId);
99
+ return $this;
100
+ }
101
+ $message = Mage::helper('dpd')->__("The email with return label and instructions has been sent to %s.", $order->getShippingAddress()->getEmail());
102
+ Mage::getSingleton('core/session')->addSuccess($message);
103
+ $this->_redirect('adminhtml/sales_order/view/order_id/' . $orderId);
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * Generates a label and completes the shipment.
109
+ * This is called by the action in the order grid dropdown.
110
+ */
111
+ public function generateAndCompleteAction()
112
+ {
113
+ ini_set('max_execution_time', 120);
114
+ $orderIds = $this->getRequest()->getParam('entity_id');
115
+ $maxOrderCount = 10;
116
+ if(count($orderIds) > $maxOrderCount){
117
+ $message = Mage::helper('dpd')->__("The maximum number of orders to process is %s. You selected %s. Please deselect some orders and try again.",$maxOrderCount, count($orderIds));
118
+ Mage::getSingleton('core/session')->addError($message);
119
+ $this->_redirect('*/*/index');
120
+ return $this;
121
+ }
122
+ if (!is_array($orderIds)) {
123
+ try {
124
+ Mage::getModel('dpd/adminhtml_dpdgrid')->generateAndCompleteOrder($orderIds);
125
+ if(!is_object(Mage::getSingleton('core/session')->getMessages()->getLastAddedMessage())){
126
+ $message = Mage::helper('dpd')->__("Your label has been generated and statuses have been changed.");
127
+ Mage::getSingleton('core/session')->addSuccess($message);
128
+ }
129
+ } catch (Exception $e) {
130
+ Mage::helper('dpd')->log($e->getMessage(), Zend_Log::ERR);
131
+ $message = Mage::helper('dpd')->__("Your selected order is not ready to be shipped or has already been shipped, operation canceled.");
132
+ Mage::getSingleton('core/session')->addError($message);
133
+ }
134
+ } else {
135
+ try {
136
+ $counter = 0;
137
+ foreach ($orderIds as $orderId) {
138
+ // sleep(0.300) // uncomment this line if you encounter web service load problems - ONLY WHEN INSTRUCTED BY DPD !
139
+ try {
140
+ $result = Mage::getModel('dpd/adminhtml_dpdgrid')->generateAndCompleteOrder($orderId);
141
+ if($result){
142
+ $counter ++;
143
+ }
144
+ } catch (Exception $e) {
145
+ Mage::helper('dpd')->log($e->getMessage(), Zend_Log::ERR);
146
+ $order = Mage::getResourceModel('sales/order_collection')->addAttributeToSelect('increment_id')->addAttributeToFilter('entity_id', array('eq' => $orderId))->getFirstItem();
147
+ $message = Mage::helper('dpd')->__("The order with id %s is not ready to be shipped or has already been shipped.", $order->getIncrementId());
148
+ Mage::getSingleton('core/session')->addNotice($message);
149
+ }
150
+ }
151
+ if($counter > 0){
152
+ $message = Mage::helper('dpd')->__("%s label(s) have been generated and statuses have been changed.", $counter);
153
+ Mage::getSingleton('core/session')->addSuccess($message);
154
+ }
155
+ } catch (Exception $e) {
156
+ Mage::helper('dpd')->log($e->getMessage(), Zend_Log::ERR);
157
+ $message = Mage::helper('dpd')->__("Some of the selected orders are not ready to be shipped or have already been shipped, operation canceled.");
158
+ Mage::getSingleton('core/session')->addError($message);
159
+ }
160
+ }
161
+ $this->_redirect('*/*/index');
162
+ }
163
+
164
+ /**
165
+ * Zips all undownloaded labels and gives downloadresponse.
166
+ */
167
+ public function dowloadAllUndownloadedAction()
168
+ {
169
+ $orderIds = $this->getRequest()->getParam('entity_id');
170
+ try {
171
+ $path = Mage::getModel('dpd/adminhtml_dpdgrid')->processUndownloadedLabels($orderIds);
172
+ if (!$path) {
173
+ $message = Mage::helper('dpd')->__('No undownloaded labels found.');
174
+ Mage::getSingleton('core/session')->addError($message);
175
+ $this->_redirect('*/*/index');
176
+ } else {
177
+ $this->_prepareDownloadResponse('dpd_undownloaded.zip', file_get_contents($path));
178
+ }
179
+ } catch (Exception $e) {
180
+ Mage::helper('dpd')->log($e->getMessage(), Zend_Log::ERR);
181
+ $message = Mage::helper('dpd')->__("The file(s) could not be downloaded, please check your DPD logs.");
182
+ Mage::getSingleton('core/session')->addError($message);
183
+ $this->_redirect('*/*/index');
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Fetches the label and puts it in a download response.
189
+ */
190
+ public function downloadDpdLabelAction()
191
+ {
192
+ $shipmentId = $this->getRequest()->getParam('shipment_id');
193
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipmentId);
194
+ if ($shipment->getDpdLabelPath() == "") {
195
+ $message = Mage::helper('dpd')->__("No label generated yet - please perform the ‘Generate Label and Complete’ action from the overview.");
196
+ Mage::getSingleton('core/session')->addError($message);
197
+ $this->_redirect('*/sales_order_shipment/view/shipment_id/' . $shipmentId);
198
+ } else {
199
+ $pdf_Path = Mage::getBaseDir('media') . "/dpd/orderlabels/" . $shipment->getDpdLabelPath();
200
+ $pdf = Zend_Pdf::load($pdf_Path);
201
+ $this->_prepareDownloadResponse($shipment->getDpdLabelPath(), $pdf->render(), 'application/pdf');
202
+ $shipment->setDpdLabelExported(1)->save();
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Returns deleted message (used for customparcelshopdelete in sysconfig).
208
+ *
209
+ * @return void
210
+ */
211
+ public function checkAction()
212
+ {
213
+ $websiteId = $this->getRequest()->getPost('id');
214
+ $collection = Mage::getModel('dpd/specialparcelshops')->getCollection()->addFieldToFilter('parcelshop_website_id', array('eq' => $websiteId));
215
+ foreach ($collection->getItems() as $_item) {
216
+ $_item->delete();
217
+ }
218
+ $message = Mage::helper('dpd')->__("The ParcelShops for this website have been deleted.");
219
+ Mage::getSingleton('core/session')->addSuccess($message);
220
+ Mage::app()->getResponse()->setBody($websiteId);
221
+ }
222
+ }
app/code/community/DPD/Shipping/controllers/AjaxController.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ /**
11
+ * Class DPD_Shipping_AjaxController
12
+ */
13
+ class DPD_Shipping_AjaxController extends Mage_Core_Controller_Front_Action {
14
+ /**
15
+ * Load indexpage of this controller.
16
+ */
17
+ public function indexAction(){
18
+ $this->loadLayout();
19
+ $this->renderLayout();
20
+ }
21
+
22
+ /**
23
+ * Return window for overlay mode of the shipping method.
24
+ */
25
+ public function windowindexAction(){
26
+ $this->loadLayout();
27
+ if($this->getRequest()->getParam('windowed')){
28
+ $this->getLayout()->getBlock('dpd')->setIsAjax(true);
29
+ }
30
+ $this->renderLayout();
31
+ }
32
+
33
+ /**
34
+ * Saves the parcel and returns the selected parcelshop template.
35
+ */
36
+ public function saveparcelAction(){
37
+ $parcelData = $this->getRequest()->getPost();
38
+ Mage::getModel('checkout/cart')->getQuote()
39
+ ->setDpdSelected(1)
40
+ ->setDpdParcelshopId($parcelData['parcelShopId'])
41
+ ->setDpdCompany($parcelData['company'])
42
+ ->setDpdStreet($parcelData['houseno'])
43
+ ->setDpdZipcode($parcelData['zipcode'])
44
+ ->setDpdCity($parcelData['city'])
45
+ ->setDpdCountry($parcelData['country'])
46
+ ->setDpdExtraInfo($parcelData['extra_info'])
47
+ ->save();
48
+ $this->loadLayout();
49
+ $this->renderLayout();
50
+ }
51
+
52
+ /**
53
+ * Unsets selected parcelshop and returns select parcelshop template.
54
+ */
55
+ public function invalidateparcelAction(){
56
+ Mage::getModel('checkout/cart')->getQuote()->setDpdSelected(0)->save();
57
+ $this->loadLayout();
58
+ $this->renderLayout();
59
+ }
60
+ }
app/code/community/DPD/Shipping/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <sales>
5
+ <children>
6
+ <dpd translate="title" module="dpd">
7
+ <sort_order>20</sort_order>
8
+ <title>DPD Orders</title>
9
+ <action>adminhtml/dpdorder/</action>
10
+ </dpd>
11
+ </children>
12
+ </sales>
13
+ </menu>
14
+ <acl>
15
+ <resources>
16
+ <admin>
17
+ <children>
18
+ <sales>
19
+ <children>
20
+ <dpd translate="title" module="dpd">
21
+ <title>DPD Orders</title>
22
+ <sort_order>20</sort_order>
23
+ </dpd>
24
+ </children>
25
+ </sales>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>
app/code/community/DPD/Shipping/etc/config.xml ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <DPD_Shipping>
5
+ <version>0.1.0</version>
6
+ </DPD_Shipping>
7
+ </modules>
8
+ <global>
9
+ <fieldsets>
10
+ <sales_convert_quote>
11
+ <dpd_parcelshop_id>
12
+ <to_order>*</to_order>
13
+ </dpd_parcelshop_id>
14
+ </sales_convert_quote>
15
+ </fieldsets>
16
+ <blocks>
17
+ <dpd>
18
+ <class>DPD_Shipping_Block</class>
19
+ </dpd>
20
+ </blocks>
21
+ <models>
22
+ <dpd>
23
+ <class>DPD_Shipping_Model</class>
24
+ <resourceModel>dpd_mysql4</resourceModel>
25
+ </dpd>
26
+ <dpd_mysql4>
27
+ <class>DPD_Shipping_Model_Mysql4</class>
28
+ <entities>
29
+ <returnlabels>
30
+ <table>dpd_shipping_returnlabels</table>
31
+ </returnlabels>
32
+ <specialparcelshops>
33
+ <table>dpd_shipping_specialparcelshops</table>
34
+ </specialparcelshops>
35
+ <dpdclassic_tablerate>
36
+ <table>dpd_shipping_dpdclassic_tablerate</table>
37
+ </dpdclassic_tablerate>
38
+ <dpdparcelshops_tablerate>
39
+ <table>dpd_shipping_dpdparcelshops_tablerate</table>
40
+ </dpdparcelshops_tablerate>
41
+ </entities>
42
+ </dpd_mysql4>
43
+ </models>
44
+ <helpers>
45
+ <dpd>
46
+ <class>DPD_Shipping_Helper</class>
47
+ </dpd>
48
+ </helpers>
49
+ <resources>
50
+ <dpd_setup>
51
+ <setup>
52
+ <module>DPD_Shipping</module>
53
+ </setup>
54
+ <connection>
55
+ <use>core_setup</use>
56
+ </connection>
57
+ </dpd_setup>
58
+ <dpd_write>
59
+ <connection>
60
+ <use>core_write</use>
61
+ </connection>
62
+ </dpd_write>
63
+ <dpd_read>
64
+ <connection>
65
+ <use>core_read</use>
66
+ </connection>
67
+ </dpd_read>
68
+ </resources>
69
+ <template>
70
+ <email>
71
+ <dpd_returnlabel_email_template translate="label" module="dpd">
72
+ <label>Dpd Returnlabel Email</label>
73
+ <file>sales/dpd_returnlabel.html</file>
74
+ <type>html</type>
75
+ </dpd_returnlabel_email_template>
76
+ </email>
77
+ </template>
78
+ </global>
79
+ <frontend>
80
+ <layout>
81
+ <updates>
82
+ <dpd>
83
+ <file>dpd_shipping.xml</file>
84
+ </dpd>
85
+ </updates>
86
+ </layout>
87
+ <translate>
88
+ <modules>
89
+ <dpd>
90
+ <files>
91
+ <default>DPD_Shipping.csv</default>
92
+ </files>
93
+ </dpd>
94
+ </modules>
95
+ </translate>
96
+ <events>
97
+ <core_block_abstract_to_html_after>
98
+ <observers>
99
+ <dpdshipping>
100
+ <class>dpd/observer</class>
101
+ <method>core_block_abstract_to_html_after</method>
102
+ </dpdshipping>
103
+ </observers>
104
+ </core_block_abstract_to_html_after>
105
+ <checkout_controller_onepage_save_shipping_method>
106
+ <observers>
107
+ <dpdshipping>
108
+ <type>singleton</type>
109
+ <class>dpd/observer</class>
110
+ <method>checkout_controller_onepage_save_shipping_method</method>
111
+ </dpdshipping>
112
+ </observers>
113
+ </checkout_controller_onepage_save_shipping_method>
114
+ </events>
115
+ <routers>
116
+ <dpd>
117
+ <use>standard</use>
118
+ <args>
119
+ <module>DPD_Shipping</module>
120
+ <frontName>dpd</frontName>
121
+ </args>
122
+ </dpd>
123
+ </routers>
124
+ </frontend>
125
+ <adminhtml>
126
+ <events>
127
+ <core_block_abstract_to_html_before>
128
+ <observers>
129
+ <dpdshipping>
130
+ <class>dpd/observer</class>
131
+ <method>core_block_abstract_to_html_before</method>
132
+ <type>model</type>
133
+ </dpdshipping>
134
+ </observers>
135
+ </core_block_abstract_to_html_before>
136
+ <sales_order_shipment_save_before>
137
+ <observers>
138
+ <dpdshipping>
139
+ <class>dpd/observer</class>
140
+ <method>sales_order_shipment_save_before</method>
141
+ <type>model</type>
142
+ </dpdshipping>
143
+ </observers>
144
+ </sales_order_shipment_save_before>
145
+ </events>
146
+ <translate>
147
+ <modules>
148
+ <dpd>
149
+ <files>
150
+ <default>DPD_Shipping.csv</default>
151
+ </files>
152
+ </dpd>
153
+ </modules>
154
+ </translate>
155
+ <layout>
156
+ <updates>
157
+ <dpdshipping>
158
+ <file>dpd/shipping.xml</file>
159
+ </dpdshipping>
160
+ </updates>
161
+ </layout>
162
+ </adminhtml>
163
+ <default>
164
+ <carriers>
165
+ <dpdclassic>
166
+ <active>1</active>
167
+ <model>dpd/carrier_dpdclassic</model>
168
+ <title>DPD Home Delivery</title>
169
+ <name>Delivery at home</name>
170
+ <sort_order>0</sort_order>
171
+ <default>0</default>
172
+ <ratetype>0</ratetype>
173
+ <flatrateprice>0</flatrateprice>
174
+ <paperformat>0</paperformat>
175
+ <specificcountry>BE,FR,DE,LU,NL</specificcountry>
176
+ <sallowspecific>1</sallowspecific>
177
+ </dpdclassic>
178
+ <dpdparcelshops>
179
+ <active>1</active>
180
+ <log_level>7</log_level>
181
+ <model>dpd/carrier_dpdparcelshops</model>
182
+ <title>DPD ParcelShops</title>
183
+ <name>Delivery at ParcelShops</name>
184
+ <sort_order>0</sort_order>
185
+ <default>0</default>
186
+ <ratetype>0</ratetype>
187
+ <flatrateprice>0</flatrateprice>
188
+ <google_maps_width>600</google_maps_width>
189
+ <google_maps_height>430</google_maps_height>
190
+ <paperformat>0</paperformat>
191
+ <google_maps_maxpointers>10</google_maps_maxpointers>
192
+ <google_maps_display>0</google_maps_display>
193
+ <google_maps_enable_list>0</google_maps_enable_list>
194
+ <specificcountry>BE,FR,DE,LU,NL</specificcountry>
195
+ <sallowspecific>1</sallowspecific>
196
+ </dpdparcelshops>
197
+ </carriers>
198
+ </default>
199
+ <admin>
200
+ <routers>
201
+ <adminhtml>
202
+ <args>
203
+ <modules>
204
+ <dpd before="Mage_Adminhtml">DPD_Shipping_Adminhtml</dpd>
205
+ </modules>
206
+ </args>
207
+ </adminhtml>
208
+ </routers>
209
+ </admin>
210
+ </config>
app/code/community/DPD/Shipping/etc/system.xml ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <shipping>
5
+ <groups>
6
+ <dpdclassic translate="label" module="dpd">
7
+ <label>DPD Shipping</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>10</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <userid translate="label">
15
+ <label>User Id</label>
16
+ <frontend_type>text</frontend_type>
17
+ <sort_order>11</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ <comment>Please contact DPD for your User ID</comment>
22
+ </userid>
23
+ <password translate="label">
24
+ <label>Password</label>
25
+ <frontend_type>obscure</frontend_type>
26
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
27
+ <sort_order>12</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ <comment>Please contact DPD for your password</comment>
32
+ </password>
33
+ <webserviceurl translate="label">
34
+ <label>Webservice URL</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>15</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ <comment>Do NOT change unless instructed by DPD</comment>
41
+ </webserviceurl>
42
+ <sender_name translate="label">
43
+ <label>Sender name</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>16</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <comment>Do NOT change unless instructed by DPD</comment>
50
+ </sender_name>
51
+ <sender_street translate="label">
52
+ <label>Sender street</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>17</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ <comment>Do NOT change unless instructed by DPD</comment>
59
+ </sender_street>
60
+ <sender_streetnumber translate="label">
61
+ <label>Sender streetnumber</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>18</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ <comment>Do NOT change unless instructed by DPD</comment>
68
+ </sender_streetnumber>
69
+ <sender_country translate="label">
70
+ <label>Sender country</label>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>19</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ <comment>Do NOT change unless instructed by DPD</comment>
77
+ </sender_country>
78
+ <sender_zipcode translate="label">
79
+ <label>Sender zipcode</label>
80
+ <frontend_type>text</frontend_type>
81
+ <sort_order>20</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ <comment>Do NOT change unless instructed by DPD</comment>
86
+ </sender_zipcode>
87
+ <sender_city translate="label">
88
+ <label>Sender city</label>
89
+ <frontend_type>text</frontend_type>
90
+ <sort_order>21</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>1</show_in_store>
94
+ <comment>Do NOT change unless instructed by DPD</comment>
95
+ </sender_city>
96
+ <paperformat translate="label">
97
+ <label>Paperformat</label>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>dpd/system_config_source_paperformat</source_model>
100
+ <sort_order>10</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ <comment>Select in which format the labels should be generated for printing</comment>
105
+ </paperformat>
106
+ <weight_unit>
107
+ <label>Weight unit</label>
108
+ <frontend_type>select</frontend_type>
109
+ <source_model>dpd/system_config_source_weightunit</source_model>
110
+ <sort_order>10</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>1</show_in_store>
114
+ <comment>Choose the unit of the weight attribute of products</comment>
115
+ </weight_unit>
116
+ </fields>
117
+ </dpdclassic>
118
+ </groups>
119
+ </shipping>
120
+ <carriers>
121
+ <groups>
122
+ <dpdclassic translate="label" module="dpd">
123
+ <label>DPD Home Delivery</label>
124
+ <frontend_type>text</frontend_type>
125
+ <sort_order>10</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>1</show_in_store>
129
+ <fields>
130
+ <active translate="label">
131
+ <label>Enabled</label>
132
+ <frontend_type>select</frontend_type>
133
+ <source_model>adminhtml/system_config_source_yesno</source_model>
134
+ <sort_order>1</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
+ </active>
139
+ <name translate="label">
140
+ <label>Shipping method name</label>
141
+ <frontend_type>text</frontend_type>
142
+ <sort_order>2</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ <comment>The name of the shipping method</comment>
147
+ </name>
148
+ <sort_order translate="label">
149
+ <label>Sort order</label>
150
+ <frontend_type>text</frontend_type>
151
+ <sort_order>3</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ <comment>The order in which the shipping method should appear</comment>
156
+ </sort_order>
157
+ <default translate="label">
158
+ <label>Default selected</label>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>adminhtml/system_config_source_yesno</source_model>
161
+ <sort_order>4</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ <comment>Automatically selects this shipping method during checkout by default</comment>
166
+ </default>
167
+ <ratetype translate="label">
168
+ <label>Rate type</label>
169
+ <frontend_type>select</frontend_type>
170
+ <source_model>dpd/system_config_source_ratetypes</source_model>
171
+ <sort_order>5</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ <comment>You can use flat rate or calculated table rates</comment>
176
+ </ratetype>
177
+ <flatrateprice translate="label">
178
+ <label>Flat rate price</label>
179
+ <frontend_type>text</frontend_type>
180
+ <sort_order>6</sort_order>
181
+ <depends>
182
+ <ratetype>0</ratetype>
183
+ </depends>
184
+ <show_in_default>1</show_in_default>
185
+ <show_in_website>1</show_in_website>
186
+ <show_in_store>1</show_in_store>
187
+ <comment>Fixed fee for DPD shipments</comment>
188
+ </flatrateprice>
189
+ <condition_name translate="label">
190
+ <label>Table rates condition</label>
191
+ <frontend_type>select</frontend_type>
192
+ <source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
193
+ <sort_order>7</sort_order>
194
+ <depends>
195
+ <ratetype>1</ratetype>
196
+ </depends>
197
+ <show_in_default>1</show_in_default>
198
+ <show_in_website>1</show_in_website>
199
+ <show_in_store>0</show_in_store>
200
+ </condition_name>
201
+ <export translate="label">
202
+ <label>Export table rates file</label>
203
+ <frontend_type>button</frontend_type>
204
+ <frontend_model>dpd/adminhtml_system_config_form_dpdclassicexport</frontend_model>
205
+ <sort_order>8</sort_order>
206
+ <depends>
207
+ <ratetype>1</ratetype>
208
+ </depends>
209
+ <show_in_default>0</show_in_default>
210
+ <show_in_website>1</show_in_website>
211
+ <show_in_store>0</show_in_store>
212
+ <comment>Export your table rates configuration here</comment>
213
+ </export>
214
+ <import_classic translate="label">
215
+ <label>Import table rates file</label>
216
+ <frontend_type>import</frontend_type>
217
+ <sort_order>9</sort_order>
218
+ <backend_model>dpd/adminhtml_system_config_backend_shipping_dpdclassic_tablerate</backend_model>
219
+ <depends>
220
+ <ratetype>1</ratetype>
221
+ </depends>
222
+ <show_in_default>0</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>0</show_in_store>
225
+ <comment>Upload your table rates configuration here. Refer to the manual for more information</comment>
226
+ </import_classic>
227
+ <sallowspecific translate="label">
228
+ <label>Ship to countries</label>
229
+ <frontend_type>select</frontend_type>
230
+ <sort_order>13</sort_order>
231
+ <frontend_class>shipping-applicable-country</frontend_class>
232
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>0</show_in_store>
236
+ <comment>Make DPD available in all countries or in specific</comment>
237
+ </sallowspecific>
238
+ <specificcountry translate="label">
239
+ <label>Allowed countries</label>
240
+ <frontend_type>multiselect</frontend_type>
241
+ <sort_order>14</sort_order>
242
+ <source_model>adminhtml/system_config_source_country</source_model>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>0</show_in_store>
246
+ <can_be_empty>0</can_be_empty>
247
+ <comment>Select one or more countries where dpd should be available for</comment>
248
+ </specificcountry>
249
+ </fields>
250
+ </dpdclassic>
251
+ <dpdparcelshops translate="label" module="dpd">
252
+ <label>DPD Parcelshops</label>
253
+ <frontend_type>text</frontend_type>
254
+ <sort_order>11</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>1</show_in_store>
258
+ <fields>
259
+ <active translate="label">
260
+ <label>Enabled</label>
261
+ <frontend_type>select</frontend_type>
262
+ <source_model>adminhtml/system_config_source_yesno</source_model>
263
+ <sort_order>1</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>1</show_in_store>
267
+ </active>
268
+ <name translate="label">
269
+ <label>Shipping method name</label>
270
+ <frontend_type>text</frontend_type>
271
+ <sort_order>2</sort_order>
272
+ <show_in_default>1</show_in_default>
273
+ <show_in_website>1</show_in_website>
274
+ <show_in_store>1</show_in_store>
275
+ <comment>The name of the shipping method</comment>
276
+ </name>
277
+ <sort_order translate="label">
278
+ <label>Sort order</label>
279
+ <frontend_type>text</frontend_type>
280
+ <sort_order>3</sort_order>
281
+ <show_in_default>1</show_in_default>
282
+ <show_in_website>1</show_in_website>
283
+ <show_in_store>1</show_in_store>
284
+ <comment>The order in which the shipping method should appear</comment>
285
+ </sort_order>
286
+ <default translate="label">
287
+ <label>Default selected</label>
288
+ <frontend_type>select</frontend_type>
289
+ <source_model>adminhtml/system_config_source_yesno</source_model>
290
+ <sort_order>4</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ <comment>Automatically selects this shipping method during checkout by default</comment>
295
+ </default>
296
+ <ratetype translate="label">
297
+ <label>Rate type</label>
298
+ <frontend_type>select</frontend_type>
299
+ <source_model>dpd/system_config_source_ratetypes</source_model>
300
+ <sort_order>5</sort_order>
301
+ <show_in_default>1</show_in_default>
302
+ <show_in_website>1</show_in_website>
303
+ <show_in_store>1</show_in_store>
304
+ <comment>You can use flat rate or calculated table rates</comment>
305
+ </ratetype>
306
+ <flatrateprice translate="label">
307
+ <label>Flat rate price</label>
308
+ <frontend_type>text</frontend_type>
309
+ <sort_order>6</sort_order>
310
+ <depends>
311
+ <ratetype>0</ratetype>
312
+ </depends>
313
+ <show_in_default>1</show_in_default>
314
+ <show_in_website>1</show_in_website>
315
+ <show_in_store>1</show_in_store>
316
+ <comment>Fixed fee for DPD shipments</comment>
317
+ </flatrateprice>
318
+ <condition_name translate="label">
319
+ <label>Table rates condition</label>
320
+ <frontend_type>select</frontend_type>
321
+ <source_model>adminhtml/system_config_source_shipping_tablerate</source_model>
322
+ <sort_order>7</sort_order>
323
+ <depends>
324
+ <ratetype>1</ratetype>
325
+ </depends>
326
+ <show_in_default>1</show_in_default>
327
+ <show_in_website>1</show_in_website>
328
+ <show_in_store>0</show_in_store>
329
+ </condition_name>
330
+ <export translate="label">
331
+ <label>Export table rates file</label>
332
+ <frontend_type>button</frontend_type>
333
+ <frontend_model>dpd/adminhtml_system_config_form_dpdparcelshopsexport</frontend_model>
334
+ <sort_order>8</sort_order>
335
+ <depends>
336
+ <ratetype>1</ratetype>
337
+ </depends>
338
+ <show_in_default>0</show_in_default>
339
+ <show_in_website>1</show_in_website>
340
+ <show_in_store>0</show_in_store>
341
+ <comment>Export your table rates configuration here</comment>
342
+ </export>
343
+ <import_parcelshops translate="label">
344
+ <label>Import table rates file</label>
345
+ <frontend_type>import</frontend_type>
346
+ <sort_order>9</sort_order>
347
+ <backend_model>dpd/adminhtml_system_config_backend_shipping_dpdparcelshops_tablerate</backend_model>
348
+ <depends>
349
+ <ratetype>1</ratetype>
350
+ </depends>
351
+ <show_in_default>0</show_in_default>
352
+ <show_in_website>1</show_in_website>
353
+ <show_in_store>0</show_in_store>
354
+ <comment>Upload your table rates configuration here. Refer to the manual for more information</comment>
355
+ </import_parcelshops>
356
+ <sallowspecific translate="label">
357
+ <label>Ship to countries</label>
358
+ <frontend_type>select</frontend_type>
359
+ <sort_order>10</sort_order>
360
+ <frontend_class>shipping-applicable-country</frontend_class>
361
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
362
+ <show_in_default>1</show_in_default>
363
+ <show_in_website>1</show_in_website>
364
+ <show_in_store>0</show_in_store>
365
+ <comment>Make DPD available in all countries or in specific</comment>
366
+ </sallowspecific>
367
+ <specificcountry translate="label">
368
+ <label>Allowed countries</label>
369
+ <frontend_type>multiselect</frontend_type>
370
+ <sort_order>11</sort_order>
371
+ <source_model>adminhtml/system_config_source_country</source_model>
372
+ <show_in_default>1</show_in_default>
373
+ <show_in_website>1</show_in_website>
374
+ <show_in_store>0</show_in_store>
375
+ <can_be_empty>0</can_be_empty>
376
+ <can_be_empty>1</can_be_empty>
377
+ <comment>Select one or more countries where dpd should be available for</comment>
378
+ </specificcountry>
379
+ <google_maps_api translate="label">
380
+ <label>Google Maps API</label>
381
+ <frontend_type>text</frontend_type>
382
+ <sort_order>12</sort_order>
383
+ <show_in_default>1</show_in_default>
384
+ <show_in_website>1</show_in_website>
385
+ <show_in_store>1</show_in_store>
386
+ <comment><![CDATA[<a href="https://developers.google.com/maps/documentation/javascript/tutorial?hl=nl#api_key" target="_blank">How to request an API key</a>]]></comment>
387
+ </google_maps_api>
388
+ <google_maps_width translate="label">
389
+ <label>Map width</label>
390
+ <frontend_type>text</frontend_type>
391
+ <sort_order>13</sort_order>
392
+ <show_in_default>1</show_in_default>
393
+ <show_in_website>1</show_in_website>
394
+ <show_in_store>1</show_in_store>
395
+ <comment>Width of the inline map (in px)</comment>
396
+ </google_maps_width>
397
+ <google_maps_height translate="label">
398
+ <label>Map height</label>
399
+ <frontend_type>text</frontend_type>
400
+ <sort_order>14</sort_order>
401
+ <show_in_default>1</show_in_default>
402
+ <show_in_website>1</show_in_website>
403
+ <show_in_store>1</show_in_store>
404
+ <comment>Height of the inline map (in px)</comment>
405
+ </google_maps_height>
406
+ <google_maps_maxpointers translate="label">
407
+ <label>Map - max num of shops</label>
408
+ <frontend_type>text</frontend_type>
409
+ <sort_order>15</sort_order>
410
+ <show_in_default>1</show_in_default>
411
+ <show_in_website>1</show_in_website>
412
+ <show_in_store>1</show_in_store>
413
+ <comment>Maximum number of Parcelshops to be put on the map</comment>
414
+ </google_maps_maxpointers>
415
+ <google_maps_display translate="label">
416
+ <label>Map presentation</label>
417
+ <frontend_type>select</frontend_type>
418
+ <frontend_type>select</frontend_type>
419
+ <source_model>dpd/system_config_source_display</source_model>
420
+ <sort_order>16</sort_order>
421
+ <show_in_default>1</show_in_default>
422
+ <show_in_website>1</show_in_website>
423
+ <show_in_store>1</show_in_store>
424
+ <comment>Show the map inline or as an overlay</comment>
425
+ </google_maps_display>
426
+ <google_maps_enable_list translate="label">
427
+ <label>Map list</label>
428
+ <frontend_type>select</frontend_type>
429
+ <source_model>adminhtml/system_config_source_yesno</source_model>
430
+ <sort_order>17</sort_order>
431
+ <show_in_default>1</show_in_default>
432
+ <show_in_website>1</show_in_website>
433
+ <show_in_store>1</show_in_store>
434
+ <comment>Show the list of ParcelShops to the right of the map</comment>
435
+ </google_maps_enable_list>
436
+ <custom_parcelshops_import translate="label">
437
+ <label>Custom ParcelShops - CSV</label>
438
+ <frontend_type>import</frontend_type>
439
+ <backend_model>dpd/adminhtml_system_config_backend_shipping_specialparcelshops</backend_model>
440
+ <sort_order>18</sort_order>
441
+ <show_in_default>0</show_in_default>
442
+ <show_in_website>1</show_in_website>
443
+ <show_in_store>0</show_in_store>
444
+ <comment>Contact DPD to get the CSV !</comment>
445
+ </custom_parcelshops_import>
446
+ <check_custom_parcelshops_import translate="label">
447
+ <label></label>
448
+ <frontend_type>button</frontend_type>
449
+ <frontend_model>dpd/adminhtml_system_config_form_availability</frontend_model>
450
+ <sort_order>19</sort_order>
451
+ <show_in_default>0</show_in_default>
452
+ <show_in_website>1</show_in_website>
453
+ <show_in_store>0</show_in_store>
454
+ </check_custom_parcelshops_import>
455
+ <special_parcelshop_icon translate="label">
456
+ <label>Custom ParcelShops - logo</label>
457
+ <frontend_type>image</frontend_type>
458
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
459
+ <upload_dir config="system/filesystem/media" scope_info="1">dpd</upload_dir>
460
+ <base_url type="media" scope_info="1">dpd</base_url>
461
+ <sort_order>20</sort_order>
462
+ <show_in_default>1</show_in_default>
463
+ <show_in_website>1</show_in_website>
464
+ <show_in_store>1</show_in_store>
465
+ <comment>Upload your custom map logo (100x100 px)</comment>
466
+ </special_parcelshop_icon>
467
+ <google_maps_icon translate="label">
468
+ <label>Custom ParcelShops – map logo</label>
469
+ <frontend_type>image</frontend_type>
470
+ <backend_model>adminhtml/system_config_backend_image</backend_model>
471
+ <upload_dir config="system/filesystem/media" scope_info="1">dpd</upload_dir>
472
+ <base_url type="media" scope_info="1">dpd</base_url>
473
+ <sort_order>21</sort_order>
474
+ <show_in_default>1</show_in_default>
475
+ <show_in_website>1</show_in_website>
476
+ <show_in_store>1</show_in_store>Enabled
477
+ <comment>Map pointer image. (57x57 px)</comment>
478
+ </google_maps_icon>
479
+ </fields>
480
+ </dpdparcelshops>
481
+ </groups>
482
+ </carriers>
483
+ </sections>
484
+ </config>
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ // add quote attributes
13
+
14
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_selected', "boolean default '0'");
15
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_company', "varchar(255) null default ''");
16
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_city', "varchar(255) null default ''");
17
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_street', "varchar(255) null default ''");
18
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_zipcode', "varchar(255) null default ''");
19
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_country', "varchar(255) null default ''");
20
+
21
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.1-0.0.2.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ // add quote attributes
13
+
14
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_extra_info', "text null default ''");
15
+
16
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.2-0.0.3.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->run("
13
+ CREATE TABLE IF NOT EXISTS {$this->getTable('dpd_shipping_returnlabels')} (
14
+ `returnlabels_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
15
+ `date_created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
16
+ `label_number` varchar(255) NOT NULL DEFAULT '',
17
+ `label_pdf_url` varchar(255) NOT NULL,
18
+ `label_instructions_url` varchar(255) NOT NULL,
19
+ `order_id` int(11) NOT NULL,
20
+ PRIMARY KEY (`returnlabels_id`)
21
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
22
+ ");
23
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'dpd_label_exported', "int(11) null");
24
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.3-0.0.4.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'dpd_label_exported', "int(11) null");
13
+ $installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'dpd_label_path', "varchar(255) null default ''");
14
+ $installer->getConnection()->dropColumn($installer->getTable('sales/order'), 'dpd_label_exported');
15
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.4-0.0.5.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'dpd_parcelshop_id', "varchar(255) null");
13
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'dpd_parcelshop_id', "varchar(255) null");
14
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'dpd_label_exported', "bool null default 0");
15
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.5-0.0.6.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'dpd_label_exists', "bool null default 0");
13
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.6-0.0.7.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->getConnection()->addColumn($installer->getTable('sales/shipment'), 'dpd_tracking_url', "varchar(255) null default ''");
13
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.7-0.0.8.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->run("
13
+ CREATE TABLE IF NOT EXISTS {$this->getTable('dpd_shipping_specialparcelshops')} (
14
+ `specialparselshops_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
15
+ `parcelshop_delicom_id` varchar(255) NOT NULL,
16
+ `parcelshop_website_id` int(11) NULL,
17
+ `parcelshop_carrier_pudo_id` int(11) NULL,
18
+ `parcelshop_manager` varchar(255) NULL,
19
+ `parcelshop_pudo_name`varchar(255) NOT NULL,
20
+ `parcelshop_pudo_language`varchar(255) NOT NULL,
21
+ `parcelshop_country`varchar(255) NOT NULL,
22
+ `parcelshop_latitude`varchar(255) NOT NULL,
23
+ `parcelshop_longitude`varchar(255) NOT NULL,
24
+ `parcelshop_city_code`varchar(255) NULL,
25
+ `parcelshop_langue_1`varchar(255) NULL,
26
+ `parcelshop_address_1`varchar(255) NOT NULL,
27
+ `parcelshop_address_2`varchar(255) NULL,
28
+ `parcelshop_location_information`varchar(255) NULL,
29
+ `parcelshop_post_code`varchar(255) NOT NULL,
30
+ `parcelshop_town`varchar(255) NOT NULL,
31
+ `parcelshop_region`varchar(255) NULL,
32
+ `parcelshop_openinghours`text NULL,
33
+ PRIMARY KEY (`specialparselshops_id`)
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
35
+ ");
36
+
37
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.8-0.0.9.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->run("CREATE TABLE `dpd_shipping_dpdclassic_tablerate` (
13
+ `pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
14
+ `website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
15
+ `dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
16
+ `dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
17
+ `dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
18
+ `condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
19
+ `condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
20
+ `price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
21
+ `cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
22
+ PRIMARY KEY (`pk`),
23
+ UNIQUE KEY `D60821CDB2AFACEE1566CFC02D0D4CAA` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Dpdclassic Tablerate'");
25
+ $installer->endSetup();
app/code/community/DPD/Shipping/sql/dpd_setup/mysql4-upgrade-0.0.9-0.1.0.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PHPro
4
+ *
5
+ * @package DPD
6
+ * @subpackage Shipping
7
+ * @category Checkout
8
+ * @author PHPro (info@phpro.be)
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+ $installer->run("CREATE TABLE `dpd_shipping_dpdparcelshops_tablerate` (
13
+ `pk` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary key',
14
+ `website_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Website Id',
15
+ `dest_country_id` varchar(4) NOT NULL DEFAULT '0' COMMENT 'Destination coutry ISO/2 or ISO/3 code',
16
+ `dest_region_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Destination Region Id',
17
+ `dest_zip` varchar(10) NOT NULL DEFAULT '*' COMMENT 'Destination Post Code (Zip)',
18
+ `condition_name` varchar(20) NOT NULL COMMENT 'Rate Condition name',
19
+ `condition_value` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Rate condition value',
20
+ `price` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Price',
21
+ `cost` decimal(12,4) NOT NULL DEFAULT '0.0000' COMMENT 'Cost',
22
+ PRIMARY KEY (`pk`),
23
+ UNIQUE KEY `D60821CDB2AFACEE1566CFC02D0D4CAA` (`website_id`,`dest_country_id`,`dest_region_id`,`dest_zip`,`condition_name`,`condition_value`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Dpdparcelshops Tablerate'");
25
+ $installer->endSetup();
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>dpdshipping</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
@@ -11,8 +11,8 @@
11
  <notes>First release</notes>
12
  <authors><author><name>PHPro</name><user>heremke</user><email>info@phpro.be</email></author></authors>
13
  <date>2014-03-13</date>
14
- <time>16:40:15</time>
15
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="dpd"><file name="shipping.xml" hash="489b47b14eb3bec23bbfd254fda398df"/></dir></dir><dir name="template"><dir name="dpd"><dir name="order"><dir name="view"><dir name="tab"><file name="returnlabels.phtml" hash="cc2f679da3a728fbbe1ddc510c04cdae"/></dir></dir></dir><dir name="system"><dir name="config"><file name="availability.phtml" hash="5f17246a65c243bf0c8c4dfea499578e"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="dpd_shipping.xml" hash="05f2c2afda6a6732ee49b77ed074a947"/></dir><dir name="template"><dir name="dpd"><file name="gmapsapi.phtml" hash="e0073b425f55c844918b5c83aea20b1b"/><file name="ordertracking.phtml" hash="2273e469b6f129b2f174424ddebe83a3"/><file name="parcelshop.phtml" hash="9bd08955732d22e70e917c4189ccdb97"/><file name="parcelshoplink.phtml" hash="3a19aa648c56399d07aeeb803764719a"/><file name="parcelshopselected.phtml" hash="fe1e5d1e2a80b5f8f632946e2eca346a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DPD_Shipping.xml" hash="2014a79baf3f800f46222ceb11310d59"/></dir></target><target name="magelocale"><dir name="en_US"><file name="DPD_Shipping.csv" hash="0e6a08a0cb4f974d38a93b6af7d4718b"/></dir></target><target name="mageweb"><dir name="js"><dir name="dpd"><file name="shipping.js" hash="23e9280a056a11bdcfcfc922656705da"/><dir name="window"><file name="shipping.js" hash="7ad8ea9367757797676269a40ec32067"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir><dir name="dpd"><file name="shipping.css" hash="b37446a478b7cce62cf34279ee962d36"/><file name="window.css" hash="b0b31c19dd3b52e7408df6ab53e25dcd"/></dir></dir><file name="widgets.css" hash="61d471e890fee29b85f429f8d7a3a2e6"/></dir><dir name="images"><file name="calendar.gif" hash="b1468e5239504974c689eea5d93f86d4"/><dir><dir name="catalog"><dir name="product"><dir name="placeholder"><file name="image.jpg" hash="097ab8a3051bc037ea3de0e17f440540"/><file name="small_image.jpg" hash="f825d16f97a640453553c79c48ebaa73"/><file name="thumbnail.jpg" hash="b2b682d28a08a748a73d2cda70ab5a57"/></dir></dir></dir><dir name="centinel"><file name="sc_learn_62x34.gif" hash="059ec6c3eecea97b3f70a2e2d6ceb911"/><file name="v_activate_steps.gif" hash="005312b14c6aed41e8a47c4acaac7c1a"/><file name="vbv_ltbg_71x57.gif" hash="2b0bcd07251fcaafd46e7ce77ba821a9"/></dir><dir name="cookies"><file name="firefox.png" hash="425e1b2ddc38c0bba431fb54357c66a4"/><file name="ie6-1.gif" hash="5c27700e245762bc89ed8c3ee7183f21"/><file name="ie6-2.gif" hash="d8c55e15e1f711e5c259300a9c19551b"/><file name="ie7-1.gif" hash="d61edcc8a514a3c81ea116b7d38ddcb6"/><file name="ie7-2.gif" hash="0526a654e94c54866cad977c0a47d3e5"/><file name="ie7-3.gif" hash="4fb142def3f6cfd8d8d23e1315528a1e"/><file name="ie7-4.gif" hash="575c276231c6a91e28935ec98215e146"/><file name="ie7-5.gif" hash="3ae5fcc11fe89da91674d183872337c1"/><file name="ie7-6.gif" hash="95a4981a41785a8cde273c9b2edbfbc7"/><file name="opera.png" hash="34070d92180d4ee0e37b1dd8bb731cd7"/></dir><dir name="dpd"><file name="ajax-loader.gif" hash="f3dbc538b63d07156155acf0631ae375"/><file name="button_close.png" hash="040640376fe4f699f97f0d59b64e79cf"/><file name="dpd_parcelshop_logo.png" hash="43e479d6bb23dea74f2ec6ff8a1e390c"/><file name="icon_info.gif" hash="4c85c6937f19e50c5e871c2699e99bee"/><file name="icon_info.png" hash="53faeafe236c775f54752bc2008efa97"/><file name="icon_parcelshop.png" hash="202e38024b9f41483285a7b2d34d2a56"/><file name="icon_parcelshop_shadow.png" hash="263ee734ba6bb38060fd47a5b3de64ae"/><file name="icon_route.png" hash="fe07947b6f600723e682f2fcb8fca88f"/></dir><dir name="moneybookers"><file name="banner_120_de.gif" hash="74815117bf378543e5b3496bb5bc4e8a"/><file name="banner_120_de.png" hash="6c3f708fcb6dac92e53472d4c2246c68"/><file name="banner_120_dk.gif" hash="2106bd994d188d40474bf2a2e8d62a8d"/><file name="banner_120_fr.gif" hash="a84241eef7bc38fb38567e7aa8ca245a"/><file name="banner_120_fr.png" hash="8994d1dc3b4f5c9e5efc67ce3f9f55a9"/><file name="banner_120_int.gif" hash="e23ddcf71e15f0a9300062ef9cdea512"/><file name="banner_120_int.png" hash="f9dfbc26041e52b34eea65348707d64f"/><file name="banner_120_pl.gif" hash="44313c7d27cdcf59c2f66708c6c5abd5"/><file name="banner_120_pl.png" hash="67d3385f93bc9113880305ee7c7da9de"/><file name="banner_120_sp.gif" hash="a003ed8db63620672ae945682b1e1e39"/><file name="banner_120_sp.png" hash="f9c4a653d6814ab3f8c535da706f5f77"/><file name="moneybookers_acc.png" hash="a3e639a68fafdffaca81e91985127735"/><file name="moneybookers_csi.gif" hash="4eec4ed7c494d01d518a3c6c691128e9"/><file name="moneybookers_did.gif" hash="6a3a3365894e9cdb199647a5b74ba35b"/><file name="moneybookers_dnk.gif" hash="7d4b8d27784f8a6fa6ef81c4e911831b"/><file name="moneybookers_ebt.gif" hash="9911d8cc223e7f3d9ec12f50c280ec61"/><file name="moneybookers_ent.gif" hash="704e9551ed4aff82b67114242b9fba1a"/><file name="moneybookers_gcb.gif" hash="e2e7c0f501e5ab0136f859ca5f57abc2"/><file name="moneybookers_gir.gif" hash="f16e949bc60bbd812f803d5e377d47f6"/><file name="moneybookers_idl.gif" hash="fe0ad1efc12d43df6c9ff3ffdd9dd59b"/><file name="moneybookers_lsr.gif" hash="58cdadfa20b6d37aeaa19e50995e4baf"/><file name="moneybookers_mae.gif" hash="4d4b5f0cf3377939c7738fc7e416d25f"/><file name="moneybookers_npy.gif" hash="01242c5ad7bc667e7493b550b6397fab"/><file name="moneybookers_obt_de.png" hash="ce44fd2974b8d279401778292e2c4484"/><file name="moneybookers_obt_dk.png" hash="2985e8cb472d1886d584fa31d56bee92"/><file name="moneybookers_obt_ee.png" hash="cb186be1c7595544f61d3737c7bf85aa"/><file name="moneybookers_obt_en.png" hash="eee098a06e3ea34f33e276724b084774"/><file name="moneybookers_obt_fl.png" hash="6c3766df052d875ce399e62ad8a435f8"/><file name="moneybookers_obt_lt.png" hash="adf61f248fc6d5985840db3e0c23391e"/><file name="moneybookers_obt_lv.png" hash="4e7f16b4988ea30f049942d4dcdb5f78"/><file name="moneybookers_obt_pl.png" hash="fb2c43c18ba73d390e5b5f5261261f4a"/><file name="moneybookers_obt_se.png" hash="9028412e9c3f25d114bf40bb2049d225"/><file name="moneybookers_pli.gif" hash="93989e85caff760af7a61838db0300bf"/><file name="moneybookers_psp.gif" hash="7abffc2246f172625be2ce31f4315cb2"/><file name="moneybookers_pwy.gif" hash="b4a0b9db9a031855e6e3899592012fae"/><file name="moneybookers_sft.gif" hash="e9e774163c99a8ab4deb18d37feaf658"/><file name="moneybookers_so2.gif" hash="9911d8cc223e7f3d9ec12f50c280ec61"/><file name="moneybookers_wlt.gif" hash="4b9cbc5aa5c32f3015ce7bec98da2670"/></dir><dir name="widgets"><file name="i_block-list.gif" hash="fe8424127ecbe4b0d893bcf6f253dc1a"/><file name="i_widget-link.gif" hash="1bf753578171f147f0203e7b13bdd0c4"/><file name="i_widget-new.gif" hash="a75377ffed51b711cbc608ffaa1a2e7d"/></dir><dir name="xmlconnect"><dir name="catalog"><dir name="category"><dir name="placeholder"><file name="image.jpg" hash="097ab8a3051bc037ea3de0e17f440540"/><file name="small_image.jpg" hash="f825d16f97a640453553c79c48ebaa73"/><file name="thumbnail.jpg" hash="b2b682d28a08a748a73d2cda70ab5a57"/></dir></dir></dir><file name="tab_account.png" hash="0498d73e47ed47179e5546dc15c17dc7"/><file name="tab_cart.png" hash="9055ba76e256a51d3fee53a8c41d5226"/><file name="tab_home.png" hash="07d0af93e167b9366d3d4fb3d6cdb31c"/><file name="tab_more.png" hash="b9fc21feb8d7655bc9c2985c37b0de2f"/><file name="tab_page.png" hash="ca05dbc42f944b8d4255f6675f6dd93a"/><file name="tab_search.png" hash="25e880eb2a4d06828e2e1c3f32d22400"/><file name="tab_shop.png" hash="fe602fc2e7093efef5ecc0b027a32d91"/></dir></dir><file name="cvv.gif" hash="83cdd38bf110b0f9c52fe84b56f45298"/><file name="fam_book_open.png" hash="0ba89b9fbe7e88d4c6896ed0a1f495aa"/><file name="reload.png" hash="84cc4883f78ef850814ea9b53989b2a7"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>dpdshipping</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
11
  <notes>First release</notes>
12
  <authors><author><name>PHPro</name><user>heremke</user><email>info@phpro.be</email></author></authors>
13
  <date>2014-03-13</date>
14
+ <time>16:48:42</time>
15
+ <contents><target name="magecommunity"><dir name="DPD"><dir name="Shipping"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Grid"><dir name="Renderer"><file name="Shippingmethod.php" hash="b70aad5bba5c4eb5cc897dcc12e3c199"/></dir></dir><file name="Grid.php" hash="e710e55b9dc609951efd0361a940f045"/><dir name="View"><dir name="Tab"><file name="Returnlabels.php" hash="7917e9cd5107154a83561e9a399de876"/></dir></dir></dir><file name="Order.php" hash="3bf3e1fb85abbfe21a051442920ab479"/></dir><dir name="Shipping"><dir name="Carrier"><dir name="Dpdclassic"><dir name="Tablerate"><file name="Grid.php" hash="e7ac634260c5f6d3c70b5f9c8875f265"/></dir></dir><dir name="Dpdparcelshops"><dir name="Tablerate"><file name="Grid.php" hash="dfe9582089ac0729d66853415a5e57f3"/></dir></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Availability.php" hash="7883b99fbec71aa29486a81065476b12"/><file name="Dpdclassicexport.php" hash="b8bb24d799599844e8a9174f7dc4606c"/><file name="Dpdparcelshopsexport.php" hash="a5facc313e5249cc9d73249b40956a49"/></dir></dir></dir></dir><dir name="Carrier"><file name="Parcelshop.php" hash="0ea6d85c21c397e23997882d32f3489f"/></dir></dir><dir name="Helper"><file name="Data.php" hash="43713611d5e2b9da04d1d3cfddaf5bb2"/></dir><dir name="Model"><dir name="Adminhtml"><file name="Dpdgrid.php" hash="365d594e11113cca64ac3442a8946951"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Shipping"><dir name="Dpdclassic"><file name="Tablerate.php" hash="2448a6974c41d4361a1125c7c26d02a9"/></dir><dir name="Dpdparcelshops"><file name="Tablerate.php" hash="259c9918f4c2e29a0d8478409da879e4"/></dir><file name="Specialparcelshops.php" hash="67d996d145f0206e9fab5954bf6b0063"/></dir></dir></dir></dir></dir><dir name="Carrier"><file name="Dpdclassic.php" hash="04fc4d22d9bca9ff6b20c2d824f203f4"/><file name="Dpdparcelshops.php" hash="85c57bb4f50a57d853079a6c1d949bb5"/></dir><dir name="Dpdclassic"><file name="Tablerate.php" hash="9cec2a0a694a1af5fc44fe9cbf3b8283"/></dir><dir name="Dpdparcelshops"><file name="Tablerate.php" hash="be1dfb643e62f3ea0a6c527b6ef88ca9"/></dir><dir name="Mysql4"><dir name="Dpdclassic"><dir name="Tablerate"><file name="Collection.php" hash="8eadb25daf3962f3adba71d380129683"/></dir><file name="Tablerate.php" hash="b87171d15d926e416bc542c544e802a8"/></dir><dir name="Dpdparcelshops"><dir name="Tablerate"><file name="Collection.php" hash="bbfbfdcb550a97195e2f13e582d96d59"/></dir><file name="Tablerate.php" hash="4a75de42a54b2e8ffa01ec8ed28d027e"/></dir><dir name="Returnlabels"><file name="Collection.php" hash="80fe36b9f31d150f02aebb64a769fc5d"/></dir><file name="Returnlabels.php" hash="1d75562904a21b572535483d2d086cdd"/><dir name="Specialparcelshops"><file name="Collection.php" hash="cd7d740fa52301b798ace547820473ef"/></dir><file name="Specialparcelshops.php" hash="64dd72846b549e7fd3a73e96c3542b54"/></dir><file name="Observer.php" hash="0e80c70924be85308ff8754abc142ce5"/><file name="Returnlabels.php" hash="5fa12afaf88cecc73cbd3d0f3163c6f2"/><file name="Specialparcelshops.php" hash="d1f2b72ffab70117fcd2b9f2820cd028"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Display.php" hash="af239a08df6796995e0c580d59d88c46"/><file name="Paperformat.php" hash="e0c638d918566a8b868cca06a459627b"/><file name="Ratetypes.php" hash="1fdeeb0624939d674d625e2c664f907c"/><file name="Weightunit.php" hash="857dd1b887f0f8485616107e6d66db01"/></dir></dir></dir><file name="Webservice.php" hash="0953cd4e5d2fde3a9011846ab4f07afa"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="DpdconfigController.php" hash="c04b8c67343fcb446948dde216cb7052"/><file name="DpdorderController.php" hash="f95f8961942ca9bdab1b1c3ffcfdd09f"/></dir><file name="AjaxController.php" hash="a5c976d9f134d4184466e46e327bfc36"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9b48a3489a485e86c8f2720a7a4380d8"/><file name="config.xml" hash="b5aa2de0450a569a6c90c94c1a93429e"/><file name="system.xml" hash="c26cb40c24f62d5acef33ee41166a263"/></dir><dir name="sql"><dir name="dpd_setup"><file name="mysql4-install-0.0.1.php" hash="3dc22f7bf34a98be9b7f746e21832988"/><file name="mysql4-upgrade-0.0.1-0.0.2.php" hash="1d5467d1cc3b7ed2019bd6eb05aa1f08"/><file name="mysql4-upgrade-0.0.2-0.0.3.php" hash="a1a30b8234ef4b8cc26e220f559af25f"/><file name="mysql4-upgrade-0.0.3-0.0.4.php" hash="ee870d8941ff7f5565c148e6a26056bb"/><file name="mysql4-upgrade-0.0.4-0.0.5.php" hash="2d4632b58e315f3de7d630d41bd2d3f9"/><file name="mysql4-upgrade-0.0.5-0.0.6.php" hash="e75ee16a3c996fc9204a52f6a130f1c8"/><file name="mysql4-upgrade-0.0.6-0.0.7.php" hash="80226a27f1a62aeebef355490e89613a"/><file name="mysql4-upgrade-0.0.7-0.0.8.php" hash="45fbb66b1657ca6455d0348da94b824d"/><file name="mysql4-upgrade-0.0.8-0.0.9.php" hash="3fc70e7ff7256337074c991ed671a5a3"/><file name="mysql4-upgrade-0.0.9-0.1.0.php" hash="827c41a4a56bba13927089ab8b0841b8"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="dpd"><file name="shipping.xml" hash="489b47b14eb3bec23bbfd254fda398df"/></dir></dir><dir name="template"><dir name="dpd"><dir name="order"><dir name="view"><dir name="tab"><file name="returnlabels.phtml" hash="cc2f679da3a728fbbe1ddc510c04cdae"/></dir></dir></dir><dir name="system"><dir name="config"><file name="availability.phtml" hash="5f17246a65c243bf0c8c4dfea499578e"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="dpd_shipping.xml" hash="05f2c2afda6a6732ee49b77ed074a947"/></dir><dir name="template"><dir name="dpd"><file name="gmapsapi.phtml" hash="e0073b425f55c844918b5c83aea20b1b"/><file name="ordertracking.phtml" hash="2273e469b6f129b2f174424ddebe83a3"/><file name="parcelshop.phtml" hash="9bd08955732d22e70e917c4189ccdb97"/><file name="parcelshoplink.phtml" hash="3a19aa648c56399d07aeeb803764719a"/><file name="parcelshopselected.phtml" hash="fe1e5d1e2a80b5f8f632946e2eca346a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DPD_Shipping.xml" hash="2014a79baf3f800f46222ceb11310d59"/></dir></target><target name="magelocale"><dir name="en_US"><file name="DPD_Shipping.csv" hash="0e6a08a0cb4f974d38a93b6af7d4718b"/></dir></target><target name="mageweb"><dir name="js"><dir name="dpd"><file name="shipping.js" hash="23e9280a056a11bdcfcfc922656705da"/><dir name="window"><file name="shipping.js" hash="7ad8ea9367757797676269a40ec32067"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir><dir name="dpd"><file name="shipping.css" hash="b37446a478b7cce62cf34279ee962d36"/><file name="window.css" hash="b0b31c19dd3b52e7408df6ab53e25dcd"/></dir></dir><file name="widgets.css" hash="61d471e890fee29b85f429f8d7a3a2e6"/></dir><dir name="images"><file name="calendar.gif" hash="b1468e5239504974c689eea5d93f86d4"/><dir><dir name="catalog"><dir name="product"><dir name="placeholder"><file name="image.jpg" hash="097ab8a3051bc037ea3de0e17f440540"/><file name="small_image.jpg" hash="f825d16f97a640453553c79c48ebaa73"/><file name="thumbnail.jpg" hash="b2b682d28a08a748a73d2cda70ab5a57"/></dir></dir></dir><dir name="centinel"><file name="sc_learn_62x34.gif" hash="059ec6c3eecea97b3f70a2e2d6ceb911"/><file name="v_activate_steps.gif" hash="005312b14c6aed41e8a47c4acaac7c1a"/><file name="vbv_ltbg_71x57.gif" hash="2b0bcd07251fcaafd46e7ce77ba821a9"/></dir><dir name="cookies"><file name="firefox.png" hash="425e1b2ddc38c0bba431fb54357c66a4"/><file name="ie6-1.gif" hash="5c27700e245762bc89ed8c3ee7183f21"/><file name="ie6-2.gif" hash="d8c55e15e1f711e5c259300a9c19551b"/><file name="ie7-1.gif" hash="d61edcc8a514a3c81ea116b7d38ddcb6"/><file name="ie7-2.gif" hash="0526a654e94c54866cad977c0a47d3e5"/><file name="ie7-3.gif" hash="4fb142def3f6cfd8d8d23e1315528a1e"/><file name="ie7-4.gif" hash="575c276231c6a91e28935ec98215e146"/><file name="ie7-5.gif" hash="3ae5fcc11fe89da91674d183872337c1"/><file name="ie7-6.gif" hash="95a4981a41785a8cde273c9b2edbfbc7"/><file name="opera.png" hash="34070d92180d4ee0e37b1dd8bb731cd7"/></dir><dir name="dpd"><file name="ajax-loader.gif" hash="f3dbc538b63d07156155acf0631ae375"/><file name="button_close.png" hash="040640376fe4f699f97f0d59b64e79cf"/><file name="dpd_parcelshop_logo.png" hash="43e479d6bb23dea74f2ec6ff8a1e390c"/><file name="icon_info.gif" hash="4c85c6937f19e50c5e871c2699e99bee"/><file name="icon_info.png" hash="53faeafe236c775f54752bc2008efa97"/><file name="icon_parcelshop.png" hash="202e38024b9f41483285a7b2d34d2a56"/><file name="icon_parcelshop_shadow.png" hash="263ee734ba6bb38060fd47a5b3de64ae"/><file name="icon_route.png" hash="fe07947b6f600723e682f2fcb8fca88f"/></dir><dir name="moneybookers"><file name="banner_120_de.gif" hash="74815117bf378543e5b3496bb5bc4e8a"/><file name="banner_120_de.png" hash="6c3f708fcb6dac92e53472d4c2246c68"/><file name="banner_120_dk.gif" hash="2106bd994d188d40474bf2a2e8d62a8d"/><file name="banner_120_fr.gif" hash="a84241eef7bc38fb38567e7aa8ca245a"/><file name="banner_120_fr.png" hash="8994d1dc3b4f5c9e5efc67ce3f9f55a9"/><file name="banner_120_int.gif" hash="e23ddcf71e15f0a9300062ef9cdea512"/><file name="banner_120_int.png" hash="f9dfbc26041e52b34eea65348707d64f"/><file name="banner_120_pl.gif" hash="44313c7d27cdcf59c2f66708c6c5abd5"/><file name="banner_120_pl.png" hash="67d3385f93bc9113880305ee7c7da9de"/><file name="banner_120_sp.gif" hash="a003ed8db63620672ae945682b1e1e39"/><file name="banner_120_sp.png" hash="f9c4a653d6814ab3f8c535da706f5f77"/><file name="moneybookers_acc.png" hash="a3e639a68fafdffaca81e91985127735"/><file name="moneybookers_csi.gif" hash="4eec4ed7c494d01d518a3c6c691128e9"/><file name="moneybookers_did.gif" hash="6a3a3365894e9cdb199647a5b74ba35b"/><file name="moneybookers_dnk.gif" hash="7d4b8d27784f8a6fa6ef81c4e911831b"/><file name="moneybookers_ebt.gif" hash="9911d8cc223e7f3d9ec12f50c280ec61"/><file name="moneybookers_ent.gif" hash="704e9551ed4aff82b67114242b9fba1a"/><file name="moneybookers_gcb.gif" hash="e2e7c0f501e5ab0136f859ca5f57abc2"/><file name="moneybookers_gir.gif" hash="f16e949bc60bbd812f803d5e377d47f6"/><file name="moneybookers_idl.gif" hash="fe0ad1efc12d43df6c9ff3ffdd9dd59b"/><file name="moneybookers_lsr.gif" hash="58cdadfa20b6d37aeaa19e50995e4baf"/><file name="moneybookers_mae.gif" hash="4d4b5f0cf3377939c7738fc7e416d25f"/><file name="moneybookers_npy.gif" hash="01242c5ad7bc667e7493b550b6397fab"/><file name="moneybookers_obt_de.png" hash="ce44fd2974b8d279401778292e2c4484"/><file name="moneybookers_obt_dk.png" hash="2985e8cb472d1886d584fa31d56bee92"/><file name="moneybookers_obt_ee.png" hash="cb186be1c7595544f61d3737c7bf85aa"/><file name="moneybookers_obt_en.png" hash="eee098a06e3ea34f33e276724b084774"/><file name="moneybookers_obt_fl.png" hash="6c3766df052d875ce399e62ad8a435f8"/><file name="moneybookers_obt_lt.png" hash="adf61f248fc6d5985840db3e0c23391e"/><file name="moneybookers_obt_lv.png" hash="4e7f16b4988ea30f049942d4dcdb5f78"/><file name="moneybookers_obt_pl.png" hash="fb2c43c18ba73d390e5b5f5261261f4a"/><file name="moneybookers_obt_se.png" hash="9028412e9c3f25d114bf40bb2049d225"/><file name="moneybookers_pli.gif" hash="93989e85caff760af7a61838db0300bf"/><file name="moneybookers_psp.gif" hash="7abffc2246f172625be2ce31f4315cb2"/><file name="moneybookers_pwy.gif" hash="b4a0b9db9a031855e6e3899592012fae"/><file name="moneybookers_sft.gif" hash="e9e774163c99a8ab4deb18d37feaf658"/><file name="moneybookers_so2.gif" hash="9911d8cc223e7f3d9ec12f50c280ec61"/><file name="moneybookers_wlt.gif" hash="4b9cbc5aa5c32f3015ce7bec98da2670"/></dir><dir name="widgets"><file name="i_block-list.gif" hash="fe8424127ecbe4b0d893bcf6f253dc1a"/><file name="i_widget-link.gif" hash="1bf753578171f147f0203e7b13bdd0c4"/><file name="i_widget-new.gif" hash="a75377ffed51b711cbc608ffaa1a2e7d"/></dir><dir name="xmlconnect"><dir name="catalog"><dir name="category"><dir name="placeholder"><file name="image.jpg" hash="097ab8a3051bc037ea3de0e17f440540"/><file name="small_image.jpg" hash="f825d16f97a640453553c79c48ebaa73"/><file name="thumbnail.jpg" hash="b2b682d28a08a748a73d2cda70ab5a57"/></dir></dir></dir><file name="tab_account.png" hash="0498d73e47ed47179e5546dc15c17dc7"/><file name="tab_cart.png" hash="9055ba76e256a51d3fee53a8c41d5226"/><file name="tab_home.png" hash="07d0af93e167b9366d3d4fb3d6cdb31c"/><file name="tab_more.png" hash="b9fc21feb8d7655bc9c2985c37b0de2f"/><file name="tab_page.png" hash="ca05dbc42f944b8d4255f6675f6dd93a"/><file name="tab_search.png" hash="25e880eb2a4d06828e2e1c3f32d22400"/><file name="tab_shop.png" hash="fe602fc2e7093efef5ecc0b027a32d91"/></dir></dir><file name="cvv.gif" hash="83cdd38bf110b0f9c52fe84b56f45298"/><file name="fam_book_open.png" hash="0ba89b9fbe7e88d4c6896ed0a1f495aa"/><file name="reload.png" hash="84cc4883f78ef850814ea9b53989b2a7"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>