Smartsend_Logistics - Version 7.1.0

Version Notes

Latest stable release

Download this release

Release Info

Developer Smart Send ApS
Extension Smartsend_Logistics
Version 7.1.0
Comparing to
See all releases


Code changes from version 7.0.5 to 7.1.0

Files changed (65) hide show
  1. app/code/community/Smartsend/Logistics/.DS_Store +0 -0
  2. app/code/community/Smartsend/Logistics/Block/.DS_Store +0 -0
  3. app/code/community/Smartsend/Logistics/Block/Adminhtml/PickupShipping.php +0 -95
  4. app/code/community/Smartsend/Logistics/Block/Adminhtml/Shipping.php +16 -8
  5. app/code/community/Smartsend/Logistics/Block/Bring.php +16 -66
  6. app/code/community/Smartsend/Logistics/Block/Gls.php +17 -66
  7. app/code/community/Smartsend/Logistics/Block/Pickup.php +0 -105
  8. app/code/community/Smartsend/Logistics/Block/Postdanmark.php +33 -62
  9. app/code/community/Smartsend/Logistics/Block/Posten.php +26 -63
  10. app/code/community/Smartsend/Logistics/Block/Swipbox.php +0 -103
  11. app/code/community/Smartsend/Logistics/Model/Api/Pickups.php +139 -0
  12. app/code/community/Smartsend/Logistics/Model/Api/Validation.php +61 -0
  13. app/code/community/Smartsend/Logistics/Model/Carrier/Bring.php +58 -117
  14. app/code/community/Smartsend/Logistics/Model/Carrier/Gls.php +57 -112
  15. app/code/community/Smartsend/Logistics/Model/Carrier/Pickup.php +0 -160
  16. app/code/community/Smartsend/Logistics/Model/Carrier/Postdanmark.php +57 -114
  17. app/code/community/Smartsend/Logistics/Model/Carrier/Posten.php +57 -114
  18. app/code/community/Smartsend/Logistics/Model/Carrier/Swipbox.php +0 -170
  19. app/code/community/Smartsend/Logistics/Model/{Pickup.php → Flex.php} +3 -4
  20. app/code/community/Smartsend/Logistics/Model/Label.php +583 -0
  21. app/code/community/Smartsend/Logistics/Model/Labelmagento.php +368 -0
  22. app/code/community/Smartsend/Logistics/Model/Mysql4/{Swipbox.php → Flex.php} +4 -4
  23. app/code/community/Smartsend/Logistics/Model/Mysql4/{Swipbox → Flex}/Collection.php +3 -3
  24. app/code/community/Smartsend/Logistics/Model/Observer.php +115 -59
  25. app/code/community/Smartsend/Logistics/Model/Order.php +508 -1264
  26. app/code/community/Smartsend/Logistics/Model/Ordermagento.php +706 -0
  27. app/code/community/Smartsend/Logistics/Model/Rewrite/Sales/Total/Quote/Shipping.php +68 -45
  28. app/code/community/Smartsend/Logistics/Model/Rewrite/Sales/Total/Quote/Tax.php +6 -6
  29. app/code/community/Smartsend/Logistics/Model/ShippingMethods.php +129 -199
  30. app/code/community/Smartsend/Logistics/Model/System/.DS_Store +0 -0
  31. app/code/community/Smartsend/Logistics/Model/System/CombinePdf.php +3 -3
  32. app/code/community/Smartsend/Logistics/Model/System/Listformat.php +4 -4
  33. app/code/community/Smartsend/Logistics/Model/System/OrderOption.php +2 -2
  34. app/code/community/Smartsend/Logistics/Model/System/Pacsoftformat.php +2 -2
  35. app/code/community/Smartsend/Logistics/Model/System/{PickupMethods.php → Postdanmark/Flexdelivery.php} +12 -9
  36. app/code/community/Smartsend/Logistics/Model/System/{Pickup/Listformat.php → Posten/Flexdelivery.php} +13 -5
  37. app/code/community/Smartsend/Logistics/Model/System/Return.php +5 -5
  38. app/code/community/Smartsend/Logistics/Model/System/{Size.php → Status.php} +13 -7
  39. app/code/community/Smartsend/Logistics/Model/System/Validateuser.php +31 -0
  40. app/code/community/Smartsend/Logistics/controllers/LogisticsController.php +128 -345
  41. app/code/community/Smartsend/Logistics/etc/.DS_Store +0 -0
  42. app/code/community/Smartsend/Logistics/etc/config.xml +51 -55
  43. app/code/community/Smartsend/Logistics/etc/system.xml +125 -343
  44. app/code/community/Smartsend/Logistics/sql/logistics_setup/mysql4-install-7.0.1.php +262 -53
  45. app/code/community/Smartsend/Logistics/sql/logistics_setup/mysql4-upgrade-7.0.5-7.0.6.php +75 -0
  46. app/code/community/Smartsend/Logistics/{Model/Swipbox.php → sql/logistics_setup/mysql4-upgrade-7.0.9-7.1.0.php} +15 -7
  47. app/design/adminhtml/default/default/layout/logistics.xml +63 -25
  48. app/design/adminhtml/default/default/template/logistics/array_dropdown.phtml +37 -0
  49. app/design/adminhtml/default/default/template/logistics/sales/order/view/info.phtml +79 -48
  50. app/design/adminhtml/default/default/template/logistics/sales/order/view/tab/info.phtml +77 -48
  51. app/design/frontend/base/default/layout/logistics.xml +165 -18
  52. app/design/frontend/base/default/template/logistics/.DS_Store +0 -0
  53. app/design/frontend/base/default/template/logistics/checkout/.DS_Store +0 -0
  54. app/design/frontend/base/default/template/logistics/checkout/cart/shipping.phtml +157 -0
  55. app/design/frontend/base/default/template/logistics/checkout/onepage/.DS_Store +0 -0
  56. app/design/frontend/base/default/template/logistics/checkout/onepage/shipping_method/available.phtml +4 -9
  57. app/design/frontend/base/default/template/logistics/email/order/shipment/track.phtml +68 -0
  58. app/design/frontend/base/default/template/logistics/magestoreOnestepcheckout/shipping_method.phtml +178 -0
  59. app/design/frontend/base/default/template/logistics/onestepcheckout/shipping_method.phtml +13 -21
  60. app/design/frontend/base/default/template/logistics/pickup.phtml +53 -13
  61. app/locale/da_DK/Smartsend_Logistics.csv +150 -95
  62. app/locale/da_DK/template/email/smartsend_new_shipment_email.html +46 -0
  63. js/logistics/jquery-1.10.2.min.js +6 -0
  64. package.xml +60 -11
  65. skin/frontend/base/default/js/logistics.js +44 -0
app/code/community/Smartsend/Logistics/.DS_Store ADDED
Binary file
app/code/community/Smartsend/Logistics/Block/.DS_Store ADDED
Binary file
app/code/community/Smartsend/Logistics/Block/Adminhtml/PickupShipping.php DELETED
@@ -1,95 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Smartsend_Logistics
5
- *
6
- * This source file is subject to the GNU General Public License v3.0
7
- * that is bundled with this package in the file license.txt.
8
- * It is also available through the world-wide-web at this URL:
9
- * http://www.gnu.org/licenses/gpl-3.0.html
10
- * If you did not receive a copy of the license and are unable to
11
- * obtain it through the world-wide-web, please send an email
12
- * to license@smartsend.dk so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
- * versions in the future. If you wish to customize the plugin for your
18
- * needs please refer to http://www.smartsend.dk
19
- *
20
- * @folder /app/code/community/Smartsend/Logistics/Block/Adminhtml/Shipping.php
21
- * @category Smartsend
22
- * @package Smartsend_Logistics
23
- * @author Anders Bilfeldt
24
- * @url www.smartsend.dk
25
- */
26
- class Smartsend_Logistics_Block_Adminhtml_PickupShipping extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract {
27
-
28
-
29
-
30
- public function __construct() { // create columns for the pickup carrier system config
31
-
32
- $this->addColumn('methods', array(
33
- 'label' => $this->__('Methods'),
34
- 'size' => 6,
35
- ));
36
- $this->addColumn('orderminprice', array(
37
- 'label' => $this->__('Min Price'),
38
- 'size' => 6,
39
- ));
40
- $this->addColumn('ordermaxprice', array(
41
- 'label' => $this->__('Max Price'),
42
- 'size' => 6,
43
- ));
44
- $this->addColumn('orderminweight', array(
45
- 'label' => $this->__('Min Weight'),
46
- 'size' => 6,
47
- ));
48
- $this->addColumn('ordermaxweight', array(
49
- 'label' => $this->__('Max Weight'),
50
- 'size' => 6,
51
- ));
52
- $this->addColumn('pickupshippingfee', array(
53
- 'label' => $this->__('Shipping Fee'),
54
- 'size' => 6,
55
- ));
56
-
57
- $this->addColumn('countries', array(
58
- 'label' => $this->__('Countries'),
59
- 'size' => 6,
60
- ));
61
-
62
-
63
-
64
- $this->_addAfter = false;
65
- $this->_addButtonLabel = $this->__('Add Rate');
66
-
67
- parent::__construct();
68
- $this->setTemplate('logistics/array_dropdown.phtml'); //get the dropdown for the price shipping table for pickup carrier
69
-
70
-
71
- }
72
-
73
- protected function _renderCellTemplate($columnName) { //inserts the value to the created columns above
74
- if (empty($this->_columns[$columnName])) { //checking the column names
75
- throw new Exception('Wrong column name specified.');
76
- }
77
- $column = $this->_columns[$columnName];
78
- $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
79
-
80
- if ($columnName == 'methods') { //for column name methods
81
- $shippingmethods = Mage::getModel('logistics/shippingMethods')->getOptionArray($inputName); //getting the list of shipping methods for the column methods
82
-
83
- $rendered = '<select style="width:100px;" name="' . $inputName . '">';
84
-
85
- foreach ($shippingmethods as $att => $name) {
86
- $rendered .= '<option value="' . $att . '">' . $name . '</option>';
87
- }
88
- $rendered .= '</select>';
89
- } else { //for other column than methods
90
- return '<input type="text" class="required-entry" name="' . $inputName . '" value="#{' . $columnName . '}" ' . ($column['size'] ? 'size="' . $column['size'] . '"' : '') . '/>';
91
- }
92
- return $rendered;
93
- }
94
-
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Smartsend/Logistics/Block/Adminhtml/Shipping.php CHANGED
@@ -27,27 +27,27 @@ class Smartsend_Logistics_Block_Adminhtml_Shipping extends Mage_Adminhtml_Block_
27
 
28
  public function __construct() { // create columns for the table rate for the carriers(other than pickup) system config
29
  $this->addColumn('methods', array(
30
- 'label' => $this->__('Methods'),
31
  'size' => 6,
32
  ));
33
  $this->addColumn('orderminprice', array(
34
- 'label' => $this->__('Min Price'),
35
  'size' => 6,
36
  ));
37
  $this->addColumn('ordermaxprice', array(
38
- 'label' => $this->__('Max Price'),
39
  'size' => 6,
40
  ));
41
  $this->addColumn('orderminweight', array(
42
- 'label' => $this->__('Min Weight'),
43
  'size' => 6,
44
  ));
45
  $this->addColumn('ordermaxweight', array(
46
- 'label' => $this->__('Max Weight'),
47
  'size' => 6,
48
  ));
49
  $this->addColumn('pickupshippingfee', array(
50
- 'label' => $this->__('Shipping Fee'),
51
  'size' => 6,
52
  ));
53
 
@@ -57,17 +57,25 @@ class Smartsend_Logistics_Block_Adminhtml_Shipping extends Mage_Adminhtml_Block_
57
  ));
58
 
59
  $this->addColumn('method_name', array(
60
- 'label' => $this->__('Method Name'),
61
  'size' => 6,
62
  ));
63
 
64
  $this->_addAfter = false;
65
- $this->_addButtonLabel = $this->__('Add Rate');
66
 
67
  parent::__construct();
68
  $this->setTemplate('logistics/array_dropdown.phtml'); //get the dropdown for the price shipping table for carriers other than pickup carrier
69
  }
70
 
 
 
 
 
 
 
 
 
71
  protected function _renderCellTemplate($columnName) { //inserts the value to the created columns above
72
  if (empty($this->_columns[$columnName])) { //checking the column names
73
  throw new Exception('Wrong column name specified.');
27
 
28
  public function __construct() { // create columns for the table rate for the carriers(other than pickup) system config
29
  $this->addColumn('methods', array(
30
+ 'label' => $this->__('Shipping method'),
31
  'size' => 6,
32
  ));
33
  $this->addColumn('orderminprice', array(
34
+ 'label' => $this->__('Min. price'),
35
  'size' => 6,
36
  ));
37
  $this->addColumn('ordermaxprice', array(
38
+ 'label' => $this->__('Max. price'),
39
  'size' => 6,
40
  ));
41
  $this->addColumn('orderminweight', array(
42
+ 'label' => $this->__('Min. weight'),
43
  'size' => 6,
44
  ));
45
  $this->addColumn('ordermaxweight', array(
46
+ 'label' => $this->__('Max. weight'),
47
  'size' => 6,
48
  ));
49
  $this->addColumn('pickupshippingfee', array(
50
+ 'label' => $this->__('Shipping fee'),
51
  'size' => 6,
52
  ));
53
 
57
  ));
58
 
59
  $this->addColumn('method_name', array(
60
+ 'label' => $this->__('Title'),
61
  'size' => 6,
62
  ));
63
 
64
  $this->_addAfter = false;
65
+ $this->_addButtonLabel = $this->__('Add rate');
66
 
67
  parent::__construct();
68
  $this->setTemplate('logistics/array_dropdown.phtml'); //get the dropdown for the price shipping table for carriers other than pickup carrier
69
  }
70
 
71
+
72
+ /**
73
+ * Funciton to return the input fields of the shipping table
74
+ *
75
+ * @param string $columnName Is the column name of the shipping table
76
+ *
77
+ * @return string HTML string of field (input, select ...)
78
+ */
79
  protected function _renderCellTemplate($columnName) { //inserts the value to the created columns above
80
  if (empty($this->_columns[$columnName])) { //checking the column names
81
  throw new Exception('Wrong column name specified.');
app/code/community/Smartsend/Logistics/Block/Bring.php CHANGED
@@ -30,74 +30,24 @@ class Smartsend_Logistics_Block_Bring extends Mage_Checkout_Block_Onepage_Shippi
30
  }
31
 
32
  public function getPickupData() {
33
- $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
- $street = $checkOut->getStreet();
35
- $street = implode(' ', $street); // splitting the street by " "(space)
36
- $city = $checkOut->getCity();
37
- $postcode = $checkOut->getPostcode();
38
- $country = $checkOut->getCountry();
39
- $result = Mage::getSingleton('logistics/carrier_bring')->_post($street, $city, $postcode, $country); // get the pickup points for the bring carrier
 
40
 
41
- $output = json_decode($result->response, true); // decoding the pickup points data into array
42
- if (!$output) { // if no pickup data return false
43
- return FALSE;
44
- }
45
- $servicePoints = $output;
46
 
47
- $format = Mage::getStoreConfig('carriers/smartsendbring/listformat'); //get the address format from the admin system config
48
- for ($i = 0; $i < count($servicePoints); $i++) {
49
- if (!isset($servicePoints[$i])) {
50
- break;
51
- }
52
- $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
53
- switch ($format) {
54
- case 1:
55
- $resultData[$addressData['servicePointId']] = array(
56
- 'company' => $addressData['company'],
57
- 'street' => $addressData['street'],
58
- 'zip_code' => $addressData['zipcode'],
59
- 'city' => $addressData['city']
60
- );
61
- break;
62
- case 2:
63
- $resultData[$addressData['servicePointId']] = array(
64
- 'company' => $addressData['company'],
65
- 'street' => $addressData['street'],
66
- 'zipcode' => $addressData['zipcode']
67
- );
68
- break;
69
- case 3:
70
- $resultData[$addressData['servicePointId']] = array(
71
- 'company' => $addressData['company'],
72
- 'street' => $addressData['street'],
73
- 'city' => $addressData['city']
74
- );
75
- default:
76
- $resultData[$addressData['servicePointId']] = array(
77
- 'company' => $addressData['company'],
78
- 'street' => $addressData['street'],
79
- );
80
- break;
81
- }
82
- }
83
- if (!isset($resultData)) {
84
- $resultData = "";
85
- }
86
- return $resultData;
87
- }
88
-
89
- protected function getaddressData($servicePoint) {
90
- $data['pick_up_id'] = $servicePoint['pickupid'];
91
- $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
92
- $data['city'] = $servicePoint['city'];
93
- $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
94
- $data['zipcode'] = $servicePoint['zip'];
95
- $data['shippingMethod'] = $servicePoint['carrier'];
96
- $data['country'] = $servicePoint['country'];
97
- $ser = serialize($data);
98
- $data['servicePointId'] = $ser;
99
-
100
- return $data;
101
  }
102
 
103
  }
30
  }
31
 
32
  public function getPickupData() {
33
+ $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
+
35
+ $street = $checkOut->getStreet();
36
+ $street = implode(' ', $street); // splitting the street by " "(space)
37
+ $city = $checkOut->getCity();
38
+ $postcode = $checkOut->getPostcode();
39
+ $country = $checkOut->getCountry();
40
+ $carriers = 'bring';
41
 
42
+ $pickup = Mage::getModel('logistics/api_pickups');
43
+
44
+ $pickup->_post($street, $city, $postcode, $country,$carriers); // get the pickup points for the postdanmark carrier
 
 
45
 
46
+ if($pickup->getPickupPoints() != false) {
47
+ return $pickup->getPickupPoints();
48
+ } else {
49
+ return false;
50
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
 
53
  }
app/code/community/Smartsend/Logistics/Block/Gls.php CHANGED
@@ -28,75 +28,26 @@ class Smartsend_Logistics_Block_Gls extends Mage_Checkout_Block_Onepage_Shipping
28
  public function __construct() {
29
  $this->setTemplate('logistics/pickup.phtml'); // pickup points for gls
30
  }
31
-
32
  public function getPickupData() {
33
- $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
- $street = $checkOut->getStreet();
35
- $street = implode(' ', $street); // splitting the street by " "(space)
36
- $city = $checkOut->getCity();
37
- $postcode = $checkOut->getPostcode();
38
- $country = $checkOut->getCountry();
39
- $result = Mage::getSingleton('logistics/carrier_gls')->_post($street, $city, $postcode, $country); // get the pickup points for the gls carrier
40
-
41
- $output = json_decode($result->response, true); // decoding the pickup points data into array
42
- if (!$output) { // if no pickup data return false
43
- return FALSE;
44
- }
45
- $servicePoints = $output;
46
 
47
- $format = Mage::getStoreConfig('carriers/smartsendgls/listformat'); //get the address format from the admin system config
48
- for ($i = 0; $i < count($servicePoints); $i++) {
49
- if (!isset($servicePoints[$i])) {
50
- break;
51
- }
52
- $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
53
- switch ($format) {
54
- case 1:
55
- $resultData[$addressData['servicePointId']] = array(
56
- 'company' => $addressData['company'],
57
- 'street' => $addressData['street'],
58
- 'zip_code' => $addressData['zipcode'],
59
- 'city' => $addressData['city']
60
- );
61
- break;
62
- case 2:
63
- $resultData[$addressData['servicePointId']] = array(
64
- 'company' => $addressData['company'],
65
- 'street' => $addressData['street'],
66
- 'zipcode' => $addressData['zipcode']
67
- );
68
- break;
69
- case 3:
70
- $resultData[$addressData['servicePointId']] = array(
71
- 'company' => $addressData['company'],
72
- 'street' => $addressData['street'],
73
- 'city' => $addressData['city']
74
- );
75
- default:
76
- $resultData[$addressData['servicePointId']] = array(
77
- 'company' => $addressData['company'],
78
- 'street' => $addressData['street'],
79
- );
80
- break;
81
- }
82
- }
83
- if (!isset($resultData)) {
84
- $resultData = "";
85
- }
86
- return $resultData;
87
- }
88
 
89
- protected function getaddressData($servicePoint) {
90
- $data['pick_up_id'] = $servicePoint['pickupid'];
91
- $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
92
- $data['city'] = $servicePoint['city'];
93
- $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
94
- $data['zipcode'] = $servicePoint['zip'];
95
- $data['shippingMethod'] = $servicePoint['carrier'];
96
- $data['country'] = $servicePoint['country'];
97
- $ser = serialize($data);
98
- $data['servicePointId'] = $ser;
99
- return $data;
100
  }
101
 
102
  }
28
  public function __construct() {
29
  $this->setTemplate('logistics/pickup.phtml'); // pickup points for gls
30
  }
31
+
32
  public function getPickupData() {
33
+ $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
+
35
+ $street = $checkOut->getStreet();
36
+ $street = implode(' ', $street); // splitting the street by " "(space)
37
+ $city = $checkOut->getCity();
38
+ $postcode = $checkOut->getPostcode();
39
+ $country = $checkOut->getCountry();
40
+ $carriers = 'gls';
 
 
 
 
 
41
 
42
+ $pickup = Mage::getModel('logistics/api_pickups');
43
+
44
+ $pickup->_post($street, $city, $postcode, $country,$carriers); // get the pickup points for the postdanmark carrier
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ if($pickup->getPickupPoints() != false) {
47
+ return $pickup->getPickupPoints();
48
+ } else {
49
+ return false;
50
+ }
 
 
 
 
 
 
51
  }
52
 
53
  }
app/code/community/Smartsend/Logistics/Block/Pickup.php DELETED
@@ -1,105 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Smartsend_Logistics
5
- *
6
- * This source file is subject to the GNU General Public License v3.0
7
- * that is bundled with this package in the file license.txt.
8
- * It is also available through the world-wide-web at this URL:
9
- * http://www.gnu.org/licenses/gpl-3.0.html
10
- * If you did not receive a copy of the license and are unable to
11
- * obtain it through the world-wide-web, please send an email
12
- * to license@smartsend.dk so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
- * versions in the future. If you wish to customize the plugin for your
18
- * needs please refer to http://www.smartsend.dk
19
- *
20
- * @folder /app/code/community/Smartsend/Logistics/Block/Pickup.php
21
- * @category Smartsend
22
- * @package Smartsend_Logistics
23
- * @author Anders Bilfeldt
24
- * @url www.smartsend.dk
25
- */
26
- class Smartsend_Logistics_Block_Pickup extends Mage_Checkout_Block_Onepage_Shipping_Method_Available {
27
-
28
- public function __construct() {
29
- $this->setTemplate('logistics/pickup.phtml');
30
- }
31
-
32
- public function getPickupData() {
33
- $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
- $street = $checkOut->getStreet();
35
- $street = implode(' ', $street); // splitting the street by " "(space)
36
- $city = $checkOut->getCity();
37
- $postcode = $checkOut->getPostcode();
38
- $country = $checkOut->getCountry();
39
- $result = Mage::getSingleton('logistics/carrier_pickup')->_post($street, $city, $postcode, $country); // get the pickup points for the pickup carrier
40
-
41
- $output = json_decode($result->response, true); // decoding the pickup points data into array
42
- if (!$output) { // if no pickup data return false
43
- return FALSE;
44
- }
45
- $servicePoints = $output;
46
-
47
-
48
- $format = Mage::getStoreConfig('carriers/smartsendpickup/listformat'); //get the address format from the admin system config
49
- for ($i = 0; $i < count($servicePoints); $i++) {
50
- if (!isset($servicePoints[$i])) {
51
- break;
52
- }
53
- $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
54
- if ($addressData) {
55
- switch ($format) {
56
- case 0:
57
- $resultData[$addressData['servicePointId']] = array(
58
- 'company' => $addressData['company'],
59
- 'street' => $addressData['street'],
60
- 'zip_code' => $addressData['zipcode'],
61
- 'city' => $addressData['city']
62
- );
63
- break;
64
- case 1:
65
- $resultData[$addressData['servicePointId']] = array(
66
- 'company' => $addressData['company'],
67
- 'street' => $addressData['street'],
68
- 'zipcode' => $addressData['zipcode']
69
- );
70
- break;
71
- case 2:
72
- $resultData[$addressData['servicePointId']] = array(
73
- 'company' => $addressData['company'],
74
- 'street' => $addressData['street'],
75
- 'city' => $addressData['city']
76
- );
77
- default:
78
- $resultData[$addressData['servicePointId']] = array(
79
- 'company' => $addressData['company'],
80
- 'street' => $addressData['street'],
81
- );
82
- break;
83
- }
84
- }
85
- }
86
- if (!isset($resultData)) {
87
- $resultData = "";
88
- }
89
- return $resultData;
90
- }
91
-
92
- protected function getaddressData($servicePoint) {
93
- $data['pick_up_id'] = $servicePoint['pickupid'];
94
- $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
95
- $data['city'] = $servicePoint['city'];
96
- $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
97
- $data['zipcode'] = $servicePoint['zip'];
98
- $data['shippingMethod'] = $servicePoint['carrier'];
99
- $data['country'] = $servicePoint['country'];
100
- $ser = serialize($data);
101
- $data['servicePointId'] = $ser;
102
- return $data;
103
- }
104
-
105
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Smartsend/Logistics/Block/Postdanmark.php CHANGED
@@ -30,73 +30,44 @@ class Smartsend_Logistics_Block_Postdanmark extends Mage_Checkout_Block_Onepage_
30
  }
31
 
32
  public function getPickupData() {
33
- $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
- $street = $checkOut->getStreet();
35
- $street = implode(' ', $street); // splitting the street by " "(space)
36
- $city = $checkOut->getCity();
37
- $postcode = $checkOut->getPostcode();
38
- $country = $checkOut->getCountry();
39
- $result = Mage::getSingleton('logistics/carrier_postdanmark')->_post($street, $city, $postcode, $country); // get the pickup points for the postdanmark carrier
 
40
 
41
- $output = json_decode($result->response, true); // decoding the pickup points data into array
42
- if (!$output) { // if no pickup data return false
43
- return FALSE;
44
- }
45
- $servicePoints = $output;
46
 
47
- $format = Mage::getStoreConfig('carriers/smartsendpostdanmark/listformat'); //get the address format from the admin system config
48
- for ($i = 0; $i < count($servicePoints); $i++) {
49
- if (!isset($servicePoints[$i])) {
50
- break;
51
- }
52
- $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
53
- switch ($format) {
54
- case 1:
55
- $resultData[$addressData['servicePointId']] = array(
56
- 'company' => $addressData['company'],
57
- 'street' => $addressData['street'],
58
- 'zip_code' => $addressData['zipcode'],
59
- 'city' => $addressData['city']
60
- );
61
- break;
62
- case 2:
63
- $resultData[$addressData['servicePointId']] = array(
64
- 'company' => $addressData['company'],
65
- 'street' => $addressData['street'],
66
- 'zipcode' => $addressData['zipcode']
67
- );
68
- break;
69
- case 3:
70
- $resultData[$addressData['servicePointId']] = array(
71
- 'company' => $addressData['company'],
72
- 'street' => $addressData['street'],
73
- 'city' => $addressData['city']
74
- );
75
- default:
76
- $resultData[$addressData['servicePointId']] = array(
77
- 'company' => $addressData['company'],
78
- 'street' => $addressData['street'],
79
- );
80
- break;
81
- }
82
- }
83
- if (!isset($resultData)) {
84
- $resultData = "";
85
  }
86
- return $resultData;
87
  }
88
 
89
- protected function getaddressData($servicePoint) {
90
- $data['pick_up_id'] = $servicePoint['pickupid'];
91
- $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
92
- $data['city'] = $servicePoint['city'];
93
- $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
94
- $data['zipcode'] = $servicePoint['zip'];
95
- $data['shippingMethod'] = $servicePoint['carrier'];
96
- $data['country'] = $servicePoint['country'];
97
- $ser = serialize($data);
98
- $data['servicePointId'] = $ser;
99
- return $data;
 
 
 
 
 
 
 
100
  }
101
 
102
  }
30
  }
31
 
32
  public function getPickupData() {
33
+ $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
+
35
+ $street = $checkOut->getStreet();
36
+ $street = implode(' ', $street); // splitting the street by " "(space)
37
+ $city = $checkOut->getCity();
38
+ $postcode = $checkOut->getPostcode();
39
+ $country = $checkOut->getCountry();
40
+ $carriers = 'postdanmark';
41
 
42
+ $pickup = Mage::getModel('logistics/api_pickups');
 
 
 
 
43
 
44
+ $pickup->_post($street, $city, $postcode, $country, $carriers); // get the pickup points for the postdanmark carrier
45
+
46
+ if ($pickup->getPickupPoints() != false) {
47
+ return $pickup->getPickupPoints();
48
+ } else {
49
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
 
51
  }
52
 
53
+ public function getFlexData($carrier) {
54
+
55
+ $array = array(
56
+ $this->__('By the frontdoor') => $this->__('By the frontdoor'),
57
+ $this->__('By the carport') => $this->__('By the carport'),
58
+ $this->__('By the back dor') => $this->__('By the back dor'),
59
+ $this->__('I have Modtagerflex') => $this->__('I have Modtagerflex'),
60
+ $this->__('Can be left unattended') => $this->__('Can be left unattended')
61
+ );
62
+ $array2 = array();
63
+ $flexShippingMethods = Mage::getStoreConfig('carriers/smartsendpostdanmark/flexdelivery');
64
+ $flexShippingMethods = explode(',', $flexShippingMethods);
65
+
66
+ if (in_array($carrier, $flexShippingMethods)) {
67
+ return $array;
68
+ } else {
69
+ return $array2;
70
+ }
71
  }
72
 
73
  }
app/code/community/Smartsend/Logistics/Block/Posten.php CHANGED
@@ -30,75 +30,38 @@ class Smartsend_Logistics_Block_Posten extends Mage_Checkout_Block_Onepage_Shipp
30
  }
31
 
32
  public function getPickupData() {
33
- $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
- $street = $checkOut->getStreet();
35
- $street = implode(' ', $street); // splitting the street by " "(space)
36
- $city = $checkOut->getCity();
37
- $postcode = $checkOut->getPostcode();
38
- $country = $checkOut->getCountry();
39
- $result = Mage::getSingleton('logistics/carrier_posten')->_post($street, $city, $postcode, $country); // get the pickup points for the posten carrier
 
40
 
41
- $output = json_decode($result->response, true); // decoding the pickup points data into array
42
- if (!$output) { // if no pickup data return false
43
- return FALSE;
44
- }
45
- $servicePoints = $output;
46
 
47
- $format = Mage::getStoreConfig('carriers/smartsendposten/listformat'); //get the address format from the admin system config
48
-
49
- for ($i = 0; $i < count($servicePoints); $i++) {
50
- if (!isset($servicePoints[$i])) {
51
- break;
52
- }
53
 
54
- $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
55
- switch ($format) {
56
- case 1:
57
- $resultData[$addressData['servicePointId']] = array(
58
- 'company' => $addressData['company'],
59
- 'street' => $addressData['street'],
60
- 'zip_code' => $addressData['zipcode'],
61
- 'city' => $addressData['city']
62
- );
63
- break;
64
- case 2:
65
- $resultData[$addressData['servicePointId']] = array(
66
- 'company' => $addressData['company'],
67
- 'street' => $addressData['street'],
68
- 'zipcode' => $addressData['zipcode']
69
- );
70
- break;
71
- case 3:
72
- $resultData[$addressData['servicePointId']] = array(
73
- 'company' => $addressData['company'],
74
- 'street' => $addressData['street'],
75
- 'city' => $addressData['city']
76
- );
77
- default:
78
- $resultData[$addressData['servicePointId']] = array(
79
- 'company' => $addressData['company'],
80
- 'street' => $addressData['street'],
81
- );
82
- break;
83
- }
84
- }
85
- if (!isset($resultData)) {
86
- $resultData = "";
87
  }
88
- return $resultData;
89
  }
90
 
91
- protected function getaddressData($servicePoint) {
92
- $data['pick_up_id'] = $servicePoint['pickupid'];
93
- $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
94
- $data['city'] = $servicePoint['city'];
95
- $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
96
- $data['zipcode'] = $servicePoint['zip'];
97
- $data['shippingMethod'] = $servicePoint['carrier'];
98
- $data['country'] = $servicePoint['country'];
99
- $ser = serialize($data);
100
- $data['servicePointId'] = $ser;
101
- return $data;
 
102
  }
103
 
104
  }
30
  }
31
 
32
  public function getPickupData() {
33
+ $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
34
+
35
+ $street = $checkOut->getStreet();
36
+ $street = implode(' ', $street); // splitting the street by " "(space)
37
+ $city = $checkOut->getCity();
38
+ $postcode = $checkOut->getPostcode();
39
+ $country = $checkOut->getCountry();
40
+ $carriers = 'posten';
41
 
42
+ $pickup = Mage::getModel('logistics/api_pickups');
 
 
 
 
43
 
44
+ $pickup->_post($street, $city, $postcode, $country, $carriers); // get the pickup points for the postdanmark carrier
 
 
 
 
 
45
 
46
+ if ($pickup->getPickupPoints() != false) {
47
+ return $pickup->getPickupPoints();
48
+ } else {
49
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }
 
51
  }
52
 
53
+ public function getFlexData($carrier) {
54
+
55
+ $array = array();
56
+ $array2 = array();
57
+ $flexShippingMethods = Mage::getStoreConfig('carriers/smartsendposten/flexdelivery');
58
+ $flexShippingMethods = explode(',', $flexShippingMethods);
59
+
60
+ if (in_array($carrier, $flexShippingMethods)) {
61
+ return $array;
62
+ } else {
63
+ return $array2;
64
+ }
65
  }
66
 
67
  }
app/code/community/Smartsend/Logistics/Block/Swipbox.php DELETED
@@ -1,103 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Smartsend_Logistics
5
- *
6
- * This source file is subject to the GNU General Public License v3.0
7
- * that is bundled with this package in the file license.txt.
8
- * It is also available through the world-wide-web at this URL:
9
- * http://www.gnu.org/licenses/gpl-3.0.html
10
- * If you did not receive a copy of the license and are unable to
11
- * obtain it through the world-wide-web, please send an email
12
- * to license@smartsend.dk so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
- * versions in the future. If you wish to customize the plugin for your
18
- * needs please refer to http://www.smartsend.dk
19
- *
20
- * @folder /app/code/community/Smartsend/Logistics/Block/Swipbox.php
21
- * @category Smartsend
22
- * @package Smartsend_Logistics
23
- * @author Anders Bilfeldt
24
- * @url www.smartsend.dk
25
- */
26
- class Smartsend_Logistics_Block_Swipbox extends Mage_Checkout_Block_Onepage_Shipping_Method_Available {
27
-
28
- public function __construct() {
29
- $this->setTemplate('logistics/pickup.phtml'); // swipbox html needs to be done yet
30
- }
31
-
32
- public function getPickupData() {
33
-
34
- $checkOut = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); //getting shipping address from checkout quote
35
- $street = $checkOut->getStreet();
36
- $street = implode(' ', $street); // splitting the street by " "(space)
37
- $city = $checkOut->getCity();
38
- $postcode = $checkOut->getPostcode();
39
- $country = $checkOut->getCountry();
40
- $result = Mage::getSingleton('logistics/carrier_swipbox')->_post($street, $city, $postcode, $country); // get the pickup points for the swipbox carrier
41
-
42
- $output = json_decode($result->response, true); // decoding the pickup points data into array
43
- if (!$output) { // if no pickup data return false
44
- return FALSE;
45
- }
46
- $servicePoints = $output;
47
-
48
- $format = Mage::getStoreConfig('carriers/smartsendswipbox/listformat'); //get the address format from the admin system config
49
- for ($i = 0; $i < count($servicePoints); $i++) {
50
- if (!isset($servicePoints[$i])) {
51
- break;
52
- }
53
- $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
54
- switch ($format) {
55
- case 1:
56
- $resultData[$addressData['servicePointId']] = array(
57
- 'company' => $addressData['company'],
58
- 'street' => $addressData['street'],
59
- 'zip_code' => $addressData['zipcode'],
60
- 'city' => $addressData['city']
61
- );
62
- break;
63
- case 2:
64
- $resultData[$addressData['servicePointId']] = array(
65
- 'company' => $addressData['company'],
66
- 'street' => $addressData['street'],
67
- 'zipcode' => $addressData['zipcode']
68
- );
69
- break;
70
- case 3:
71
- $resultData[$addressData['servicePointId']] = array(
72
- 'company' => $addressData['company'],
73
- 'street' => $addressData['street'],
74
- 'city' => $addressData['city']
75
- );
76
- default:
77
- $resultData[$addressData['servicePointId']] = array(
78
- 'company' => $addressData['company'],
79
- 'street' => $addressData['street'],
80
- );
81
- break;
82
- }
83
- }
84
- if (!isset($resultData)) {
85
- $resultData = "";
86
- }
87
- return $resultData;
88
- }
89
-
90
- protected function getaddressData($servicePoint) {
91
- $data['pick_up_id'] = $servicePoint['pickupid'];
92
- $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
93
- $data['city'] = $servicePoint['city'];
94
- $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
95
- $data['zipcode'] = $servicePoint['zip'];
96
- $data['shippingMethod'] = $servicePoint['carrier'];
97
- $data['country'] = $servicePoint['country'];
98
- $ser = serialize($data);
99
- $data['servicePointId'] = $ser;
100
- return $data;
101
- }
102
-
103
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Smartsend/Logistics/Model/Api/Pickups.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Smartsend_Logistics
5
+ *
6
+ * This source file is subject to the GNU General Public License v3.0
7
+ * that is bundled with this package in the file license.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.gnu.org/licenses/gpl-3.0.html
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@smartsend.dk so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
+ * versions in the future. If you wish to customize the plugin for your
18
+ * needs please refer to http://www.smartsend.dk
19
+ *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/Api/Pickups.php
21
+ * @category Smartsend
22
+ * @package Smartsend_Logistics
23
+ * @author Anders Bilfeldt
24
+ * @url www.smartsend.dk
25
+ */
26
+ class Smartsend_Logistics_Model_Api_Pickups extends Mage_Core_Model_Abstract {
27
+
28
+ private $_pickupPoints;
29
+
30
+ public function __construct() {
31
+ }
32
+
33
+ public function _post($street, $city, $postcode, $country,$carriers) {
34
+
35
+ $ch = curl_init();
36
+
37
+ /* Script URL */
38
+ $url = 'http://smartsend-prod.apigee.net/v7/pickup/';
39
+
40
+ /* $_GET Parameters to Send */
41
+ $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
42
+
43
+ /* Update URL to container Query String of Paramaters */
44
+ $url .= $carriers . '?' . http_build_query($params);
45
+
46
+ curl_setopt($ch, CURLOPT_URL, $url); //curl url
47
+ curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
48
+ //curl_setopt($ch, CURLOPT_HEADER, false);
49
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
50
+ 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
51
+ 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
52
+ 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licensekey'),
53
+ 'cmssystem:Magento',
54
+ 'cmsversion:'.Mage::getVersion(),
55
+ 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
56
+ )); //curl request header
57
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
58
+
59
+ $result = new StdClass();
60
+ $result->response = curl_exec($ch); //executing curl
61
+ $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
62
+ $result->meta = curl_getinfo($ch);
63
+ $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting curl error if any
64
+
65
+ curl_close($ch); //curl closing
66
+
67
+ if($curl_error == null && $result->response != '') {
68
+ $this->_pickupPoints = json_decode($result->response, true);
69
+ }
70
+ }
71
+
72
+ public function getPickupPoints() {
73
+
74
+ // decoding the pickup points data into array
75
+ if( isset($this->_pickupPoints) && is_array($this->_pickupPoints) ) { // if no pickup data return false
76
+ $servicePoints = $this->_pickupPoints;
77
+ $format = Mage::getStoreConfig('carriers/smartsend/listformat'); //get the address format from the admin system config
78
+ for ($i = 0; $i < count($servicePoints); $i++) {
79
+ if (!isset($servicePoints[$i])) {
80
+ break;
81
+ }
82
+ $addressData = $this->getaddressData($servicePoints[$i]); //getting address data form the pickup points response
83
+ switch ($format) {
84
+ case 1:
85
+ $resultData[$addressData['servicePointId']] = array(
86
+ 'company' => $addressData['company'],
87
+ 'street' => $addressData['street'],
88
+ 'zip_code' => $addressData['zipcode'],
89
+ 'city' => $addressData['city']
90
+ );
91
+ break;
92
+ case 2:
93
+ $resultData[$addressData['servicePointId']] = array(
94
+ 'company' => $addressData['company'],
95
+ 'street' => $addressData['street'],
96
+ 'zipcode' => $addressData['zipcode']
97
+ );
98
+ break;
99
+ case 3:
100
+ $resultData[$addressData['servicePointId']] = array(
101
+ 'company' => $addressData['company'],
102
+ 'street' => $addressData['street'],
103
+ 'city' => $addressData['city']
104
+ );
105
+ default:
106
+ $resultData[$addressData['servicePointId']] = array(
107
+ 'company' => $addressData['company'],
108
+ 'street' => $addressData['street'],
109
+ );
110
+ break;
111
+ }
112
+ }
113
+ }
114
+
115
+ if(isset($resultData) && is_array($resultData)) {
116
+ return $resultData;
117
+ } else {
118
+ return false;
119
+ }
120
+
121
+ return false;
122
+
123
+ }
124
+
125
+ private function getaddressData($servicePoint) {
126
+ $data['pick_up_id'] = $servicePoint['pickupid'];
127
+ $data['company'] = implode(" ", array_filter(array($servicePoint['name1'], $servicePoint['name2']))); //joining the address data
128
+ $data['city'] = $servicePoint['city'];
129
+ $data['street'] = implode(" ", array_filter(array($servicePoint['address1'], $servicePoint['address2'])));
130
+ $data['zipcode'] = $servicePoint['zip'];
131
+ $data['shippingMethod'] = $servicePoint['carrier'];
132
+ $data['country'] = $servicePoint['country'];
133
+
134
+ $ser = serialize($data);
135
+ $data['servicePointId'] = $ser;
136
+ return $data;
137
+ }
138
+
139
+ }
app/code/community/Smartsend/Logistics/Model/Api/Validation.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Smartsend_Logistics
5
+ *
6
+ * This source file is subject to the GNU General Public License v3.0
7
+ * that is bundled with this package in the file license.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.gnu.org/licenses/gpl-3.0.html
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@smartsend.dk so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
+ * versions in the future. If you wish to customize the plugin for your
18
+ * needs please refer to http://www.smartsend.dk
19
+ *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/Api/Validation.php
21
+ * @category Smartsend
22
+ * @package Smartsend_Logistics
23
+ * @author Anders Bilfeldt
24
+ * @url www.smartsend.dk
25
+ */
26
+ class Smartsend_Logistics_Model_Api_Validation extends Mage_Core_Model_Abstract {
27
+
28
+ public function _verify($username, $licensekey) {
29
+
30
+ $ch = curl_init();
31
+
32
+ /* Script URL */
33
+ $url = 'http://smartsend-prod.apigee.net/v7/verify_user';
34
+
35
+ curl_setopt($ch, CURLOPT_URL, $url); //curl url
36
+ curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
37
+ //curl_setopt($ch, CURLOPT_HEADER, false);
38
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
39
+ 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
40
+ 'smartsendmail:'.$username,
41
+ 'smartsendlicence:'.$licensekey,
42
+ 'cmssystem:Magento',
43
+ 'cmsversion:'.Mage::getVersion(),
44
+ 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
45
+ )); //curl request header
46
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
47
+
48
+ $result = new StdClass();
49
+ $result->response = curl_exec($ch); //executing curl
50
+ $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
51
+ $result->meta = curl_getinfo($ch);
52
+ curl_close($ch); //curl closing
53
+
54
+ if($result->code == 200) {
55
+ return true;
56
+ } else {
57
+ return false;
58
+ }
59
+ }
60
+
61
+ }
app/code/community/Smartsend/Logistics/Model/Carrier/Bring.php CHANGED
@@ -26,49 +26,7 @@
26
  class Smartsend_Logistics_Model_Carrier_Bring extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
27
 
28
  protected $_code = 'smartsendbring';
29
-
30
- public function _post($street, $city, $postcode, $country) {
31
- $ch = curl_init(); //intitiate curl
32
-
33
- /* Script URL */
34
- //$url = 'http://private-2d17c-smartsend.apiary-mock.com/pickup/';
35
- $url = 'https://smartsend-prod.apigee.net/v7/pickup/';
36
-
37
- $carriers = 'bring';
38
-
39
- /* $_GET Parameters to Send */
40
- $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
41
-
42
- /* Update URL to container Query String of Paramaters */
43
- $url .= $carriers . '?' . http_build_query($params);
44
-
45
- curl_setopt($ch, CURLOPT_URL, $url); //curl url
46
- curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
47
- //curl_setopt($ch, CURLOPT_HEADER, false);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
49
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
50
- 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
51
- 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licencekey'),
52
- 'cmssystem:Magento',
53
- 'cmsversion:'.Mage::getVersion(),
54
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
55
- )); //curl request header
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
-
58
- $result = new StdClass(); //creating new class
59
- $result->response = curl_exec($ch); //executing the curl
60
- $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
61
- $result->meta = curl_getinfo($ch);
62
- $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting error from curl if any
63
-
64
- curl_close($ch); //closing the curl
65
-
66
- if ($curl_error) {
67
- throw new Exception('An error occurred while connecting to Chargify: ' . $curl_error);
68
- }
69
- return $result;
70
- }
71
-
72
  public function isTrackingAvailable() {
73
  return true;
74
  }
@@ -78,45 +36,62 @@ class Smartsend_Logistics_Model_Carrier_Bring extends Mage_Shipping_Model_Carrie
78
  }
79
 
80
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
81
- if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) { //checking that carrier is active or not
 
82
  return false;
83
  }
84
 
 
85
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
86
- $result = Mage::getModel('shipping/rate_result'); //shipping rate table for the bring carrier
87
- $bringShippingFee = $this->getBringShippingFee(); //getting bring shipping fees form table rate
88
- $carrier_label = 'Bring';
89
- $shipping_country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() //shipping address from the checkout quote
90
- ->getCountryId();
91
- $show = true;
92
- if ($show && $bringShippingFee!=NULL) { // This if condition is just to demonstrate how to return success and error in shipping methods
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  $carrier = $this->_code;
94
- $check_method = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country); //checking the shipping fee for the shipping method
95
-
96
- foreach ($check_method as $key => $value) {
97
-
98
- $title = '';
99
- foreach (unserialize($this->getConfigData('price')) as $val) {
100
-
101
- if ($val['methods'] == $key && $val['pickupshippingfee'] == $value) {
102
-
103
- $title = $val['method_name'];
104
- $method_code = Mage::getModel('logistics/shippingMethods')->getMethodName(); //getting the shipping method name
105
-
106
- $method_code = $method_code[$val['methods']];
107
- }
108
- }
109
-
110
-
111
- $method = Mage::getModel('shipping/rate_result_method'); //saving the shipping method
112
- $method->setCarrier($this->_code);
113
- $method->setMethod($method_code);
114
- $method->setCarrierTitle($this->getConfigData('title'));
115
- $method->setMethodTitle($title);
116
- $method->setPrice($value);
117
- $method->setCost($value);
118
- $result->append($method);
119
- }
120
  } else {
121
  $error = Mage::getModel('shipping/rate_result_error');
122
  $error->setCarrier($this->_code);
@@ -124,50 +99,16 @@ class Smartsend_Logistics_Model_Carrier_Bring extends Mage_Shipping_Model_Carrie
124
  $error->setErrorMessage($this->getConfigData('specificerrmsg'));
125
  $result->append($error);
126
  }
127
-
128
  return $result;
129
  }
130
 
 
 
 
 
 
131
  public function getAllowedMethods() {
132
- return array('bring' => $this->getConfigData('name')); //get name for the bring carrier
133
- }
134
-
135
- public function getBringShippingFee() {
136
- //$orderPrice = Mage::registry('ordsubtotal');
137
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); // get the total amount of the order
138
- $orderWeight = Mage::registry('ordweight'); // get the order weight
139
-
140
-
141
- if (Mage::getStoreConfig('carriers/smartsendbring/price') != "") {
142
- $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/smartsendbring/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
143
- }
144
-
145
- $rates = array();
146
- if ($pickupShippingRates) {
147
-
148
- foreach ($pickupShippingRates as $pickupShippingRate) {
149
- if ($pickupShippingRate['orderminprice'] <= $orderPrice && $pickupShippingRate['ordermaxprice'] >= $orderPrice && $pickupShippingRate['orderminweight'] <= $orderWeight && $pickupShippingRate['ordermaxweight'] >= $orderWeight) { //if weight and price is correct
150
- $rates[] = $pickupShippingRate['pickupshippingfee']; //add rate to array of rates
151
- }
152
- }
153
-
154
- $cheapestexpensive = Mage::getStoreConfig('carriers/smartsendbring/cheapestexpensive', Mage::app()->getStore()); //get the 'Cheapest or most expensive' setting from the admin system config
155
- if (!$cheapestexpensive) {
156
- $cheapestexpensive = 0; //default is the cheapest
157
- }
158
-
159
- if (!empty($rates)) { //if at least one rate matches the order
160
- if ($cheapestexpensive == 0) {
161
- return min($rates); //return min price
162
- } elseif ($cheapestexpensive == 1) {
163
- return max($rates); //return max price
164
- }
165
- } else {
166
- return false;
167
- }
168
- } else {
169
- return false;
170
- }
171
  }
172
 
173
  }
26
  class Smartsend_Logistics_Model_Carrier_Bring extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
27
 
28
  protected $_code = 'smartsendbring';
29
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  public function isTrackingAvailable() {
31
  return true;
32
  }
36
  }
37
 
38
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
39
+ // Check that the carrier is not deactive
40
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
41
  return false;
42
  }
43
 
44
+ // Carrier information
45
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
46
+ $result = Mage::getModel('shipping/rate_result'); // Table rate for shipping methods
47
+ $show = true; // Always true
48
+
49
+ // Shipping country
50
+ $shipping_country = $request->getDestCountryId();
51
+
52
+ // Order subtotal price (price without shipping) WITHOUT tax
53
+ // $order_subtotal = $request->getOrderSubtotal(); //NOT WORKING
54
+ $order_subtotal = $request->getPackageValueWithDiscount();
55
+ /*
56
+ // iterate over all item and add item price inc tax
57
+ $items = $request->getAllItems(); // Can include bundled items AND the subitems
58
+ $order_subtotal = 0;
59
+ foreach ($items as $item){
60
+ $order_subtotal += $item->getRowTotalInclTax();
61
+ }
62
+ */
63
+
64
+ // Order total weight
65
+ $order_weight = $request->getPackageWeight();
66
+
67
+ if ($show) { // This if condition is just to demonstrate how to return success and error in shipping methods$method = Mage::getModel('shipping/rate_result_method');
68
  $carrier = $this->_code;
69
+
70
+ // Chek the table rates for valid shipping method
71
+ $shipping_methods_array = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country, $order_subtotal, $order_weight);
72
+
73
+ if(is_array($shipping_methods_array)) {
74
+ foreach ($shipping_methods_array as $shipping_method_code => $shipping_method) {
75
+
76
+ // Create a shipping method
77
+ $method = Mage::getModel('shipping/rate_result_method');
78
+ $method->setCarrier($this->_code);
79
+ $method->setMethod($shipping_method_code);
80
+ $method->setCarrierTitle( $this->getConfigData('title') );
81
+ $method->setMethodTitle( $shipping_method['frontend_title'] );
82
+ $method->setPrice( $shipping_method['shippingfee'] );
83
+ $method->setCost( $shipping_method['shippingfee'] );
84
+
85
+ // Add shipping method to collection of valid methods
86
+ $result->append($method);
87
+ }
88
+ } else {
89
+ $error = Mage::getModel('shipping/rate_result_error');
90
+ $error->setCarrier($this->_code);
91
+ $error->setCarrierTitle($this->getConfigData('name'));
92
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
93
+ $result->append($error);
94
+ }
95
  } else {
96
  $error = Mage::getModel('shipping/rate_result_error');
97
  $error->setCarrier($this->_code);
99
  $error->setErrorMessage($this->getConfigData('specificerrmsg'));
100
  $result->append($error);
101
  }
 
102
  return $result;
103
  }
104
 
105
+ /**
106
+ * Method is required by the interface
107
+ *
108
+ * @return array of key-value pairs of all available methods
109
+ */
110
  public function getAllowedMethods() {
111
+ return Mage::getModel('logistics/shippingMethods')->getShippingMethodByCarrier( $this->_code );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  }
app/code/community/Smartsend/Logistics/Model/Carrier/Gls.php CHANGED
@@ -27,48 +27,6 @@ class Smartsend_Logistics_Model_Carrier_Gls extends Mage_Shipping_Model_Carrier_
27
 
28
  protected $_code = 'smartsendgls';
29
 
30
- public function _post($street, $city, $postcode, $country) {
31
- $ch = curl_init();
32
-
33
- /* Script URL */
34
- //$url = 'http://private-2d17c-smartsend.apiary-mock.com/pickup/';
35
- $url = 'https://smartsend-prod.apigee.net/v7/pickup/';
36
-
37
- $carriers = 'gls';
38
-
39
- /* $_GET Parameters to Send */
40
- $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
41
-
42
- /* Update URL to container Query String of Paramaters */
43
- $url .= $carriers . '?' . http_build_query($params);
44
-
45
- curl_setopt($ch, CURLOPT_URL, $url); //curl url
46
- curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
47
- //curl_setopt($ch, CURLOPT_HEADER, false);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
49
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
50
- 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
51
- 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licencekey'),
52
- 'cmssystem:Magento',
53
- 'cmsversion:'.Mage::getVersion(),
54
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
55
- )); //curl request header
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
-
58
- $result = new StdClass(); //declare new class
59
- $result->response = curl_exec($ch); //executing curl
60
- $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
61
- $result->meta = curl_getinfo($ch);
62
- $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting curl error if their are any
63
-
64
- curl_close($ch); //closing curl
65
-
66
- if ($curl_error) {
67
- throw new Exception('An error occurred while connecting to Chargify: ' . $curl_error); //showing error
68
- }
69
- return $result;
70
- }
71
-
72
  public function isTrackingAvailable() {
73
  return true;
74
  }
@@ -78,43 +36,62 @@ class Smartsend_Logistics_Model_Carrier_Gls extends Mage_Shipping_Model_Carrier_
78
  }
79
 
80
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
81
- if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) { //checking if carrier is active or not
 
82
  return false;
83
  }
84
 
 
85
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
86
- $result = Mage::getModel('shipping/rate_result'); //shipping rate price model
87
- $glsShippingFee = $this->getGlsShippingFee(); //getting gls shipping prices
88
- $carrier_label = 'Gls';
89
- $shipping_country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() ///get shipping address from the checkout quote
90
- ->getCountryId();
91
- $show = true;
92
- if ($show && $glsShippingFee!=NULL) { // This if condition is just to demonstrate how to return success and error in shipping methods
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  $carrier = $this->_code;
94
- $check_method = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country); //checking the shipping price for the carrier gls
95
-
96
- foreach ($check_method as $key => $value) {
97
-
98
- $title = '';
99
- foreach (unserialize($this->getConfigData('price')) as $val) {
100
-
101
- if ($val['methods'] == $key && $val['pickupshippingfee'] == $value) {
102
- $title = $val['method_name'];
103
- $method_code = Mage::getModel('logistics/shippingMethods')->getMethodName(); //getting the shipping method name
104
-
105
- $method_code = $method_code[$val['methods']];
106
- }
107
- }
108
-
109
- $method = Mage::getModel('shipping/rate_result_method'); //saving the shipping method
110
- $method->setCarrier($this->_code);
111
- $method->setMethod($method_code);
112
- $method->setCarrierTitle($this->getConfigData('title'));
113
- $method->setMethodTitle($title);
114
- $method->setPrice($value);
115
- $method->setCost($value);
116
- $result->append($method);
117
- }
 
 
118
  } else {
119
  $error = Mage::getModel('shipping/rate_result_error');
120
  $error->setCarrier($this->_code);
@@ -125,45 +102,13 @@ class Smartsend_Logistics_Model_Carrier_Gls extends Mage_Shipping_Model_Carrier_
125
  return $result;
126
  }
127
 
 
 
 
 
 
128
  public function getAllowedMethods() {
129
- return array('gls' => $this->getConfigData('name'));
130
- }
131
-
132
- public function getGlsShippingFee() {
133
- //$orderPrice = Mage::registry('ordsubtotal') + Mage::registry('ordtaxtotal'); //adding the tax amount with the order subtotal
134
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); // get the total amount of the order
135
- $orderWeight = Mage::registry('ordweight'); //getting the order weight
136
-
137
- if (Mage::getStoreConfig('carriers/smartsendgls/price') != "") { //checking the shipping price
138
- $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/smartsendgls/price', Mage::app()->getStore()));
139
- }
140
-
141
- $rates = array();
142
- if ($pickupShippingRates) {
143
-
144
- foreach ($pickupShippingRates as $pickupShippingRate) {
145
- if ($pickupShippingRate['orderminprice'] <= $orderPrice && $pickupShippingRate['ordermaxprice'] >= $orderPrice && $pickupShippingRate['orderminweight'] <= $orderWeight && $pickupShippingRate['ordermaxweight'] >= $orderWeight) { //if weight and price is correct
146
- $rates[] = $pickupShippingRate['pickupshippingfee']; //add rate to array of rates
147
- }
148
- }
149
-
150
- $cheapestexpensive = Mage::getStoreConfig('carriers/smartsendgls/cheapestexpensive', Mage::app()->getStore()); //get the 'Cheapest or most expensive' setting from the admin system config
151
- if (!$cheapestexpensive) {
152
- $cheapestexpensive = 0; //default is the cheapest
153
- }
154
-
155
- if (!empty($rates)) { //if at least one rate matches the order
156
- if ($cheapestexpensive == 0) {
157
- return min($rates); //return min price
158
- } elseif ($cheapestexpensive == 1) {
159
- return max($rates); //return max price
160
- }
161
- } else {
162
- return false;
163
- }
164
- } else {
165
- return false;
166
- }
167
  }
168
 
169
  }
27
 
28
  protected $_code = 'smartsendgls';
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  public function isTrackingAvailable() {
31
  return true;
32
  }
36
  }
37
 
38
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
39
+ // Check that the carrier is not deactive
40
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
41
  return false;
42
  }
43
 
44
+ // Carrier information
45
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
46
+ $result = Mage::getModel('shipping/rate_result'); // Table rate for shipping methods
47
+ $show = true; // Always true
48
+
49
+ // Shipping country
50
+ $shipping_country = $request->getDestCountryId();
51
+
52
+ // Order subtotal price (price without shipping) WITHOUT tax
53
+ // $order_subtotal = $request->getOrderSubtotal(); //NOT WORKING
54
+ $order_subtotal = $request->getPackageValueWithDiscount();
55
+ /*
56
+ // iterate over all item and add item price inc tax
57
+ $items = $request->getAllItems(); // Can include bundled items AND the subitems
58
+ $order_subtotal = 0;
59
+ foreach ($items as $item){
60
+ $order_subtotal += $item->getRowTotalInclTax();
61
+ }
62
+ */
63
+
64
+ // Order total weight
65
+ $order_weight = $request->getPackageWeight();
66
+
67
+ if ($show) { // This if condition is just to demonstrate how to return success and error in shipping methods$method = Mage::getModel('shipping/rate_result_method');
68
  $carrier = $this->_code;
69
+
70
+ // Chek the table rates for valid shipping method
71
+ $shipping_methods_array = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country, $order_subtotal, $order_weight);
72
+
73
+ if(is_array($shipping_methods_array)) {
74
+ foreach ($shipping_methods_array as $shipping_method_code => $shipping_method) {
75
+
76
+ // Create a shipping method
77
+ $method = Mage::getModel('shipping/rate_result_method');
78
+ $method->setCarrier($this->_code);
79
+ $method->setMethod($shipping_method_code);
80
+ $method->setCarrierTitle( $this->getConfigData('title') );
81
+ $method->setMethodTitle( $shipping_method['frontend_title'] );
82
+ $method->setPrice( $shipping_method['shippingfee'] );
83
+ $method->setCost( $shipping_method['shippingfee'] );
84
+
85
+ // Add shipping method to collection of valid methods
86
+ $result->append($method);
87
+ }
88
+ } else {
89
+ $error = Mage::getModel('shipping/rate_result_error');
90
+ $error->setCarrier($this->_code);
91
+ $error->setCarrierTitle($this->getConfigData('name'));
92
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
93
+ $result->append($error);
94
+ }
95
  } else {
96
  $error = Mage::getModel('shipping/rate_result_error');
97
  $error->setCarrier($this->_code);
102
  return $result;
103
  }
104
 
105
+ /**
106
+ * Method is required by the interface
107
+ *
108
+ * @return array of key-value pairs of all available methods
109
+ */
110
  public function getAllowedMethods() {
111
+ return Mage::getModel('logistics/shippingMethods')->getShippingMethodByCarrier( $this->_code );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  }
app/code/community/Smartsend/Logistics/Model/Carrier/Pickup.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Smartsend_Logistics
5
- *
6
- * This source file is subject to the GNU General Public License v3.0
7
- * that is bundled with this package in the file license.txt.
8
- * It is also available through the world-wide-web at this URL:
9
- * http://www.gnu.org/licenses/gpl-3.0.html
10
- * If you did not receive a copy of the license and are unable to
11
- * obtain it through the world-wide-web, please send an email
12
- * to license@smartsend.dk so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
- * versions in the future. If you wish to customize the plugin for your
18
- * needs please refer to http://www.smartsend.dk
19
- *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Carrier/Pickup.php
21
- * @category Smartsend
22
- * @package Smartsend_Logistics
23
- * @author Anders Bilfeldt
24
- * @url www.smartsend.dk
25
- */
26
- class Smartsend_Logistics_Model_Carrier_Pickup extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
27
-
28
- protected $_code = 'smartsendpickup';
29
-
30
- public function _post($street, $city, $postcode, $country) {
31
-
32
- $ch = curl_init();
33
-
34
- /* Script URL */
35
- $url = 'https://smartsend-prod.apigee.net/v7/pickup/';
36
-
37
- $carriers = str_replace(",", "-", Mage::getStoreConfig('carriers/smartsendpickup/methods'));
38
-
39
- /* $_GET Parameters to Send */
40
- $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
41
-
42
- /* Update URL to container Query String of Paramaters */
43
- $url .= $carriers . '?' . http_build_query($params);
44
-
45
- curl_setopt($ch, CURLOPT_URL, $url); //curl url
46
- curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
47
- //curl_setopt($ch, CURLOPT_HEADER, false);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
49
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
50
- 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
51
- 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licencekey'),
52
- 'cmssystem:Magento',
53
- 'cmsversion:'.Mage::getVersion(),
54
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
55
- )); //curl request header
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
-
58
- $result = new StdClass();
59
- $result->response = curl_exec($ch); //executing curl
60
- $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
61
- $result->meta = curl_getinfo($ch);
62
- $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting curl error if any
63
-
64
- curl_close($ch); //curl closing
65
-
66
- if ($curl_error) {
67
- throw new Exception('An error occurred while connecting to Chargify: ' . $curl_error);
68
- }
69
- return $result;
70
- }
71
-
72
- /*
73
- public function isTrackingAvailable() {
74
- return true;
75
- }
76
- */
77
-
78
- public function getFormBlock() {
79
- return 'logistics/pickup';
80
- }
81
-
82
- public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
83
- if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) { //checking if carrier is active or not
84
- return false;
85
- }
86
-
87
- $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
88
- $result = Mage::getModel('shipping/rate_result'); //shipping rate table for the pickup carrier
89
- $show = true;
90
- $pickupShippingFee = $this->getPickupShippingFee(); //getting pickup shipping fees form table rate
91
-
92
- $shipping_country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() //getting shipping address form the checkout quote
93
- ->getCountryId();
94
- if ($show && $pickupShippingFee!=NULL) { // This if condition is just to demonstrate how to return success and error in shipping methods
95
- $carrier = $this->_code;
96
- $check_method = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country); //check shipping fee rates form the table rates
97
-
98
- foreach ($check_method as $key => $value) {
99
-
100
- $method = Mage::getModel('shipping/rate_result_method'); //saving shipping method
101
- $method->setCarrier($this->_code);
102
- $method->setMethod('pickup');
103
- $method->setCarrierTitle($this->getConfigData('title'));
104
- $method->setMethodTitle($this->getConfigData('name'));
105
- $method->setPrice($value);
106
- $method->setCost($value);
107
- $result->append($method);
108
- }
109
- } else {
110
- $error = Mage::getModel('shipping/rate_result_error');
111
- $error->setCarrier($this->_code);
112
- $error->setCarrierTitle($this->getConfigData('name'));
113
- $error->setErrorMessage($this->getConfigData('specificerrmsg'));
114
- $result->append($error);
115
- }
116
- return $result;
117
- }
118
-
119
- public function getAllowedMethods() {
120
- return array('pickup' => $this->getConfigData('name'));
121
- }
122
-
123
- public function getPickupShippingFee() {
124
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); //getting grand total form the checkout session quote
125
- $orderWeight = Mage::registry('ordweight'); //getting order weight
126
-
127
- if (Mage::getStoreConfig('carriers/smartsendpickup/price') != "") {
128
- $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/smartsendpickup/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
129
- }
130
-
131
- $rates = array();
132
- if ($pickupShippingRates) {
133
-
134
- foreach ($pickupShippingRates as $pickupShippingRate) {
135
- if ($pickupShippingRate['orderminprice'] <= $orderPrice && $pickupShippingRate['ordermaxprice'] >= $orderPrice
136
- && $pickupShippingRate['orderminweight'] <= $orderWeight && $pickupShippingRate['ordermaxweight'] >= $orderWeight) { //if weight and price is correct
137
- $rates[] = $pickupShippingRate['pickupshippingfee']; //add rate to array of rates
138
- }
139
- }
140
-
141
- $cheapestexpensive = Mage::getStoreConfig('carriers/smartsendpickup/cheapestexpensive', Mage::app()->getStore()); //get the 'Cheapest or most expensive' setting from the admin system config
142
- if (!$cheapestexpensive) {
143
- $cheapestexpensive = 0; //default is the cheapest
144
- }
145
-
146
- if (!empty($rates)) { //if at least one rate matches the order
147
- if ($cheapestexpensive == 0) {
148
- return min($rates); //return min price
149
- } elseif ($cheapestexpensive == 1) {
150
- return max($rates); //return max price
151
- }
152
- } else {
153
- return false;
154
- }
155
- } else {
156
- return false;
157
- }
158
- }
159
-
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Smartsend/Logistics/Model/Carrier/Postdanmark.php CHANGED
@@ -27,48 +27,6 @@ class Smartsend_Logistics_Model_Carrier_Postdanmark extends Mage_Shipping_Model_
27
 
28
  protected $_code = 'smartsendpostdanmark';
29
 
30
- public function _post($street, $city, $postcode, $country) {
31
- $ch = curl_init();
32
-
33
- /* Script URL */
34
- //$url = 'http://private-2d17c-smartsend.apiary-mock.com/pickup/';
35
- $url = 'https://smartsend-prod.apigee.net/v7/pickup/';
36
-
37
- $carriers = 'postdanmark';
38
-
39
- /* $_GET Parameters to Send */
40
- $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
41
-
42
- /* Update URL to container Query String of Paramaters */
43
- $url .= $carriers . '?' . http_build_query($params);
44
-
45
- curl_setopt($ch, CURLOPT_URL, $url); // curl url
46
- curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
47
- //curl_setopt($ch, CURLOPT_HEADER, false);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
49
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
50
- 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
51
- 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licencekey'),
52
- 'cmssystem:Magento',
53
- 'cmsversion:'.Mage::getVersion(),
54
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
55
- )); //curl request header
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
-
58
- $result = new StdClass();
59
- $result->response = curl_exec($ch); //execute curl
60
- $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
61
- $result->meta = curl_getinfo($ch);
62
- $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); // getting error if any
63
-
64
- curl_close($ch); //closing curl
65
-
66
- if ($curl_error) {
67
- throw new Exception('An error occurred while connecting to Chargify: ' . $curl_error);
68
- }
69
- return $result;
70
- }
71
-
72
  public function isTrackingAvailable() {
73
  return true;
74
  }
@@ -78,45 +36,62 @@ class Smartsend_Logistics_Model_Carrier_Postdanmark extends Mage_Shipping_Model_
78
  }
79
 
80
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
81
- if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) { //checking if carrier is active or not
 
82
  return false;
83
  }
84
 
85
-
86
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
87
- $result = Mage::getModel('shipping/rate_result'); //table rate for shipping methods
88
- $postdanmarkShippingFee = $this->getPostdanmarkShippingFee(); //getting shipping fee for the carrier
89
- $show = true;
90
- $carrier_label = 'Postdanmark';
91
- $shipping_country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() //getting shipping address from the checkout quote
92
- ->getCountryId();
93
- if ($show && $postdanmarkShippingFee!=NULL) { // This if condition is just to demonstrate how to return success and error in shipping methods$method = Mage::getModel('shipping/rate_result_method');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  $carrier = $this->_code;
95
- $check_method = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country); //cheking the table rates for the shipping method
96
-
97
- foreach ($check_method as $key => $value) {
98
-
99
- $title = '';
100
- foreach (unserialize($this->getConfigData('price')) as $val) {
101
-
102
- if ($val['methods'] == $key && $val['pickupshippingfee'] == $value) {
103
- $title = $val['method_name'];
104
- $method_code = Mage::getModel('logistics/shippingMethods')->getMethodName(); //getting the shipping method name
105
-
106
- $method_code = $method_code[$val['methods']];
107
- }
108
- }
109
-
110
-
111
- $method = Mage::getModel('shipping/rate_result_method'); //saving the shipping method
112
- $method->setCarrier($this->_code);
113
- $method->setMethod($method_code);
114
- $method->setCarrierTitle($this->getConfigData('title'));
115
- $method->setMethodTitle($title);
116
- $method->setPrice($value);
117
- $method->setCost($value);
118
- $result->append($method);
119
- }
 
120
  } else {
121
  $error = Mage::getModel('shipping/rate_result_error');
122
  $error->setCarrier($this->_code);
@@ -127,45 +102,13 @@ class Smartsend_Logistics_Model_Carrier_Postdanmark extends Mage_Shipping_Model_
127
  return $result;
128
  }
129
 
 
 
 
 
 
130
  public function getAllowedMethods() {
131
- return array('postdanmark' => $this->getConfigData('name'));
132
- }
133
-
134
- public function getPostdanmarkShippingFee() {
135
- //$orderPrice = Mage::registry('ordsubtotal');
136
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); // get the total amount of the order
137
- $orderWeight = Mage::registry('ordweight'); // get the order weight
138
-
139
- if (Mage::getStoreConfig('carriers/smartsendpostdanmark/price') != "") {
140
- $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/smartsendpostdanmark/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
141
- }
142
-
143
- $rates = array();
144
- if ($pickupShippingRates) {
145
-
146
- foreach ($pickupShippingRates as $pickupShippingRate) {
147
- if ($pickupShippingRate['orderminprice'] <= $orderPrice && $pickupShippingRate['ordermaxprice'] >= $orderPrice && $pickupShippingRate['orderminweight'] <= $orderWeight && $pickupShippingRate['ordermaxweight'] >= $orderWeight) { //if weight and price is correct
148
- $rates[] = $pickupShippingRate['pickupshippingfee']; //add rate to array of rates
149
- }
150
- }
151
-
152
- $cheapestexpensive = Mage::getStoreConfig('carriers/smartsendpostdanmark/cheapestexpensive', Mage::app()->getStore()); //get the 'Cheapest or most expensive' setting from the admin system config
153
- if (!$cheapestexpensive) {
154
- $cheapestexpensive = 0; //default is the cheapest
155
- }
156
-
157
- if (!empty($rates)) { //if at least one rate matches the order
158
- if ($cheapestexpensive == 0) {
159
- return min($rates); //return min price
160
- } elseif ($cheapestexpensive == 1) {
161
- return max($rates); //return max price
162
- }
163
- } else {
164
- return false;
165
- }
166
- } else {
167
- return false;
168
- }
169
  }
170
 
171
  }
27
 
28
  protected $_code = 'smartsendpostdanmark';
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  public function isTrackingAvailable() {
31
  return true;
32
  }
36
  }
37
 
38
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
39
+ // Check that the carrier is not deactive
40
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
41
  return false;
42
  }
43
 
44
+ // Carrier information
45
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
46
+ $result = Mage::getModel('shipping/rate_result'); // Table rate for shipping methods
47
+ $show = true; // Always true
48
+
49
+ // Shipping country
50
+ $shipping_country = $request->getDestCountryId();
51
+
52
+ // Order subtotal price (price without shipping) WITHOUT tax
53
+ // $order_subtotal = $request->getOrderSubtotal(); //NOT WORKING
54
+ $order_subtotal = $request->getPackageValueWithDiscount();
55
+ /*
56
+ // iterate over all item and add item price inc tax
57
+ $items = $request->getAllItems(); // Can include bundled items AND the subitems
58
+ $order_subtotal = 0;
59
+ foreach ($items as $item){
60
+ $order_subtotal += $item->getRowTotalInclTax();
61
+ }
62
+ */
63
+
64
+ // Order total weight
65
+ $order_weight = $request->getPackageWeight();
66
+
67
+ if ($show) { // This if condition is just to demonstrate how to return success and error in shipping methods$method = Mage::getModel('shipping/rate_result_method');
68
  $carrier = $this->_code;
69
+
70
+ // Chek the table rates for valid shipping method
71
+ $shipping_methods_array = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country, $order_subtotal, $order_weight);
72
+
73
+ if(is_array($shipping_methods_array)) {
74
+ foreach ($shipping_methods_array as $shipping_method_code => $shipping_method) {
75
+
76
+ // Create a shipping method
77
+ $method = Mage::getModel('shipping/rate_result_method');
78
+ $method->setCarrier($this->_code);
79
+ $method->setMethod($shipping_method_code);
80
+ $method->setCarrierTitle( $this->getConfigData('title') );
81
+ $method->setMethodTitle( $shipping_method['frontend_title'] );
82
+ $method->setPrice( $shipping_method['shippingfee'] );
83
+ $method->setCost( $shipping_method['shippingfee'] );
84
+
85
+ // Add shipping method to collection of valid methods
86
+ $result->append($method);
87
+ }
88
+ } else {
89
+ $error = Mage::getModel('shipping/rate_result_error');
90
+ $error->setCarrier($this->_code);
91
+ $error->setCarrierTitle($this->getConfigData('name'));
92
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
93
+ $result->append($error);
94
+ }
95
  } else {
96
  $error = Mage::getModel('shipping/rate_result_error');
97
  $error->setCarrier($this->_code);
102
  return $result;
103
  }
104
 
105
+ /**
106
+ * Method is required by the interface
107
+ *
108
+ * @return array of key-value pairs of all available methods
109
+ */
110
  public function getAllowedMethods() {
111
+ return Mage::getModel('logistics/shippingMethods')->getShippingMethodByCarrier( $this->_code );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  }
app/code/community/Smartsend/Logistics/Model/Carrier/Posten.php CHANGED
@@ -27,48 +27,6 @@ class Smartsend_Logistics_Model_Carrier_Posten extends Mage_Shipping_Model_Carri
27
 
28
  protected $_code = 'smartsendposten';
29
 
30
- public function _post($street, $city, $postcode, $country) {
31
- $ch = curl_init(); //initiate curl
32
-
33
- /* Script URL */
34
- //$url = 'http://private-2d17c-smartsend.apiary-mock.com/pickup/';
35
- $url = 'https://smartsend-prod.apigee.net/v7/pickup/';
36
-
37
- $carriers = 'posten';
38
-
39
- /* $_GET Parameters to Send */
40
- $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
41
-
42
- /* Update URL to container Query String of Paramaters */
43
- $url .= $carriers . '?' . http_build_query($params);
44
-
45
- curl_setopt($ch, CURLOPT_URL, $url); //curl url
46
- curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
47
- //curl_setopt($ch, CURLOPT_HEADER, false);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
49
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
50
- 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
51
- 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licencekey'),
52
- 'cmssystem:Magento',
53
- 'cmsversion:'.Mage::getVersion(),
54
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
55
- )); //curl request header
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
-
58
- $result = new StdClass();
59
- $result->response = curl_exec($ch); //execute curl
60
- $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
61
- $result->meta = curl_getinfo($ch);
62
- $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting error from curl if any
63
-
64
- curl_close($ch); //close curl
65
-
66
- if ($curl_error) {
67
- throw new Exception('An error occurred while connecting to Chargify: ' . $curl_error);
68
- }
69
- return $result;
70
- }
71
-
72
  public function isTrackingAvailable() {
73
  return true;
74
  }
@@ -78,45 +36,62 @@ class Smartsend_Logistics_Model_Carrier_Posten extends Mage_Shipping_Model_Carri
78
  }
79
 
80
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
81
- if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) { //checking carrier is active or not
 
82
  return false;
83
  }
84
 
85
-
86
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
87
- $result = Mage::getModel('shipping/rate_result'); //shipping rate table for the carrier
88
- $postenShippingFee = $this->getPostenShippingFee(); //getting shipping fees form table rate
89
- $show = true;
90
- $carrier_label = 'posten';
91
- $shipping_country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() //shipping address from the checkout quote
92
- ->getCountryId();
93
- if ($show && $postenShippingFee!=NULL) { // This if condition is just to demonstrate how to return success and error in shipping methods$method = Mage::getModel('shipping/rate_result_method');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  $carrier = $this->_code;
95
- $check_method = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country); //checking the shipping method rates
96
-
97
- foreach ($check_method as $key => $value) {
98
-
99
- $title = '';
100
- foreach (unserialize($this->getConfigData('price')) as $val) {
101
-
102
- if ($val['methods'] == $key && $val['pickupshippingfee'] == $value) {
103
- $title = $val['method_name'];
104
- $method_code = Mage::getModel('logistics/shippingMethods')->getMethodName(); //getting the shipping method name
105
-
106
- $method_code = $method_code[$val['methods']];
107
- }
108
- }
109
-
110
-
111
- $method = Mage::getModel('shipping/rate_result_method'); //saving the shipping method
112
- $method->setCarrier($this->_code);
113
- $method->setMethod($method_code);
114
- $method->setCarrierTitle($this->getConfigData('title'));
115
- $method->setMethodTitle($title);
116
- $method->setPrice($value);
117
- $method->setCost($value);
118
- $result->append($method);
119
- }
 
120
  } else {
121
  $error = Mage::getModel('shipping/rate_result_error');
122
  $error->setCarrier($this->_code);
@@ -127,45 +102,13 @@ class Smartsend_Logistics_Model_Carrier_Posten extends Mage_Shipping_Model_Carri
127
  return $result;
128
  }
129
 
 
 
 
 
 
130
  public function getAllowedMethods() {
131
- return array('posten' => $this->getConfigData('name'));
132
- }
133
-
134
- public function getPostenShippingFee() {
135
- //$orderPrice = Mage::registry('ordsubtotal');
136
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); // get the total amount of the order
137
- $orderWeight = Mage::registry('ordweight'); // get the order weight
138
-
139
- if (Mage::getStoreConfig('carriers/smartsendposten/price') != "") {
140
- $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/smartsendposten/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
141
- }
142
-
143
- $rates = array();
144
- if ($pickupShippingRates) {
145
-
146
- foreach ($pickupShippingRates as $pickupShippingRate) {
147
- if ($pickupShippingRate['orderminprice'] <= $orderPrice && $pickupShippingRate['ordermaxprice'] >= $orderPrice && $pickupShippingRate['orderminweight'] <= $orderWeight && $pickupShippingRate['ordermaxweight'] >= $orderWeight) { //if weight and price is correct
148
- $rates[] = $pickupShippingRate['pickupshippingfee']; //add rate to array of rates
149
- }
150
- }
151
-
152
- $cheapestexpensive = Mage::getStoreConfig('carriers/smartsendposten/cheapestexpensive', Mage::app()->getStore()); //get the 'Cheapest or most expensive' setting from the admin system config
153
- if (!$cheapestexpensive) {
154
- $cheapestexpensive = 0; //default is the cheapest
155
- }
156
-
157
- if (!empty($rates)) { //if at least one rate matches the order
158
- if ($cheapestexpensive == 0) {
159
- return min($rates); //return min price
160
- } elseif ($cheapestexpensive == 1) {
161
- return max($rates); //return max price
162
- }
163
- } else {
164
- return false;
165
- }
166
- } else {
167
- return false;
168
- }
169
  }
170
 
171
  }
27
 
28
  protected $_code = 'smartsendposten';
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  public function isTrackingAvailable() {
31
  return true;
32
  }
36
  }
37
 
38
  public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
39
+ // Check that the carrier is not deactive
40
+ if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) {
41
  return false;
42
  }
43
 
44
+ // Carrier information
45
  $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
46
+ $result = Mage::getModel('shipping/rate_result'); // Table rate for shipping methods
47
+ $show = true; // Always true
48
+
49
+ // Shipping country
50
+ $shipping_country = $request->getDestCountryId();
51
+
52
+ // Order subtotal price (price without shipping) WITHOUT tax
53
+ // $order_subtotal = $request->getOrderSubtotal(); //NOT WORKING
54
+ $order_subtotal = $request->getPackageValueWithDiscount();
55
+ /*
56
+ // iterate over all item and add item price inc tax
57
+ $items = $request->getAllItems(); // Can include bundled items AND the subitems
58
+ $order_subtotal = 0;
59
+ foreach ($items as $item){
60
+ $order_subtotal += $item->getRowTotalInclTax();
61
+ }
62
+ */
63
+
64
+ // Order total weight
65
+ $order_weight = $request->getPackageWeight();
66
+
67
+ if ($show) { // This if condition is just to demonstrate how to return success and error in shipping methods$method = Mage::getModel('shipping/rate_result_method');
68
  $carrier = $this->_code;
69
+
70
+ // Chek the table rates for valid shipping method
71
+ $shipping_methods_array = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country, $order_subtotal, $order_weight);
72
+
73
+ if(is_array($shipping_methods_array)) {
74
+ foreach ($shipping_methods_array as $shipping_method_code => $shipping_method) {
75
+
76
+ // Create a shipping method
77
+ $method = Mage::getModel('shipping/rate_result_method');
78
+ $method->setCarrier($this->_code);
79
+ $method->setMethod($shipping_method_code);
80
+ $method->setCarrierTitle( $this->getConfigData('title') );
81
+ $method->setMethodTitle( $shipping_method['frontend_title'] );
82
+ $method->setPrice( $shipping_method['shippingfee'] );
83
+ $method->setCost( $shipping_method['shippingfee'] );
84
+
85
+ // Add shipping method to collection of valid methods
86
+ $result->append($method);
87
+ }
88
+ } else {
89
+ $error = Mage::getModel('shipping/rate_result_error');
90
+ $error->setCarrier($this->_code);
91
+ $error->setCarrierTitle($this->getConfigData('name'));
92
+ $error->setErrorMessage($this->getConfigData('specificerrmsg'));
93
+ $result->append($error);
94
+ }
95
  } else {
96
  $error = Mage::getModel('shipping/rate_result_error');
97
  $error->setCarrier($this->_code);
102
  return $result;
103
  }
104
 
105
+ /**
106
+ * Method is required by the interface
107
+ *
108
+ * @return array of key-value pairs of all available methods
109
+ */
110
  public function getAllowedMethods() {
111
+ return Mage::getModel('logistics/shippingMethods')->getShippingMethodByCarrier( $this->_code );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
 
114
  }
app/code/community/Smartsend/Logistics/Model/Carrier/Swipbox.php DELETED
@@ -1,170 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Smartsend_Logistics
5
- *
6
- * This source file is subject to the GNU General Public License v3.0
7
- * that is bundled with this package in the file license.txt.
8
- * It is also available through the world-wide-web at this URL:
9
- * http://www.gnu.org/licenses/gpl-3.0.html
10
- * If you did not receive a copy of the license and are unable to
11
- * obtain it through the world-wide-web, please send an email
12
- * to license@smartsend.dk so we can send you a copy immediately.
13
- *
14
- * DISCLAIMER
15
- *
16
- * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
- * versions in the future. If you wish to customize the plugin for your
18
- * needs please refer to http://www.smartsend.dk
19
- *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Carrier/Swipbox.php
21
- * @category Smartsend
22
- * @package Smartsend_Logistics
23
- * @author Anders Bilfeldt
24
- * @url www.smartsend.dk
25
- */
26
- class Smartsend_Logistics_Model_Carrier_Swipbox extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
27
-
28
- protected $_code = 'smartsendswipbox';
29
-
30
- public function _post($street, $city, $postcode, $country) {
31
- $ch = curl_init(); //initiate curl
32
-
33
- /* Script URL */
34
- //$url = 'http://private-2d17c-smartsend.apiary-mock.com/pickup/';
35
- $url = 'https://smartsend-prod.apigee.net/v7/pickup/';
36
-
37
- $carriers = 'swipbox';
38
-
39
- /* $_GET Parameters to Send */
40
- $params = array('country' => $country, 'zip' => $postcode, 'city' => $city, 'street' => $street);
41
-
42
- /* Update URL to container Query String of Paramaters */
43
- $url .= $carriers . '?' . http_build_query($params);
44
-
45
- curl_setopt($ch, CURLOPT_URL, $url); //curl url
46
- curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
47
- //curl_setopt($ch, CURLOPT_HEADER, false);
48
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
49
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
50
- 'smartsendmail:'.Mage::getStoreConfig('carriers/smartsend/username'),
51
- 'smartsendlicence:'.Mage::getStoreConfig('carriers/smartsend/licencekey'),
52
- 'cmssystem:Magento',
53
- 'cmsversion:'.Mage::getVersion(),
54
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version
55
- )); //curl request header
56
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
57
-
58
- $result = new StdClass();
59
- $result->response = curl_exec($ch); //exceute curl
60
- $result->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
61
- $result->meta = curl_getinfo($ch);
62
- $curl_error = ($result->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting error from curl if any
63
-
64
- curl_close($ch); //close curl
65
-
66
- if ($curl_error) {
67
- throw new Exception('An error occurred while connecting to Chargify: ' . $curl_error);
68
- }
69
- return $result;
70
- }
71
-
72
- public function isTrackingAvailable() {
73
- return true;
74
- }
75
-
76
- public function getFormBlock() {
77
- return 'logistics/swipbox';
78
- }
79
-
80
- public function collectRates(Mage_Shipping_Model_Rate_Request $request) {
81
- if (!Mage::getStoreConfig('carriers/' . $this->_code . '/active')) { //checking that carrier is active or not
82
- return false;
83
- }
84
-
85
- $handling = Mage::getStoreConfig('carriers/' . $this->_code . '/handling');
86
- $result = Mage::getModel('shipping/rate_result'); //shipping rate table for the carrier
87
- $swipboxShippingFee = $this->getSwipboxShippingFee(); //getting shipping fees form table rate
88
- $show = true;
89
- $carrier_label = 'Swipbox';
90
- $shipping_country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() //shipping address from the checkout quote
91
- ->getCountryId();
92
- if ($show && $swipboxShippingFee!=NULL) { // This if condition is just to demonstrate how to return success and error in shipping methods
93
- $carrier = $this->_code;
94
- $check_method = Mage::getModel('logistics/shippingMethods')->checkShippingFee($carrier, $shipping_country); //checking the shipping fee for the shipping method
95
-
96
- foreach ($check_method as $key => $value) {
97
- $title = '';
98
- foreach (unserialize($this->getConfigData('price')) as $val) {
99
-
100
- if ($val['methods'] == $key && $val['pickupshippingfee'] == $value) {
101
- $title = $val['method_name'];
102
-
103
- $method_code = Mage::getModel('logistics/shippingMethods')->getMethodName(); //getting the shipping method name
104
-
105
- $method_code = $method_code[$val['methods']];
106
- }
107
- }
108
-
109
-
110
- $method = Mage::getModel('shipping/rate_result_method'); //saving the shipping method
111
- $method->setCarrier($this->_code);
112
- $method->setMethod($method_code);
113
- $method->setCarrierTitle($this->getConfigData('title'));
114
- $method->setMethodTitle($title);
115
- $method->setPrice($value);
116
- $method->setCost($value);
117
- $result->append($method);
118
- }
119
- } else {
120
- $error = Mage::getModel('shipping/rate_result_error');
121
- $error->setCarrier($this->_code);
122
- $error->setCarrierTitle($this->getConfigData('name'));
123
- $error->setErrorMessage($this->getConfigData('specificerrmsg'));
124
- $result->append($error);
125
- }
126
- return $result;
127
- }
128
-
129
- public function getAllowedMethods() {
130
- return array('swipbox' => $this->getConfigData('name'));
131
- }
132
-
133
- public function getSwipboxShippingFee() {
134
- //$orderPrice = Mage::registry('ordsubtotal');
135
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); // get the total amount of the order
136
- $orderWeight = Mage::registry('ordweight'); // get the order weight
137
-
138
- if (Mage::getStoreConfig('carriers/smartsendswipbox/price') != "") {
139
- $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/smartsendswipbox/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
140
- }
141
-
142
- $rates = array();
143
- if ($pickupShippingRates) {
144
-
145
- foreach ($pickupShippingRates as $pickupShippingRate) {
146
- if ($pickupShippingRate['orderminprice'] <= $orderPrice && $pickupShippingRate['ordermaxprice'] >= $orderPrice && $pickupShippingRate['orderminweight'] <= $orderWeight && $pickupShippingRate['ordermaxweight'] >= $orderWeight) { //if weight and price is correct
147
- $rates[] = $pickupShippingRate['pickupshippingfee']; //add rate to array of rates
148
- }
149
- }
150
-
151
- $cheapestexpensive = Mage::getStoreConfig('carriers/smartsendswipbox/cheapestexpensive', Mage::app()->getStore()); //get the 'Cheapest or most expensive' setting from the admin system config
152
- if (!$cheapestexpensive) {
153
- $cheapestexpensive = 0; //default is the cheapest
154
- }
155
-
156
- if (!empty($rates)) { //if at least one rate matches the order
157
- if ($cheapestexpensive == 0) {
158
- return min($rates); //return min price
159
- } elseif ($cheapestexpensive == 1) {
160
- return max($rates); //return max price
161
- }
162
- } else {
163
- return false;
164
- }
165
- } else {
166
- return false;
167
- }
168
- }
169
-
170
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Smartsend/Logistics/Model/{Pickup.php → Flex.php} RENAMED
@@ -17,17 +17,16 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Pickup.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
- class Smartsend_Logistics_Model_Pickup extends Mage_Core_Model_Abstract {
27
 
28
  public function _construct() {
29
  parent::_construct();
30
- $this->_init('logistics/pickup');
31
  }
32
-
33
  }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/Flex.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
+ class Smartsend_Logistics_Model_Flex extends Mage_Core_Model_Abstract {
27
 
28
  public function _construct() {
29
  parent::_construct();
30
+ $this->_init('logistics/flex');
31
  }
 
32
  }
app/code/community/Smartsend/Logistics/Model/Label.php ADDED
@@ -0,0 +1,583 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Label class
5
+ *
6
+ * The label class is used to handle requests and responses from the Smart Send Logistics API
7
+ *
8
+ * @folder /app/code/community/Smartsend/Logistics/Model/Label.php
9
+ * @category Smart Send
10
+ * @package Smartsend_Logistics
11
+ * @class Smartsend_Logistics_Label
12
+ * @copyright Copyright (c) Smart Send ApS (http://www.smartsend.dk)
13
+ * @license http://smartsend.dk/license
14
+ * @version Release: 7.1.0
15
+ * @author Smart Send ApS
16
+ * @link http://smartsend.dk/download/generec
17
+ * @since Class available since Release 7.1.0
18
+ */
19
+
20
+ /*
21
+
22
+ $label = new Smartsend_Logistics_Label($single=false);
23
+ $label->setRequestType('bulk');
24
+ foreach($orders as $order) {
25
+ try{
26
+ $label->addOrderToRequest($order);
27
+ }
28
+ //catch exception
29
+ catch(Exception $e) {
30
+ $this->addErrorMessage( $e->getMessage() );
31
+ }
32
+ }
33
+
34
+ if( $label->hasRequestOrders() ) {
35
+ $label->sendRequest();
36
+
37
+ if( $label->getResponseError() ) {
38
+ $label->addErrorMessage( $label->getResponseError() );
39
+ } else {
40
+ $label->handleApiReponse();
41
+ }
42
+ }
43
+
44
+ $label->showResult();
45
+
46
+ */
47
+
48
+ class Smartsend_Logistics_Model_Label extends Mage_Core_Model_Abstract {
49
+
50
+ private $_test = false;
51
+
52
+ protected $request=array();
53
+ protected $request_type;
54
+ protected $response;
55
+ protected $response_type;
56
+ protected $response_code;
57
+
58
+ protected $message_string_array;
59
+
60
+ protected $messages=array();
61
+
62
+ protected $show_order_succes = true;
63
+
64
+ public function __construct() {
65
+ }
66
+
67
+ /**
68
+ * This method returns the message string based on message number
69
+ *
70
+ * @return string
71
+ */
72
+ protected function getMessageString($message_number) {
73
+ if(isset($this->message_string_array[$message_number])) {
74
+ return $this->message_string_array[$message_number];
75
+ } else {
76
+ return '';
77
+ }
78
+ }
79
+
80
+ /**
81
+ * This method returns the request to be used in the API call
82
+ *
83
+ * @return string
84
+ */
85
+ private function getTest() {
86
+ return $this->_test;
87
+ }
88
+
89
+ /**
90
+ * This method returns the messages that has been created
91
+ *
92
+ * @return array
93
+ */
94
+ protected function getMessages() {
95
+ return $this->messages;
96
+ }
97
+
98
+ /**
99
+ * This method returns the request to be used in the API call
100
+ *
101
+ * @return array
102
+ */
103
+ protected function getRequest() {
104
+ return $this->request;
105
+ }
106
+
107
+ /**
108
+ * This method returns the JSON encoded request to be used in the API call
109
+ *
110
+ * @return string
111
+ */
112
+ protected function getRequestJsonEncoded() {
113
+ return json_encode($this->request);
114
+ }
115
+
116
+ /**
117
+ * This method returns the request type to be used in the API call
118
+ *
119
+ * @return array
120
+ */
121
+ protected function getRequestType() {
122
+ return $this->request_type;
123
+ }
124
+
125
+ /**
126
+ * This method returns the response from the API call decoded from JSON/XML
127
+ *
128
+ * @return string
129
+ */
130
+ protected function getResponse() {
131
+ return $this->response;
132
+ }
133
+
134
+ /**
135
+ * This method returns the JSON decoded response from the API call
136
+ *
137
+ * @return string
138
+ */
139
+ protected function getResponseJsonDecoded() {
140
+ if(strpos($this->response_type,'json') !== false) {
141
+ return $json = json_decode( $this->getResponse(),true );
142
+ }
143
+ }
144
+
145
+ /**
146
+ * This method returns whether or not to show the individual order succes
147
+ *
148
+ * @return boolean
149
+ */
150
+ protected function getShowOrderSucces() {
151
+ return $this->show_order_succes;
152
+ }
153
+
154
+
155
+ /**
156
+ * This method returns the Apikey used for API calls
157
+ *
158
+ * @return string
159
+ */
160
+ protected function getApikey() {
161
+ return $this->apikey;
162
+ }
163
+
164
+ /**
165
+ * This method returns the Smart Send licensekey entered in the modules settings
166
+ *
167
+ * @return string
168
+ */
169
+ protected function getSmartsendLicensekey() {
170
+ return $this->smartsend_licensekey;
171
+ }
172
+
173
+ /**
174
+ * This method returns the Smart Send username entered in the modules settings
175
+ *
176
+ * @return string
177
+ */
178
+ protected function getSmartsendUsername() {
179
+ return $this->smartsend_username;
180
+ }
181
+
182
+ /**
183
+ * This method returns the version number of the CMS
184
+ *
185
+ * @return string
186
+ */
187
+ public function getCmsSystem() {
188
+ return $this->cms_system;
189
+ }
190
+
191
+ /**
192
+ * This method returns the version number of the CMS
193
+ *
194
+ * @return string
195
+ */
196
+ public function getCmsVersion() {
197
+ return $this->cms_version;
198
+ }
199
+
200
+ /**
201
+ * This method returns the version number of the Smart Send Logistics module
202
+ *
203
+ * @return string
204
+ */
205
+ public function getModuleVersion() {
206
+ return $this->module_version;
207
+ }
208
+
209
+ /**
210
+ * This method returns the language used my the active admin user
211
+ *
212
+ * @return string
213
+ */
214
+ public function getCmsLanguage() {
215
+ return str_replace("_","-",$this->cms_language);
216
+ }
217
+
218
+ /**
219
+ * This method returns the module settings
220
+ *
221
+ * @return array
222
+ */
223
+ public function getSettings() {
224
+ return $this->settings;
225
+ }
226
+
227
+ /**
228
+ * This method is used to check if any orders has been added to the request
229
+ *
230
+ * @return bolean
231
+ */
232
+ public function hasRequestOrders() {
233
+ $request = $this->getRequest();
234
+ if( is_array($request) && !empty($request) ) {
235
+ return true;
236
+ } else {
237
+ return false;
238
+ }
239
+ }
240
+
241
+ /**
242
+ * This method sets the request type to be used for the API call
243
+ *
244
+ * @return void
245
+ */
246
+ public function setRequestType($request_type) {
247
+ $this->request_type = $request_type;
248
+ }
249
+
250
+ /**
251
+ * This method sets the response from the API call
252
+ *
253
+ * @return void
254
+ */
255
+ private function setResponse($response) {
256
+ $this->response = $response;
257
+ }
258
+
259
+ /**
260
+ * This method sets the response type from the API call
261
+ *
262
+ * @return void
263
+ */
264
+ private function setResponseType($response_type) {
265
+ $this->response_type = $response_type;
266
+ }
267
+
268
+ /**
269
+ * This method sets the response code from the API call
270
+ *
271
+ * @return void
272
+ */
273
+ private function setResponseCode($response_code) {
274
+ $this->response_code = $response_code;
275
+ }
276
+
277
+ public function setShowOrderSucces($boolean) {
278
+ $this->show_order_succes = $boolean;
279
+ }
280
+
281
+ /**
282
+ * This method performs the API request
283
+ *
284
+ * @return void
285
+ */
286
+ public function sendRequest() {
287
+
288
+ //intitiate curl
289
+ $ch = curl_init();
290
+
291
+ /* API URL */
292
+ switch ($this->getRequestType()) {
293
+ case 'bulk':
294
+ //Label was created from order list
295
+ $url = 'http://smartsend-prod.apigee.net/v7/booking/orders';
296
+ break;
297
+ case 'single':
298
+ //Label was created from order info page
299
+ $url = 'http://smartsend-prod.apigee.net/v7/booking/order';
300
+ break;
301
+ default:
302
+ throw new Exception( $this->getMessageString(2201) );
303
+ }
304
+
305
+ // Check if reqest is empty
306
+ if( !$this->hasRequestOrders() ) {
307
+ throw new Exception( $this->getMessageString(2202) );
308
+ }
309
+
310
+ // Check if there is missing settings:
311
+ if($this->getSmartsendUsername() == '') {
312
+ throw new Exception( $this->getMessageString(2212) );
313
+ } elseif($this->getSmartsendLicensekey() == '') {
314
+ throw new Exception( $this->getMessageString(2213) );
315
+ }
316
+
317
+ curl_setopt($ch, CURLOPT_URL, $url); //curl url
318
+ curl_setopt($ch, CURLOPT_POST, true);
319
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getRequestJsonEncoded());
320
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
321
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
322
+ 'apikey:'.$this->getApikey(),
323
+ 'smartsendmail:'.$this->getSmartsendUsername(),
324
+ 'smartsendlicence:'.$this->getSmartsendLicensekey(),
325
+ 'cmssystem:'.$this->getCmsSystem(),
326
+ 'cmsversion:'.$this->getCmsVersion(),
327
+ 'appversion:'.$this->getModuleVersion(),
328
+ 'test:'.($this->getTest() ? 'true' : 'false'),
329
+ 'Content-Type:application/json; charset=UTF-8',
330
+ "Accept: text/xml",
331
+ 'Accept-Language:'.$this->getCmsLanguage(),
332
+ )); //curl request header
333
+
334
+ $response = curl_exec($ch); //executes the request
335
+ $response_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
336
+ $response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
337
+ $response_error = curl_error($ch);
338
+ // cURL error code: curl_errno($ch)
339
+
340
+ // Set the respinse
341
+ $this->setResponse( $response );
342
+ $this->setResponseType( $response_type );
343
+ $this->setResponseCode( $response_error );
344
+ //meta data: curl_getinfo($ch);
345
+
346
+ // If there were any
347
+ if( !($response_code >= 200 && $response_code < 300) ) {
348
+ throw new Exception( $this->getMessageString(2203) . ': (' . $response_code . ') '. $response );
349
+ }
350
+
351
+ curl_close($ch); // Close the curl. Only AFTER the errro has been checked
352
+
353
+ }
354
+
355
+ /**
356
+ * This method handles the response from the API request
357
+ *
358
+ * @return void
359
+ */
360
+ public function handleApiReponse() {
361
+
362
+ $response = $this->getResponseJsonDecoded();
363
+
364
+ $settings = $this->getSettings();
365
+
366
+ // Add notification if the info-field is set in the response
367
+ if( isset($response['info']) && $response['info'] != '') {
368
+ if(is_array($response['info'])) {
369
+ // Add an array of info messages
370
+ foreach($response['info'] as $info_message) {
371
+ $this->addWarningMessage( $info_message );
372
+ }
373
+ } else {
374
+ // Add an info message
375
+ $this->addWarningMessage( $response['info'] );
376
+ }
377
+ }
378
+
379
+ if( !(isset($response['combine_pdf']) && $response['combine_pdf'] != '') && !(isset($order_response['combine_link']) && $order_response['combine_link'] != '') ){
380
+ $this->setShowOrderSucces(true);
381
+ } else {
382
+ $this->setShowOrderSucces(!$settings['combine_pdf_labels']);
383
+ }
384
+
385
+ if(isset($response['orders']) && is_array($response['orders'])) {
386
+ // An array of orders is returned from the API
387
+ foreach($response['orders'] as $order) {
388
+ try {
389
+ $this->handleOrderResponse($order);
390
+ }
391
+ //catch exception
392
+ catch(Exception $e) {
393
+ $this->addErrorMessage( $this->getMessageString(2000) . ' ' . $order['reference'] . ': ' . $e->getMessage() );
394
+ }
395
+ }
396
+
397
+ if( $settings['combine_pdf_labels'] ) {
398
+ // Show the combined link or PDF link
399
+ if(isset($response['combine_pdf']) && $response['combine_pdf'] != '') {
400
+ // Add link to PDF label
401
+ $this->addSuccessMessage('<a href="' . $response['combine_pdf'] . '" target="_blank">' . $this->getMessageString(2101) . '</a>' );
402
+ } elseif(isset($order_response['combine_link']) && $order_response['combine_link'] != '') {
403
+ // Add link to label
404
+ $this->addSuccessMessage('<a href="' . $response['combine_link'] . '" target="_blank">' . $this->getMessageString(2102) . '</a>' );
405
+ }
406
+ }
407
+ } elseif(isset($response['orderno'])) {
408
+ $this->handleOrderResponse($response);
409
+ } else {
410
+ // No orders was returned from the API
411
+ if(isset($response['message']) && $response['message'] != '') {
412
+ $this->addWarningMessage( $response['message'] );
413
+ } else {
414
+ $this->addWarningMessage( $this->getMessageString(2204) );
415
+ }
416
+ }
417
+ }
418
+
419
+ /**
420
+ * This method handles each order response from the API request
421
+ *
422
+ * @param array $order_response contains the API response, JSON devoced to an array
423
+ *
424
+ * @return void
425
+ */
426
+ public function handleOrderResponse($order_response) {
427
+
428
+ $order = $this->loadOrderModel($order_response['orderno']);
429
+ $smartsendorder = $this->loadSmartsendOrderModel();
430
+ $smartsendorder->setOrderObject($order);
431
+
432
+ if( $smartsendorder->getOrderId() ) {
433
+
434
+ $order_comment = $this->getMessageString(2105);
435
+ if(isset($order_response['pdflink'])) {
436
+ $order_comment .= '<br><a href="' . $order_response['pdflink'] . '" target="_blank">' . $this->getMessageString(2103) . '</a>';
437
+ }
438
+ if(is_array($order_response['parcels'])) {
439
+ // This array will be used to send shipment emails
440
+ $parcels_succes_array = array();
441
+
442
+ // An array of orders is returned from the API
443
+ foreach($order_response['parcels'] as $parcel) {
444
+ try {
445
+ $order_comment_array = $this->handleParcelResponse($order_response,$parcel);
446
+ $parcels_succes_array[] = $order_comment_array;
447
+ if(isset($order_comment_array['tracecode']) && isset($order_comment_array['tracelink'])) {
448
+ $order_comment .= '<br>' . $this->getMessageString(2106) . ': <a href="' . $order_comment_array['tracelink'] . '" target="_blank">' . $order_comment_array['tracecode'] . '</a>';
449
+ }
450
+ }
451
+ //catch exception
452
+ catch(Exception $e) {
453
+ $this->addErrorMessage( $this->getMessageString(2000) . ' ' . $order_response['reference'] . ': ' . $e->getMessage() );
454
+ }
455
+ }
456
+
457
+ $settings = $this->getSettings();
458
+
459
+ try {
460
+ // Add comment to order
461
+ $this->addCommentToOrder($order_response['orderno'],$order_comment);
462
+
463
+ // Send email with shipping information
464
+ if($settings['send_shipment_mail']) {
465
+ $this->sendShipmentEmail($order_response['orderno'],$parcels_succes_array,$customer_email_comments=null);
466
+ }
467
+
468
+ // Change order status
469
+ if($settings['change_order_status']) {
470
+ $this->setOrderStatus($order_response['orderno'],$settings['change_order_status']);
471
+ }
472
+ //catch exception
473
+ } catch(Exception $e) {
474
+ $this->addErrorMessage( $this->getMessageString(2000) . ' ' . $order_response['reference'] . ': ' . $e->getMessage() );
475
+ }
476
+
477
+ // Show succes message with label link or pdf link
478
+ if($this->getShowOrderSucces()) {
479
+ if(isset($order_response['pdflink']) && $order_response['pdflink'] != '') {
480
+ // Add link to PDF label
481
+ $this->addSuccessMessage( $this->getMessageString(2000) . ' '. $smartsendorder->getOrderReference() .': <a href="' . $order_response['pdflink'] . '" target="_blank">' . $this->getMessageString(2103) . '</a>' );
482
+ } elseif(isset($order_response['link']) && $order_response['link'] != '') {
483
+ // Add link to label
484
+ $this->addSuccessMessage( $this->getMessageString(2000) . ' '. $smartsendorder->getOrderReference() .': <a href="' . $order_response['link'] . '" target="_blank">' . $this->getMessageString(2104) . '</a>' );
485
+ } else {
486
+ throw new Exception( $this->getMessageString(2207) );
487
+ }
488
+ }
489
+
490
+ } else {
491
+ // No parcels was returned from the API
492
+ if(isset($order_response['message']) && $order_response['message'] != '') {
493
+ $this->addErrorMessage( $this->getMessageString(2000) . ' ' . $order_response['reference'] . ': ' . $order_response['message'] );
494
+ } else {
495
+ $this->addErrorMessage( $this->getMessageString(2000) . ' ' . $order_response['reference'] . ': ' . $this->getMessageString(2205) );
496
+ }
497
+ }
498
+
499
+ } else {
500
+ // Unknwn order
501
+ $this->addErrorMessage( $this->getMessageString(2206) );
502
+ }
503
+ }
504
+
505
+ /**
506
+ * This method handles each parcel response from the API request
507
+ *
508
+ * @param
509
+ *
510
+ * @return array
511
+ */
512
+ public function handleParcelResponse($order_response,$parcel_response) {
513
+ if(isset($parcel_response['tracecode']) && $parcel_response['tracecode'] != '') {
514
+ $this->addTracecodeToParcel($order_response['orderno'], $parcel_response['reference'], $parcel_response['tracecode'],$parcel_response['tracelink']);
515
+ return array(
516
+ 'id' => $parcel_response['id'],
517
+ 'reference' => $parcel_response['reference'],
518
+ 'tracecode' => $parcel_response['tracecode'],
519
+ 'tracelink' => $parcel_response['tracelink']
520
+ );
521
+ } else {
522
+ return;
523
+ }
524
+
525
+ }
526
+
527
+ /*
528
+ * Add an error message that is subsequently shown in admin
529
+ *
530
+ * @param string $error_message
531
+ *
532
+ * @return void
533
+ */
534
+ public function addErrorMessage($error_message) {
535
+ $this->messages[] = array(
536
+ 'type' => 'error',
537
+ 'text' => $error_message
538
+ );
539
+ }
540
+
541
+ /*
542
+ * Add a warning message that is subsequently shown in admin
543
+ *
544
+ * @param string $warning_message
545
+ *
546
+ * @return void
547
+ */
548
+ public function addWarningMessage($warning_message) {
549
+ $this->messages[] = array(
550
+ 'type' => 'warning',
551
+ 'text' => $warning_message
552
+ );
553
+ }
554
+
555
+ /*
556
+ * Add a success message that is subsequently shown in admin
557
+ *
558
+ * @param string $success_message
559
+ *
560
+ * @return void
561
+ */
562
+ public function addSuccessMessage($success_message) {
563
+ $this->messages[] = array(
564
+ 'type' => 'success',
565
+ 'text' => $success_message
566
+ );
567
+ }
568
+
569
+ /*
570
+ * Add an information message that is subsequently shown in admin
571
+ *
572
+ * @param string $information_message
573
+ *
574
+ * @return void
575
+ */
576
+ public function addInfoMessage($information_message) {
577
+ $this->messages[] = array(
578
+ 'type' => 'info',
579
+ 'text' => $information_message
580
+ );
581
+ }
582
+
583
+ }
app/code/community/Smartsend/Logistics/Model/Labelmagento.php ADDED
@@ -0,0 +1,368 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Label class
5
+ *
6
+ * The label class is used to handle requests and responses from the Smart Send Logistics API
7
+ * These are the CMS dependent functions that is used by the parent label class.
8
+ *
9
+ * @folder /app/code/community/Smartsend/Logistics/Model/Labelmagento.php
10
+ * @category Smart Send
11
+ * @package Smartsend_Logistics
12
+ * @class Smartsend_Logistics_Label
13
+ * @copyright Copyright (c) Smart Send ApS (http://www.smartsend.dk)
14
+ * @license http://smartsend.dk/license
15
+ * @version Release: 7.1.0
16
+ * @author Smart Send ApS
17
+ * @link http://smartsend.dk/download/generec
18
+ * @since Class available since Release 7.1.0
19
+ */
20
+
21
+ class Smartsend_Logistics_Model_Labelmagento extends Smartsend_Logistics_Model_Label {
22
+
23
+ protected $apikey;
24
+ protected $smartsend_licensekey;
25
+ protected $smartsend_username;
26
+ protected $cms_system;
27
+ protected $cms_version;
28
+ protected $module_version;
29
+ protected $cms_language;
30
+ protected $settings;
31
+
32
+ /*
33
+ * Set all the variables when class is initiated
34
+ *
35
+ * @return void
36
+ */
37
+ public function __construct() {
38
+ $this->setApiKey();
39
+ $this->setSmartsendLicensekey();
40
+ $this->setSmartsendUsername();
41
+ $this->setCmsVersion();
42
+ $this->setCmsSystem();
43
+ $this->setModuleVersion();
44
+ $this->setCmsLanguage();
45
+ $this->setMessageStringArray();
46
+ $this->setSettings();
47
+ }
48
+
49
+ /*
50
+ * Set the strings that are shown (and translated) for succes, error and notification messages
51
+ *
52
+ * @return void
53
+ */
54
+ protected function setMessageStringArray() {
55
+ $this->message_string_array = array(
56
+ 2000 => 'Order',
57
+ //Notifications
58
+ 2101 => 'Download combined PDF label',
59
+ 2102 => 'Link to print labels',
60
+ 2103 => 'Download PDF label',
61
+ 2104 => 'Link to print label',
62
+ 2105 => 'Label generated with Smart Send Logistics',
63
+ 2106 => 'Tracecode',
64
+ //Errors
65
+ 2201 => 'Unknown API method',
66
+ 2202 => 'Trying to send empty order array',
67
+ 2203 => 'Error from server',
68
+ 2204 => 'No orders returned from server',
69
+ 2205 => 'No parcels returned from server',
70
+ 2206 => 'Unknown order was returned from server',
71
+ 2207 => 'No PDF file or link returned from server',
72
+ 2208 => 'Failed to insert tracecode. No tracecode available.',
73
+ 2209 => 'Failed to change order status. Status unchanged.',
74
+ 2210 => 'Failed to send shipment mail. No mail sent.',
75
+ 2211 => 'Failed to add order comment',
76
+ 2212 => 'Please enter a username in the modules settings',
77
+ 2213 => 'Please enter a license key in the modules settings',
78
+ );
79
+
80
+ // Translate the error string of the $_error array
81
+ foreach($this->message_string_array as $key=>$value) {
82
+ $this->message_string_array[$key] = Mage::helper('logistics')->__($value);
83
+ }
84
+ }
85
+
86
+ /*
87
+ * Set the apikey used for API calls
88
+ *
89
+ * @return void
90
+ */
91
+ protected function setApiKey() {
92
+ $this->apikey = 'yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe';
93
+ }
94
+
95
+ /*
96
+ * Set the licensekey used for API calls
97
+ *
98
+ * @return void
99
+ */
100
+ protected function setSmartsendLicensekey() {
101
+ if(Mage::getStoreConfig('carriers/smartsend/username') == '' && Mage::helper('core')->isModuleEnabled('Vconnect_Postnord')) {
102
+ $this->smartsend_licensekey = Mage::getStoreConfig('carriers/vconnect_postnord/licensekey');
103
+ } else {
104
+ $this->smartsend_licensekey = Mage::getStoreConfig('carriers/smartsend/licensekey');
105
+ }
106
+ }
107
+
108
+ /*
109
+ * Set the username used for API calls
110
+ *
111
+ * @return void
112
+ */
113
+ protected function setSmartsendUsername() {
114
+ if(Mage::getStoreConfig('carriers/smartsend/username') == '' && Mage::helper('core')->isModuleEnabled('Vconnect_Postnord')) {
115
+ $this->smartsend_username = Mage::getStoreConfig('carriers/vconnect_postnord/username');
116
+ } else {
117
+ $this->smartsend_username = Mage::getStoreConfig('carriers/smartsend/username');
118
+ }
119
+ }
120
+
121
+ /*
122
+ * Set the version number of the CMS system
123
+ *
124
+ * @return void
125
+ */
126
+ protected function setCmsVersion() {
127
+ $this->cms_version = Mage::getVersion();
128
+ }
129
+
130
+ /*
131
+ * Set the language used by the CMS system
132
+ *
133
+ * @return void
134
+ */
135
+ protected function setCmsLanguage() {
136
+ $this->cms_language = Mage::app()->getLocale()->getLocaleCode();
137
+ }
138
+
139
+ /*
140
+ * Set the CMS system
141
+ *
142
+ * @return void
143
+ */
144
+ protected function setCmsSystem() {
145
+ $this->cms_system = 'Magento';
146
+ }
147
+
148
+ /*
149
+ * Set the version number of this module
150
+ *
151
+ * @return void
152
+ */
153
+ protected function setModuleVersion() {
154
+ $this->module_version = Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version;
155
+ }
156
+
157
+ /*
158
+ * Set the general settings from the module
159
+ *
160
+ * @return void
161
+ */
162
+ protected function setSettings() {
163
+ $this->settings = array(
164
+ 'combine_pdf_labels' => Mage::getStoreConfig('carriers/smartsend/combinepdf'),
165
+ 'change_order_status' => Mage::getStoreConfig('carriers/smartsend/status'),
166
+ 'send_shipment_mail' => Mage::getStoreConfig('carriers/smartsend/sendemail')
167
+ );
168
+ }
169
+
170
+ /*
171
+ * Load an order model class
172
+ *
173
+ * @return object
174
+ */
175
+ protected function loadOrderModel($order_id) {
176
+ return Mage::getModel('sales/order')->load($order_id);
177
+ }
178
+
179
+ /*
180
+ * Load a Smart Send order model class
181
+ *
182
+ * @return object
183
+ */
184
+ protected function loadSmartsendOrderModel() {
185
+ return Mage::getModel('logistics/ordermagento');
186
+ }
187
+
188
+ /*
189
+ * Send an email with the shipping informations
190
+ *
191
+ * @param string $order_number is the id of the order
192
+ * @param array $parcels_succes_array is an array of parcel id numbers
193
+ * @param string $customer_email_comments is a string that can be sendt with the email
194
+ *
195
+ * @return void
196
+ */
197
+ protected function sendShipmentEmail($order_number,$parcels_succes_array,$customer_email_comments=null) {
198
+ if(is_array($parcels_succes_array)) {
199
+ foreach($parcels_succes_array as $parcel) {
200
+ $shipment = Mage::getModel('sales/order_shipment')->load($parcel['reference']);
201
+ if($shipment->getId() != '') {
202
+ // Only send email if it has not been send already
203
+ if($shipment->getEmailSent() == false ) {
204
+ $shipment->sendEmail(true, $customer_email_comments);
205
+ $shipment->setEmailSent(true);
206
+ $shipment->save();
207
+ }
208
+ } else {
209
+ throw new Exception( $this->getMessageString(2210) );
210
+ }
211
+ }
212
+ } else {
213
+ throw new Exception( $this->getMessageString(2210) );
214
+ }
215
+ }
216
+
217
+ /*
218
+ * Set the order status
219
+ *
220
+ * @param string $order_number is the id of the order
221
+ * @param string $order_status is the status that the order should be updated to
222
+ *
223
+ * @return void
224
+ */
225
+ protected function setOrderStatus($order_number,$order_status) {
226
+ $order = Mage::getModel('sales/order')->load($order_number);
227
+ if($order->getId() != '') {
228
+
229
+ // Array containing all status codes as KEY and labels as VALUE.
230
+ $status_array = array();
231
+
232
+ // Create status array
233
+ $all_status = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
234
+ foreach($all_status as $single_status) {
235
+ $status_array[$single_status["status"]] = $single_status["label"];
236
+ }
237
+
238
+ // If the status is in Magento
239
+ if(array_key_exists($order_status,$status_array)) {
240
+ // Change the status if is is not already that status
241
+ if($order->getStatus() != $order_status) {
242
+ $order->setStatus($order_status);
243
+ $order->save();
244
+ }
245
+ }
246
+ } else {
247
+ throw new Exception( $this->getMessageString(2209) );
248
+ }
249
+ }
250
+
251
+ /*
252
+ * Add a trace code to the parcel
253
+ *
254
+ * @param string $order_number is the id of the order
255
+ * @param string $shipment_number is the id of the shipment
256
+ * @param string $tracking_numder is the tracking number to add
257
+ * @param string $tracelink is the linked used to crack the parcel
258
+ *
259
+ * @return void
260
+ */
261
+ protected function addTracecodeToParcel($order_number,$shipment_number,$tracking_numder,$tracelink) {
262
+ $shipment = Mage::getModel('sales/order_shipment')->load($shipment_number);
263
+ if($shipment->getId() != '') {
264
+ $order = Mage::getModel('sales/order')->load($shipment->getData('order_id'));
265
+ $smartsendorder = Mage::getModel('logistics/ordermagento');
266
+ $smartsendorder->setOrderObject($order);
267
+
268
+ $carrier_code = 'smartsend'.$smartsendorder->getShippingCarrier();
269
+
270
+ $track = Mage::getModel('sales/order_shipment_track')
271
+ ->setShipment($shipment)
272
+ ->setData('title', $order->getShippingDescription())
273
+ ->setData('number', $tracking_numder)
274
+ ->setData('carrier_code', $carrier_code)
275
+ ->setData('order_id', $shipment->getData('order_id'))
276
+ ->save();
277
+ } else {
278
+ throw new Exception( $this->getMessageString(2208) );
279
+ }
280
+ }
281
+
282
+ /*
283
+ * Add a comment to the order
284
+ *
285
+ * @param string $order_number is the id of the order
286
+ * @param string $order_comment is the comment to add
287
+ *
288
+ * @return void
289
+ */
290
+ protected function addCommentToOrder($order_number,$order_comment) {
291
+ $order = Mage::getModel('sales/order')->load($order_number);
292
+ if($order->getId() != '') {
293
+ //Add order history comment
294
+ $order->addStatusHistoryComment($order_comment, false); // no sense to set $status again
295
+ $order->save();
296
+ } else {
297
+ throw new Exception( $this->getMessageString(2211) );
298
+ }
299
+ }
300
+
301
+ /*
302
+ * Show the messages that has been added during the API call
303
+ *
304
+ * @return void
305
+ */
306
+ public function showResult() {
307
+
308
+ foreach($this->getMessages() as $message) {
309
+
310
+ switch ($message['type']) {
311
+ case 'error':
312
+ //Add an error
313
+ Mage::getSingleton('core/session')->addError( $message['text'] );
314
+ break;
315
+ case 'warning':
316
+ //Add a warning
317
+ Mage::getSingleton('core/session')->addWarning( $message['text'] );
318
+ break;
319
+ case 'success':
320
+ //Add a success
321
+ Mage::getSingleton('core/session')->addSuccess( $message['text'] );
322
+ break;
323
+ default:
324
+ //Add an information
325
+ Mage::getSingleton('core/session')->addNotice( $message['text'] );
326
+ }
327
+
328
+ }
329
+ }
330
+
331
+ /**
332
+ * The metchods adds an order to the API request
333
+ * both for single and mass generation
334
+ *
335
+ * @param object $order
336
+ * @param bool $return indicates if the order is a return order (true) or a normal order (false)
337
+ *
338
+ * @return void
339
+ */
340
+ public function addOrderToRequest($order,$return=false) {
341
+
342
+ $smartsendorder = Mage::getModel('logistics/ordermagento');
343
+ $smartsendorder->setOrderObject($order);
344
+ $smartsendorder->setReturn($return);
345
+
346
+ $smartsendorder->setInfo();
347
+ $smartsendorder->setReceiver();
348
+ $smartsendorder->setSender();
349
+ $smartsendorder->setAgent();
350
+ $smartsendorder->setService();
351
+ $smartsendorder->setParcels();
352
+
353
+ //All done. Add to request.
354
+ switch ($this->getRequestType()) {
355
+ case 'bulk':
356
+ //Label was created from order list
357
+ $this->request[] = $smartsendorder->getFinalOrder();
358
+ break;
359
+ case 'single':
360
+ //Label was created from order info page
361
+ $this->request = $smartsendorder->getFinalOrder();
362
+ break;
363
+ default:
364
+ throw new Exception( $this->getMessageString(2201) );
365
+ }
366
+ }
367
+
368
+ }
app/code/community/Smartsend/Logistics/Model/Mysql4/{Swipbox.php → Flex.php} RENAMED
@@ -17,18 +17,18 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Mysql4/Swipbox.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
- class Smartsend_Logistics_Model_Mysql4_Swipbox extends Mage_Core_Model_Mysql4_Abstract
28
  {
29
  public function _construct()
30
  {
31
- // Note that the pickup_id refers to the key field in your database table.
32
- $this->_init('logistics/swipbox', 'id');
33
  }
34
  }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/Mysql4/Flex.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
+ class Smartsend_Logistics_Model_Mysql4_Flex extends Mage_Core_Model_Mysql4_Abstract
28
  {
29
  public function _construct()
30
  {
31
+ // Note that the Flex_id refers to the key field in your database table.
32
+ $this->_init('logistics/flex', 'id');
33
  }
34
  }
app/code/community/Smartsend/Logistics/Model/Mysql4/{Swipbox → Flex}/Collection.php RENAMED
@@ -17,18 +17,18 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Mysql4/Swipbox/Collection.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
- class Smartsend_Logistics_Model_Mysql4_Swipbox_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
28
  {
29
  public function _construct()
30
  {
31
  parent::_construct();
32
- $this->_init('logistics/swipbox');
33
  }
34
  }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/Mysql4/Flex/Collection.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
+ class Smartsend_Logistics_Model_Mysql4_Flex_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
28
  {
29
  public function _construct()
30
  {
31
  parent::_construct();
32
+ $this->_init('logistics/flex');
33
  }
34
  }
app/code/community/Smartsend/Logistics/Model/Observer.php CHANGED
@@ -26,14 +26,17 @@
26
  class Smartsend_Logistics_Model_Observer extends Varien_Object {
27
 
28
  public function saveShippingMethod($evt) { //saving shipping method
29
- $request = $evt->getRequest();
30
- $quote = $evt->getQuote();
 
31
  $shippingMethod = $quote->getShippingAddress()->getShippingMethod(); //getting shipping method
32
-
 
 
 
 
33
  $pickup_t = $request->getParam('shipping_pickup', false);
34
- if ($shippingMethod == 'smartsendswipbox_pickup') {
35
- $pickup['store'] = $pickup_t['store']['smartsendswipbox_pickup'];
36
- } elseif ($shippingMethod == 'smartsendpostdanmark_pickup') {
37
  $pickup['store'] = $pickup_t['store']['smartsendpostdanmark_pickup'];
38
  } elseif ($shippingMethod == 'smartsendposten_pickup') {
39
  $pickup['store'] = $pickup_t['store']['smartsendposten_pickup'];
@@ -41,33 +44,47 @@ class Smartsend_Logistics_Model_Observer extends Varien_Object {
41
  $pickup['store'] = $pickup_t['store']['smartsendgls_pickup'];
42
  } elseif ($shippingMethod == 'smartsendbring_pickup') {
43
  $pickup['store'] = $pickup_t['store']['smartsendbring_pickup'];
44
- } elseif ($shippingMethod == 'smartsendpickup_pickup') {
45
- $pickup['store'] = $pickup_t['store']['smartsendpickup_pickup'];
46
  }
47
 
48
- $quote_id = $quote->getId();
49
- $data = array($quote_id => $pickup);
50
-
51
  if ($pickup) {
52
- Mage::getSingleton('checkout/session')->setPickup($data); //setting pickup
 
 
 
 
 
 
 
 
 
 
 
 
53
  }
54
  }
55
 
 
 
 
 
 
 
 
 
56
  public function saveOrderAfter($evt) {
57
- $order = $evt->getOrder(); //getting order
58
- $quote = $evt->getQuote();
59
- $quote_id = $quote->getId();
60
- $pickup = Mage::getSingleton('checkout/session')->getPickup(); //getting picup
61
- $shippingMethod = $quote->getShippingAddress()->getShippingMethod(); //getting shipping method
 
 
62
 
63
  if (isset($pickup[$quote_id])) {
64
 
65
- $temp = $pickup[$quote_id];
66
- $store = unserialize($temp['store']);
67
- if ($shippingMethod == 'smartsendswipbox_pickup') {
68
- $pickupModel = Mage::getModel('logistics/swipbox');
69
- $data['pick_up_id'] = $store['pick_up_id'];
70
- } elseif ($shippingMethod == 'smartsendpostdanmark_pickup') {
71
  $pickupModel = Mage::getModel('logistics/postdanmark');
72
  $data['pick_up_id'] = $store['pick_up_id'];
73
  } elseif ($shippingMethod == 'smartsendposten_pickup') {
@@ -79,57 +96,59 @@ class Smartsend_Logistics_Model_Observer extends Varien_Object {
79
  } elseif ($shippingMethod == 'smartsendbring_pickup') {
80
  $pickupModel = Mage::getModel('logistics/bring');
81
  $data['pick_up_id'] = $store['pick_up_id'];
82
- } elseif ($shippingMethod == 'smartsendpickup_pickup') {
83
- $pickupModel = Mage::getModel('logistics/pickup');
84
- $data['pick_up_id'] = $store['pick_up_id'];
85
  }
86
 
87
- $data['store'] = Mage::app()->getStore()->getFrontendName();
88
- $data['company'] = $store['company'];
89
- $data['street'] = $store['street'];
90
- $data['city'] = $store['city'];
91
- $data['zip'] = $store['zipcode'];
92
- $data['country'] = $store['country'];
93
- $data['carrier'] = $store['shippingMethod'];
94
- $data['order_id'] = $order->getId();
95
 
96
- if (isset($pickupModel)) {
97
  $pickupModel->setData($data);
98
  $pickupModel->save();
99
  }
100
- } elseif(strstr($shippingMethod,"smartsend")!="") {
101
-
102
- $carrier_name=explode("_",$shippingMethod);
103
- $carrier = substr($carrier_name[0], 9);
104
-
105
- $pickupModel = Mage::getModel('logistics/'.$carrier);
106
- $data['carrier'] = ucfirst($carrier);
107
- $data['pick_up_id'] = '000';
108
-
109
- $data['store'] = Mage::app()->getStore()->getFrontendName();
110
- $data['company'] = '';
111
- $data['street'] = '';
112
- $data['city'] = '';
113
- $data['zip'] = '';
114
- $data['country'] = 'DK';
115
- $data['order_id'] = $order->getId();
116
-
117
- if (isset($pickupModel)) {
118
- $pickupModel->setData($data);
119
- $pickupModel->save();
120
  }
121
  }
122
  }
123
 
 
 
 
 
 
 
 
 
124
  public function loadOrderAfter($evt) {
 
125
  $order = $evt->getOrder();
126
  if ($order->getId()) {
127
  $order_id = $order->getId();
128
  $pickupCollection = Mage::getModel('logistics/pickup')->getCollection(); //get pickup collection from the pickup table
129
  $pickupCollection->addFieldToFilter('order_id', $order_id);
130
  $pickup = $pickupCollection->getFirstItem();
131
- $order->setPickupObject($pickup);
132
  }
 
133
  }
134
 
135
  public function loadQuoteAfter($evt) {
@@ -168,7 +187,7 @@ class Smartsend_Logistics_Model_Observer extends Varien_Object {
168
  $message = Mage::helper('sales')->__('Are you sure you want to do this?');
169
  $block->addButton('generate_label', array(
170
  'label' => Mage::helper('sales')->__('Generate label'),
171
- 'onclick' => "setLocation('{$block->getUrl('logistics/logistics/label')}')",//if message use: "confirmSetLocation('{$message}', '{$block->getUrl('*/yourmodule/crazy')}')",
172
  'class' => 'go'
173
  ));
174
  }
@@ -183,15 +202,52 @@ class Smartsend_Logistics_Model_Observer extends Varien_Object {
183
  // Add 'generate label' action
184
  $block->addItem('mass_generate_label', array(
185
  'label' => Mage::helper('sales')->__('Generate label'),
186
- 'url' => $block->getUrl('logistics/logistics/labelMass')
187
  ));
188
 
189
  // Add 'generate return label' action
190
  $block->addItem('mass_generate_return_label', array(
191
  'label' => Mage::helper('sales')->__('Generate return label'),
192
- 'url' => $block->getUrl('logistics/logistics/labelreturnMass')
 
 
 
 
 
 
193
  ));
194
  }
195
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
  }
26
  class Smartsend_Logistics_Model_Observer extends Varien_Object {
27
 
28
  public function saveShippingMethod($evt) { //saving shipping method
29
+ $request = $evt->getRequest();
30
+ $quote = $evt->getQuote();
31
+ $quote_id = $quote->getId();
32
  $shippingMethod = $quote->getShippingAddress()->getShippingMethod(); //getting shipping method
33
+ $carrier = explode('_', $shippingMethod);
34
+ $carrier = $carrier[0];
35
+
36
+ /* Save data about pickup point */
37
+ $pickup = array();
38
  $pickup_t = $request->getParam('shipping_pickup', false);
39
+ if ($shippingMethod == 'smartsendpostdanmark_pickup') {
 
 
40
  $pickup['store'] = $pickup_t['store']['smartsendpostdanmark_pickup'];
41
  } elseif ($shippingMethod == 'smartsendposten_pickup') {
42
  $pickup['store'] = $pickup_t['store']['smartsendposten_pickup'];
44
  $pickup['store'] = $pickup_t['store']['smartsendgls_pickup'];
45
  } elseif ($shippingMethod == 'smartsendbring_pickup') {
46
  $pickup['store'] = $pickup_t['store']['smartsendbring_pickup'];
 
 
47
  }
48
 
 
 
 
49
  if ($pickup) {
50
+ $data = array($quote_id => $pickup);
51
+ Mage::getSingleton('checkout/session')->setPickup($data);
52
+ }
53
+
54
+ /* Save data about flex delivery */
55
+ if ($carrier == 'smartsendpostdanmark' || $carrier == 'smartsendposten') {
56
+ $flex = array();
57
+ $flex_t = $request->getParam('shipping_flex', false);
58
+ $flex['store'] = $flex_t['store'][$shippingMethod];
59
+ if ($flex) {
60
+ $data_flex = array($quote_id => $flex);
61
+ Mage::getSingleton('checkout/session')->setFlex($data_flex);
62
+ }
63
  }
64
  }
65
 
66
+ /**
67
+ *
68
+ * This function is called after order gets saved to database.
69
+ * Here we transfer our custom pickuppoint fields to the custom table smartsend_pickup
70
+ * Read more: http://excellencemagentoblog.com/blog/2011/10/06/magento-add-custom-fields-checkout-page/
71
+ *
72
+ * @param $evt
73
+ */
74
  public function saveOrderAfter($evt) {
75
+ $order = $evt->getOrder(); //getting order
76
+ $quote = $evt->getQuote();
77
+ $quote_id = $quote->getId();
78
+ $shippingMethod = $quote->getShippingAddress()->getShippingMethod(); //getting shipping method
79
+
80
+ $pickup = Mage::getSingleton('checkout/session')->getPickup(); //getting picup
81
+ $flex = Mage::getSingleton('checkout/session')->getFlex(); //getting flex
82
 
83
  if (isset($pickup[$quote_id])) {
84
 
85
+ $temp = $pickup[$quote_id];
86
+ $store = unserialize($temp['store']);
87
+ if ($shippingMethod == 'smartsendpostdanmark_pickup') {
 
 
 
88
  $pickupModel = Mage::getModel('logistics/postdanmark');
89
  $data['pick_up_id'] = $store['pick_up_id'];
90
  } elseif ($shippingMethod == 'smartsendposten_pickup') {
96
  } elseif ($shippingMethod == 'smartsendbring_pickup') {
97
  $pickupModel = Mage::getModel('logistics/bring');
98
  $data['pick_up_id'] = $store['pick_up_id'];
 
 
 
99
  }
100
 
101
+ $data['store'] = Mage::app()->getStore()->getFrontendName();
102
+ $data['company'] = $store['company'];
103
+ $data['street'] = $store['street'];
104
+ $data['city'] = $store['city'];
105
+ $data['zip'] = $store['zipcode'];
106
+ $data['country'] = $store['country'];
107
+ $data['carrier'] = $store['shippingMethod'];
108
+ $data['order_id'] = $order->getId();
109
 
110
+ if (isset($pickupModel) && !empty($store)) {
111
  $pickupModel->setData($data);
112
  $pickupModel->save();
113
  }
114
+ }
115
+
116
+ if (isset($flex[$quote_id])) {
117
+
118
+ $temp = $flex[$quote_id];
119
+ $flexModel = Mage::getModel('logistics/flex');
120
+
121
+ $flexnote = $temp['store'];
122
+ $data['store'] = Mage::app()->getStore()->getFrontendName();
123
+ $data['flexnote'] = $flexnote;
124
+ $data['order_id'] = $order->getId();
125
+
126
+ if (isset($flexModel) && !empty($flexnote)) {
127
+ $flexModel->setData($data);
128
+ $flexModel->save();
 
 
 
 
 
129
  }
130
  }
131
  }
132
 
133
+ /**
134
+ *
135
+ * This function is called when $order->load() is done.
136
+ * Here we read our custom fields value from database and set it in order object.
137
+ * Read more: http://excellencemagentoblog.com/blog/2011/10/06/magento-add-custom-fields-checkout-page/
138
+ *
139
+ * @param unknown_type $evt
140
+ */
141
  public function loadOrderAfter($evt) {
142
+ /*
143
  $order = $evt->getOrder();
144
  if ($order->getId()) {
145
  $order_id = $order->getId();
146
  $pickupCollection = Mage::getModel('logistics/pickup')->getCollection(); //get pickup collection from the pickup table
147
  $pickupCollection->addFieldToFilter('order_id', $order_id);
148
  $pickup = $pickupCollection->getFirstItem();
149
+ $order->setPickupObject($pickup); //setPickupObject() is not set anywhere
150
  }
151
+ */
152
  }
153
 
154
  public function loadQuoteAfter($evt) {
187
  $message = Mage::helper('sales')->__('Are you sure you want to do this?');
188
  $block->addButton('generate_label', array(
189
  'label' => Mage::helper('sales')->__('Generate label'),
190
+ 'onclick' => "setLocation('{$block->getUrl('*/logistics/labelNormal')}')",//if message use: "confirmSetLocation('{$message}', '{$block->getUrl('*/yourmodule/crazy')}')",
191
  'class' => 'go'
192
  ));
193
  }
202
  // Add 'generate label' action
203
  $block->addItem('mass_generate_label', array(
204
  'label' => Mage::helper('sales')->__('Generate label'),
205
+ 'url' => $block->getUrl('*/logistics/labelNormalMass')
206
  ));
207
 
208
  // Add 'generate return label' action
209
  $block->addItem('mass_generate_return_label', array(
210
  'label' => Mage::helper('sales')->__('Generate return label'),
211
+ 'url' => $block->getUrl('*/logistics/labelReturnMass')
212
+ ));
213
+
214
+ // Add 'generate normal + return label' action
215
+ $block->addItem('mass_generate_normal_return_label', array(
216
+ 'label' => Mage::helper('sales')->__('Generate normal and return label'),
217
+ 'url' => $block->getUrl('*/logistics/labelNormalReturnMass')
218
  ));
219
  }
220
  }
221
+
222
+ public function changedSectionBefore($observer) {
223
+
224
+ $username = Mage::getStoreConfig('carriers/smartsend/username');
225
+ $licensekey = Mage::getStoreConfig('carriers/smartsend/licensekey');
226
+ $validation = (int) Mage::getStoreConfig('carriers/smartsend/validation');
227
+
228
+ $changedusername = Mage::app()->getRequest()->getParams()['groups']['smartsend']['fields']['username']['value'];
229
+ $changedlicensekey = Mage::app()->getRequest()->getParams()['groups']['smartsend']['fields']['licensekey']['value'];
230
+
231
+ if ($username != $changedusername || $licensekey != $changedlicensekey || $validation + 60*60*24*7 < time() ) {
232
+ $is_verified = Mage::getModel('logistics/api_validation')->_verify($changedusername, $changedlicensekey);
233
+ if ($is_verified) {
234
+ $validation = time();
235
+ } else {
236
+ $validation = 0;
237
+ }
238
+ }
239
+ Mage::getConfig()->saveConfig('carriers/smartsend/validation', $validation, 'default', 0);
240
+ }
241
+
242
+ public function changedSection($observer) {
243
+ /*
244
+ $status = Mage::app()->getRequest()->getParam('status');
245
+
246
+ if (isset($status)) {
247
+ Mage::getConfig()->saveConfig('carriers/smartsend/validation', $status, 'default', 0);
248
+ }
249
+ */
250
+ }
251
+
252
 
253
  }
app/code/community/Smartsend/Logistics/Model/Order.php CHANGED
@@ -1,7 +1,11 @@
1
  <?php
2
 
3
  /**
4
- * Smartsend_Logistics
 
 
 
 
5
  *
6
  * This source file is subject to the GNU General Public License v3.0
7
  * that is bundled with this package in the file license.txt.
@@ -17,53 +21,94 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
 
20
  * @folder /app/code/community/Smartsend/Logistics/Model/Order.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
- * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
- */
26
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  class Smartsend_Logistics_Model_Order extends Mage_Core_Model_Abstract {
29
 
30
- /* This class is called by using the code:
31
-
32
- $order = new Smartsend_Logistics_Order();
33
- $order->setOrderObject($order_object);
34
- $order->setReturn(true);
35
- try{
36
- $order->setInfo();
37
- $order->setReceiver();
38
- $order->setSender();
39
- $order->setAgent();
40
- $order->setService();
41
- $order->setParcels();
42
 
43
- //All done. Add to request.
44
- $request_array[] = $order->getFinalOrder();
45
- } catch (Exception $e) {
46
- echo 'Caught exception: ', $e->getMessage(), "\n";
47
- }
48
 
49
- */
50
-
51
- private $_order;
52
- private $_info;
53
- private $_receiver;
54
- private $_sender;
55
- private $_agent;
56
- private $_service;
57
- private $_parcels = array();
58
- private $_return = false;
59
- private $_test = false;
60
- private $_cms = 'magento';
61
-
62
- public function _construct() {}
63
 
64
  /**
65
  *
66
  * Set the order object
 
67
  */
68
  public function setOrderObject($order_object) {
69
  $this->_order = $order_object;
@@ -72,6 +117,7 @@ try{
72
  /**
73
  *
74
  * Set wheter or not the label is a return label
 
75
  */
76
  public function setReturn($return=false) {
77
  $this->_return = $return;
@@ -94,7 +140,7 @@ try{
94
 
95
 
96
  /*****************************************************************************************
97
- * Functions to return true/false for different statements
98
  ****************************************************************************************/
99
 
100
  /**
@@ -102,7 +148,7 @@ try{
102
  * Check if order is placed by a SmartSend or a vConnect shipping method
103
  * @return boolean
104
  */
105
- private function isSmartsendOrVConnect() {
106
 
107
  if($this->isSmartsend() == true) {
108
  return true;
@@ -118,7 +164,7 @@ try{
118
  * Check if order is a pickup shipping method from SmartSend or vConnect
119
  * @return boolean
120
  */
121
- private function isPickup() {
122
 
123
  if($this->isPickupSmartsend() == true) {
124
  return true;
@@ -135,23 +181,18 @@ try{
135
  * Check if the label is a return label for the order
136
  * @return boolean
137
  */
138
- private function isReturn() {
139
  return $this->_return;
140
  }
141
 
142
-
143
- /*****************************************************************************************
144
- * Functions to get pickup data, carrier data, carrier settings
145
- ****************************************************************************************/
146
-
147
  /**
148
  *
149
  * Check if order is placed by a SmartSend shipping method
150
  * @return boolean
151
  */
152
- private function isSmartsend() {
153
 
154
- $method = strtolower($this->getShippingCarrierId());
155
 
156
  //Check if shipping methode starts with 'smartsend'
157
  if(substr($method, 0, strlen('smartsend')) === 'smartsend') {
@@ -167,9 +208,9 @@ try{
167
  * Check if order is placed by a vConnect shipping method
168
  * @return boolean
169
  */
170
- private function isVconnect() {
171
 
172
- $method = strtolower($this->getShippingCarrierId());
173
 
174
  //Check if shipping methode starts with 'vconnect' or 'vc'
175
  if(substr($method, 0, strlen('vconnect')) === 'vconnect') {
@@ -187,7 +228,7 @@ try{
187
  * Check if order is a pickup shipping method from SmartSend
188
  * @return boolean
189
  */
190
- private function isPickupSmartsend() {
191
 
192
  if($this->isSmartsend() == true) {
193
  $method = $this->getShippingMethod();
@@ -209,7 +250,7 @@ try{
209
  * Check if order is a pickup shipping method from vConnect
210
  * @return boolean
211
  */
212
- private function isPickupVconnect() {
213
 
214
  if($this->isVconnect() == true) {
215
  $method = $this->getShippingMethod();
@@ -224,380 +265,511 @@ try{
224
  return false;
225
  }
226
  }
227
-
228
  /**
229
  *
230
- * Get pickup id of delivery point
231
- * @return string
232
  */
233
- private function getPickupId() {
234
-
235
- $pickupdata = $this->getPickupData();
236
- return (isset($pickupdata['id']) ? $pickupdata['id'] : null);
237
 
 
 
238
  }
239
-
 
 
 
 
240
  /**
241
  *
242
- * Get pickup data for delivery point
 
 
243
  * @return array
244
- */
245
- private function getPickupData() {
246
-
247
- if($this->isPickupSmartsend() == true) {
248
- return $this->getPickupDataSmartsend();
249
- } elseif($this->isPickupVconnect() == true) {
250
- return $this->getPickupDataVconnect();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  } else {
252
- throw new Exception( "Trying to access pickup data for an order that is not a pickup point order." );
253
  }
254
-
255
  }
256
 
257
- /**
258
- *
259
- * Get pickup data for a vConnect delivery point
260
- * @return array
261
- */
262
- private function getPickupDataVconnect() {
 
263
 
264
- $billing_address = $this->getShippingAddress();
265
 
266
- $pacsoftServicePoint = str_replace(' ', '', $billing_address['address2']); //remove spaces
267
- $pacsoftServicePointArray = explode(":",$pacsoftServicePoint); //devide into a array by :
268
-
269
- if ( isset($pacsoftServicePointArray) && ( strtolower($pacsoftServicePointArray[0]) == strtolower('ServicePointID') ) || strtolower($pacsoftServicePointArray[0]) == strtolower('Pakkeshop') ){
270
- $pickupData = array(
271
- 'id' => $pacsoftServicePointArray[1]."-".time()."-".rand(9999,10000),
272
- 'agentno' => $pacsoftServicePointArray[1],
273
- 'agenttype' => ($this->getShippingCarrier() == 'postdanmark' ? 'PDK' : null),
274
- 'company' => $billing_address['company'],
275
- 'name1' => $billing_address['name1'],
276
- 'name2' => $billing_address['name2'],
277
- 'address1' => $billing_address['address1'],
278
- 'address2' => null,
279
- 'city' => $billing_address['city'],
280
- 'zip' => $billing_address['zip'],
281
- 'country' => $billing_address['country'],
282
- 'sms' => null,
283
- 'mail' => null,
284
- );
285
 
286
- return $pickupData;
 
 
 
 
 
 
 
 
287
 
288
- } else {
289
- return null;
290
- }
291
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  }
293
 
 
 
 
294
  /**
295
  *
296
- * Get carrier formatted without 'smartsend'
 
 
 
297
  * @return string
298
  */
299
- public function formatCarrier($carrier,$format=0) {
 
300
 
301
- if($format != 0 && $format != 1 && $format != 2 && $format != 3 && $format != 4 ) {
302
- //Change this code for each CMS system
303
- throw new Exception('Unknown format for carrier formatting.');
 
304
  }
305
 
306
- $carrier_lowcase = strtolower($carrier);
307
-
308
  switch ($carrier_lowcase) {
309
  case 'postdanmark':
310
  if($format == 0) {
311
- return 'Postdanmark';
312
- } elseif($format == 1) {
313
  return 'postdanmark';
314
- } elseif($format == 2) {
315
- return 'PostDanmark';
316
- } elseif($format == 3) {
317
  return 'Post Danmark';
318
- } elseif($format == 4) {
319
- return 'smartsendpostdanmark';
320
  }
321
  break;
322
  case 'posten':
323
  if($format == 0) {
324
- return 'Posten';
325
- } elseif($format == 1) {
326
  return 'posten';
327
- } elseif($format == 2) {
328
- return 'Posten';
329
- } elseif($format == 3) {
330
  return 'Posten';
331
- } elseif($format == 4) {
332
- return 'smartsendposten';
333
  }
334
  break;
335
  case 'gls':
336
  if($format == 0) {
337
- return 'Gls';
338
- } elseif($format == 1) {
339
  return 'gls';
340
- } elseif($format == 2) {
341
- return 'GLS';
342
- } elseif($format == 3) {
343
  return 'GLS';
344
- } elseif($format == 4) {
345
- return 'smartsendgls';
346
  }
347
  break;
348
  case 'bring':
349
  if($format == 0) {
350
- return 'Bring';
351
- } elseif($format == 1) {
352
  return 'bring';
353
- } elseif($format == 2) {
354
- return 'Bring';
355
- } elseif($format == 3) {
356
  return 'Bring';
357
- } elseif($format == 4) {
358
- return 'smartsendbring';
359
  }
360
  break;
361
  default:
362
- //Change this code for each CMS system
363
- throw new Exception('Unable to determine carrier for formatting.');
364
  }
365
-
366
  }
367
 
368
  /**
369
  *
370
- * Get data about 0: shipping carrier, 1: shipping method, 2: shipping name/id, 3: Carrier raw
371
- * Magento example
372
- * 0: gls, 1: pickup, 2: smartsendpostdanmark_pickup, 3: smartsendpostdanmark
373
- * @return array
374
  */
375
- private function renameShipping($shipping_id) {
 
376
 
377
- $shipping_id = strtolower($shipping_id);
378
- $carrier_raw = null;
379
-
380
- // Carrier
381
- if(substr($shipping_id, 0, strlen('smartsendpickup')) === 'smartsendpickup' || substr($shipping_id, 0, strlen('smartsend_pickup')) === 'smartsend_pickup') {
382
- $carrier = $this->getPickupCarrier();
383
- if($carrier == '') {
384
- throw new Exception("Unable to determine carrier for pickup shipping method");
385
- }
386
- $carrier_raw = $this->formatCarrier($carrier,4);
387
- } elseif(substr($shipping_id, 0, strlen('smartsendbring')) === 'smartsendbring' || substr($shipping_id, 0, strlen('smartsend_bring')) === 'smartsend_bring') {
388
- $carrier = 'bring';
389
- $carrier_raw = 'smartsendbring';
390
- } elseif(substr($shipping_id, 0, strlen('smartsendgls')) === 'smartsendgls' || substr($shipping_id, 0, strlen('smartsend_gls')) === 'smartsend_gls') {
391
- $carrier = 'gls';
392
- $carrier_raw = 'smartsendgls';
393
- } elseif(substr($shipping_id, 0, strlen('smartsendpostdanmark')) === 'smartsendpostdanmark' || substr($shipping_id, 0, strlen('smartsend_postdanmark')) === 'smartsend_postdanmark') {
394
- $carrier = 'postdanmark';
395
- $carrier_raw = 'smartsendpostdanmark';
396
- } elseif(substr($shipping_id, 0, strlen('smartsendposten')) === 'smartsendposten' || substr($shipping_id, 0, strlen('smartsend_posten')) === 'smartsend_posten') {
397
- $carrier = 'posten';
398
- $carrier_raw = 'smartsendposten';
399
- } elseif(substr($shipping_id, 0, strlen('vconnect_postnord')) === 'vconnect_postnord' || substr($shipping_id, 0, strlen('vc_postnord')) === 'vc_postnord') {
400
- $carrier = 'postdanmark';
401
- $carrier_raw = 'vconnectpostdanmark';
402
- } elseif(substr($shipping_id, 0, strlen('vconnect_postdanmark')) === 'vconnect_postdanmark' || substr($shipping_id, 0, strlen('vc_postdanmark')) === 'vc_postdanmark') {
403
- $carrier = 'postdanmark';
404
- $carrier_raw = 'vconnectpostdanmark';
405
- } elseif(substr($shipping_id, 0, strlen('vconnect_posten')) === 'vconnect_posten' || substr($shipping_id, 0, strlen('vc_posten')) === 'vc_posten') {
406
- $carrier = 'posten';
407
- $carrier_raw = 'vconnectposten';
408
- } elseif(substr($shipping_id, 0, strlen('vconnect_gls')) === 'vconnect_gls' || substr($shipping_id, 0, strlen('vc_gls')) === 'vc_gls') {
409
- $carrier = 'gls';
410
- $carrier_raw = 'vconnectgls';
411
- } elseif(substr($shipping_id, 0, strlen('vconnect_bring')) === 'vconnect_bring' || substr($shipping_id, 0, strlen('vc_bring')) === 'vc_bring') {
412
- $carrier = 'bring';
413
- $carrier_raw = 'vconnectbring';
414
- } else {
415
- throw new Exception( "Unsupported carrier: " .$shipping_id );
416
- }
417
 
418
- // Method
419
- if(substr($shipping_id, -strlen('pickup')) === 'pickup') {
420
- $method = 'pickup';
421
- } elseif(substr($shipping_id, -strlen('private')) === 'private') {
422
- $method = 'private';
423
- } elseif(substr($shipping_id, -strlen('privatehome')) === 'privatehome') {
424
- $method = 'privatehome';
425
- } elseif(substr($shipping_id, -strlen('commercial')) === 'commercial') {
426
- $method = 'commercial';
427
- } elseif(substr($shipping_id, -strlen('express')) === 'express') {
428
- $method = 'express';
429
- } elseif(substr($shipping_id, -strlen('privatesamsending')) === 'privatesamsending') {
430
- $method = 'privatesamsending';
431
- } elseif(substr($shipping_id, -strlen('privatepriority')) === 'privatepriority') {
432
- $method = 'privatepriority';
433
- } elseif(substr($shipping_id, -strlen('privateeconomy')) === 'privateeconomy') {
434
- $method = 'privateeconomy';
435
- } elseif(substr($shipping_id, -strlen('dpdclassic')) === 'dpdclassic') {
436
- $method = 'dpdclassic';
437
- } elseif(substr($shipping_id, -strlen('dpdguarantee')) === 'dpdguarantee') {
438
- $method = 'dpdguarantee';
439
- } elseif(substr($shipping_id, -strlen('valuemail')) === 'valuemail') {
440
- $method = 'valuemail';
441
- } elseif(substr($shipping_id, -strlen('valuemailfirstclass')) === 'valuemailfirstclass') {
442
- $method = 'valuemailfirstclass';
443
- } elseif(substr($shipping_id, -strlen('valuemaileconomy')) === 'valuemaileconomy') {
444
- $method = 'valuemaileconomy';
445
- } elseif(substr($shipping_id, -strlen('maximail')) === 'maximail') {
446
- $method = 'maximail';
447
- } elseif(substr($shipping_id, -strlen('private_bulksplit')) === 'private_bulksplit') {
448
- $method = 'private_bulksplit';
449
- } elseif(substr($shipping_id, -strlen('privatehome_bulksplit')) === 'privatehome_bulksplit') {
450
- $method = 'privatehome_bulksplit';
451
- } elseif(substr($shipping_id, -strlen('commercial_bulksplit')) === 'commercial_bulksplit') {
452
- $method = 'commercial_bulksplit';
453
- } elseif(substr($shipping_id, -strlen('bestway')) === 'bestway') {
454
- $method = 'pickup';
455
- } elseif(substr($shipping_id, -strlen('postdanmark')) === 'postdanmark') {
456
- $method = 'pickup';
457
- } elseif(substr($shipping_id, -strlen('posten')) === 'posten') {
458
- $method = 'pickup';
459
- } elseif(substr($shipping_id, -strlen('postnord')) === 'postnord') {
460
- $method = 'pickup';
461
- } elseif(substr($shipping_id, -strlen('bring')) === 'bring') {
462
- $method = 'pickup';
463
- } elseif(substr($shipping_id, -strlen('gls')) === 'gls') {
464
- $method = 'pickup';
465
- } else {
466
- throw new Exception('Uanble to determine shipping method.' );
467
- }
468
 
469
- return array($carrier,$method,$shipping_id,$carrier_raw);
470
  }
471
 
472
  /**
473
  *
474
- * Get shipping carrier
475
- * Example: 'postdanmark'
476
- * @return string
477
  */
478
- public function getShippingCarrier() {
479
- $shipping_info = $this->getShippingInfo();
480
-
481
- if(isset($shipping_info[0]) && $shipping_info[0] != '') {
482
- return $shipping_info[0];
 
 
 
 
 
 
483
  } else {
484
- //Change this code for each CMS system
485
- throw new Exception('Unable to determine shipping carrier.');
486
  }
487
 
488
  }
489
 
490
  /**
491
  *
492
- * Get shipping method
493
- * Example: 'pickup'
494
- * @return string
495
  */
496
- public function getShippingMethod() {
497
- $shipping_info = $this->getShippingInfo();
 
498
 
499
- if(isset($shipping_info[1]) && $shipping_info[1] != '') {
500
- return $shipping_info[1];
501
- } else {
502
- //Change this code for each CMS system
503
- throw new Exception('Unable to determine shipping method.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  }
 
 
 
505
  }
506
 
507
  /**
508
  *
509
- * Get shipping name/id
510
- * Example: 'smartsendpostdanmark_pickup'
511
- * @return string
512
  */
513
- public function getShippingName() {
514
- $shipping_info = $this->getShippingInfo();
515
-
516
- if(isset($shipping_info[2]) && $shipping_info[2] != '') {
517
- return $shipping_info[2];
518
  } else {
519
- //Change this code for each CMS system
520
- throw new Exception('Unable to determine shipping id.');
521
  }
522
 
523
  }
524
 
525
  /**
526
  *
527
- * Get raw carrier name/id
528
- * Example: 'smartsendpostdanmark' or 'vconnectpostdanmark'
529
- * @return string
530
  */
531
- public function getShippingCarrierId() {
532
- $shipping_info = $this->getShippingInfo();
 
533
 
534
- if(isset($shipping_info[3]) && $shipping_info[3] != '') {
535
- return $shipping_info[3];
536
- } else {
537
- //Change this code for each CMS system
538
- throw new Exception('Unable to determine carrier id.');
539
- }
 
 
 
 
 
 
 
540
 
541
  }
542
 
543
  /**
544
  *
545
- * Get data about 0: shipping carrier, 1: shipping method, 2: shipping name/id, 3: Carrier raw
546
- * Magento example
547
- * 0: gls, 1: pickup, 2: smartsendpostdanmark_pickup, 3: smartsendpostdanmark
548
- * @return array
549
  */
550
- private function getShippingInfo() {
551
- /* TEST
552
- return array('postdanmark','pickup','smartsendpostdanmark_pickup'); */
553
-
554
- $shipping_id = $this->getShippingId();
555
-
556
- $shipping_info = $this->renameShipping($shipping_id);
557
 
558
- if($this->isReturn() == true) {
559
- $carrier = $this->formatCarrier($shipping_info[0],1);
560
- switch ($carrier) {
561
- case 'postdanmark':
562
- $settings = $this->getSettingsPostdanmark();
563
- $return_shipping_method = $settings['return'];
564
- break;
565
- case 'posten':
566
- $settings = $this->getSettingsPosten();
567
- $return_shipping_method = $settings['return'];
568
- break;
569
- case 'gls':
570
- $settings = $this->getSettingsGls();
571
- $return_shipping_method = $settings['return'];
572
- break;
573
- case 'bring':
574
- $settings = $this->getSettingsBring();
575
- $return_shipping_method = $settings['return'];
576
- break;
577
- default:
578
- //Change this code for each CMS system
579
- throw new Exception('Unable to determine shipping method for return.');
580
  }
581
 
582
- if($return_shipping_method != '') {
583
- $shipping_info = $this->renameShipping($return_shipping_method);
 
 
 
 
 
 
584
  }
585
  }
586
-
587
- return $shipping_info;
588
-
 
 
589
  }
 
 
 
 
590
 
591
  /**
592
  *
593
- * Get unique order reference. Constructed from ordernumber, timestamp and a random number
594
  * @return string
595
- */
596
- private function getOrderReference() {
597
-
598
- return $this->getOrderId()."-".time()."-".rand(9999,10000);
599
-
600
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
 
602
  /**
603
  *
@@ -606,9 +778,9 @@ try{
606
  * for return labels.
607
  * @return array
608
  */
609
- private function getSettingsCarrier() {
610
 
611
- $carrier = $this->formatCarrier($this->getShippingCarrier(),1);
612
  switch ($carrier) {
613
  case 'postdanmark':
614
  $settings = $this->getSettingsPostdanmark();
@@ -635,7 +807,7 @@ try{
635
  * Function to return if waybill id if any
636
  * @return string
637
  */
638
- private function getWaybill($string,$country) {
639
 
640
  //Devide string into array
641
  $array = explode(";", $string);
@@ -670,953 +842,25 @@ try{
670
  }
671
 
672
  }
673
-
674
-
675
- /*****************************************************************************************
676
- * Functions to set order parameters
677
- ****************************************************************************************/
678
-
679
- /**
680
- *
681
- * Set the meta data for the order
682
- */
683
- public function setInfo() {
684
-
685
- $carrier = $this->formatCarrier($this->getShippingCarrier(),1);
686
- $method = $this->getShippingMethod();
687
-
688
- $settings = $this->getSettingsCarrier();
689
- $type = (isset($settings['format']) ? $settings['format'] : null);
690
-
691
- $this->_info = array(
692
- 'orderno' => $this->getOrderId(),
693
- 'type' => $type,
694
- 'reference' => $this->getOrderReference(),
695
- 'carrier' => $carrier,
696
- 'method' => $method,
697
- 'return' => $this->isReturn(),
698
- 'totalprice' => $this->getOrderPriceTotal(),
699
- 'shipprice' => $this->getOrderPriceShipping(),
700
- 'currency' => $this->getOrderPriceCurrency(),
701
- 'test' => $this->_test,
702
- );
703
-
704
- }
705
-
706
- /**
707
- *
708
- * Set the receiver information
709
- */
710
- public function setReceiver() {
711
-
712
- if($this->isSmartSend() == true) {
713
- $this->_receiver = $this->getShippingAddress();
714
- } elseif($this->isVconnect() == true) {
715
- $this->_receiver = $this->getBillingAddress();
716
- } else {
717
- //Change this code for each CMS system
718
- throw new Exception('Unable to set receiver');
719
- }
720
-
721
- }
722
-
723
- /**
724
- *
725
- * Set the sender information
726
- */
727
- public function setSender() {
728
-
729
- $carrier = $this->formatCarrier($this->getShippingCarrier(),1);
730
-
731
- switch ($carrier) {
732
- case 'postdanmark':
733
- $settings = $this->getSettingsPostdanmark();
734
- $sender = array(
735
- 'senderid' => (isset($settings['quickid']) ? $settings['quickid'] : null),
736
- 'company' => null,
737
- 'name1' => null,
738
- 'name2' => null,
739
- 'address1' => null,
740
- 'address2' => null,
741
- 'zip' => null,
742
- 'city' => null,
743
- 'country' => null,
744
- 'sms' => null,
745
- 'mail' => null
746
- );
747
- break;
748
- case 'posten':
749
- $settings = $this->getSettingsPosten();
750
- $sender = array(
751
- 'senderid' => (isset($settings['quickid']) ? $settings['quickid'] : null),
752
- 'company' => null,
753
- 'name1' => null,
754
- 'name2' => null,
755
- 'address1' => null,
756
- 'address2' => null,
757
- 'zip' => null,
758
- 'city' => null,
759
- 'country' => null,
760
- 'sms' => null,
761
- 'mail' => null
762
- );
763
- break;
764
- default:
765
- $sender = array(
766
- 'senderid' => null,
767
- 'company' => null,
768
- 'name1' => null,
769
- 'name2' => null,
770
- 'address1' => null,
771
- 'address2' => null,
772
- 'zip' => null,
773
- 'city' => null,
774
- 'country' => null,
775
- 'sms' => null,
776
- 'mail' => null
777
- );
778
- }
779
-
780
- $this->_sender = $sender;
781
-
782
- }
783
 
784
  /**
785
- *
786
- * Set the agen information
787
- */
788
- public function setAgent() {
789
-
790
- if($this->isPickup() == true) {
791
- $this->_agent = $this->getPickupData();
792
- } else {
793
- $this->_agent = null;
794
  }
795
-
796
- }
797
-
798
- /**
799
- *
800
- * Set the services that is used for the order
801
- */
802
- public function setService() {
803
-
804
- $settings = $this->getSettingsCarrier();
805
-
806
- $this->_service = array(
807
- 'notemail' => ($settings['notemail'] == 1 ? $this->_receiver['mail'] : null),
808
- 'notesms' => ($settings['notesms'] == 1 ? $this->_receiver['sms'] : null),
809
- 'prenote' => $settings['prenote'],
810
- 'prenote_from' => $settings['prenote_from'],
811
- 'prenote_receiver' => ($settings['prenote_receiver'] == '' ? $this->_receiver['mail'] : $settings['prenote_receiver']),
812
- 'prenote_message' => ($settings['prenote_message'] != '' ? $settings['prenote_message'] : null),
813
- 'waybillid' => $this->getWaybill($settings['waybillid'],$this->_receiver['country'])
814
- );
815
-
816
- }
817
-
818
- /**
819
- *
820
- * Set the parcels. Each parcel contains items.
821
- */
822
- public function setParcels() {
823
-
824
- //Get all shipments for the order
825
- $shipments = $this->getShipments();
826
-
827
- if(!empty($shipments)) {
828
- //Go through shipments and check for Track & Trace
829
- foreach($shipments as $shipment) {
830
- if($this->isReturn() == true) {
831
- //Add shipment to order object as a parcel
832
- $this->addShipment($shipment);
833
- } else {
834
- if( !$this->getShipmentTrace($shipment) ) {
835
- //Add shipment to order object as a parcel
836
- $this->addShipment($shipment);
837
- }
838
- }
839
- }
840
-
841
- if(empty($this->_parcels)) {
842
- throw new Exception('No parcels without trace code');
843
- }
844
- } else {
845
- if($this->getUnshippedItems() != null) {
846
- $this->createShipment();
847
- } else {
848
- throw new Exception('No unshipped items');
849
- }
850
  }
851
-
852
- if(empty($this->_parcels)) {
853
- throw new Exception('No parcels to ship');
854
  }
855
-
856
- }
857
-
858
-
859
- /*****************************************************************************************
860
- * CMS dependent functions
861
- ****************************************************************************************/
862
-
863
- /**
864
- *
865
- * Get shipping name/id
866
- * @return string
867
- */
868
- public function getShippingId() {
869
-
870
- /* WooCommerce start */
871
- if($this->_cms == 'woocommerce') {
872
- $line_items_shipping = $this->_order->get_items( 'shipping' );
873
-
874
- if(!empty($line_items_shipping)){
875
- foreach ( $line_items_shipping as $item_id => $item ) {
876
- if( !empty($item['name']) ) {
877
- $shipMethod = esc_html( $item['name'] );
878
- }
879
- if( !empty($item['method_id']) ) {
880
- $shipMethod_id = esc_html( $item['method_id'] );
881
- }
882
- }
883
- }
884
-
885
- return $shipMethod_id; //return unique id of shipping method
886
- } /* WooCommerce end */
887
-
888
- /* Magento start */
889
- if($this->_cms == 'magento') {
890
- $shipMethod_id = $this->_order->getShippingMethod();
891
-
892
- return $shipMethod_id; //return unique id of shipping method
893
- } /* Magento end */
894
-
895
- }
896
-
897
- /**
898
- *
899
- * Get carrier name based on the pickup information.
900
- * Used if the shipping method is 'closest pickup point'
901
- * @return string
902
- */
903
- private function getPickupCarrier() {
904
-
905
- /* WooCommerce start */
906
- if($this->_cms == 'woocommerce') {
907
- $store_pickup = get_post_custom($order->id);
908
- $store_pickup = @unserialize($store_pickup['store_pickup'][0]);
909
- if(!is_array($store_pickup)) $store_pickup = unserialize($store_pickup);
910
-
911
- if(!empty($store_pickup) && isset($store_pickup['carrier'])){
912
- return $store_pickup['carrier'];
913
- } else {
914
- return null;
915
- }
916
- } /* WooCommerce end */
917
-
918
- /* Magento start */
919
- if($this->_cms == 'magento') {
920
- $pickupModel = Mage::getModel('logistics/pickup');
921
- $pickupData = $pickupModel->getCollection()->addFieldToFilter('order_id', $this->_order->getOrderId() )->getFirstItem(); //pickup data
922
- if ($pickupData->getData()) {
923
- $carrier = $pickupData->getCarrier();
924
- } else {
925
- $carrier = null;
926
- }
927
- } /* Magento end */
928
-
929
- }
930
-
931
- /**
932
- *
933
- * Get the order id
934
- * @return string
935
- */
936
- private function getOrderId() {
937
-
938
- /* WooCommerce start */
939
- if($this->_cms == 'woocommerce') {
940
- return $this->_order->id;
941
- } /* WooCommerce end */
942
-
943
- /* Magento start */
944
- if($this->_cms == 'magento') {
945
- return $this->_order->getIncrementId();
946
- } /* Magento end */
947
- }
948
-
949
- /**
950
- *
951
- * Get total price of order including tax
952
- * @return float
953
- */
954
- private function getOrderPriceTotal() {
955
-
956
- /* WooCommerce start */
957
- if($this->_cms == 'woocommerce') {
958
- return $this->_order->get_total();
959
- } /* WooCommerce end */
960
-
961
- /* Magento start */
962
- if($this->_cms == 'magento') {
963
- return $this->_order->getGrandTotal();
964
- } /* Magento end */
965
- }
966
-
967
- /**
968
- *
969
- * Get shipping costs including tax
970
- * @return float
971
- */
972
- private function getOrderPriceShipping() {
973
-
974
- /* WooCommerce start */
975
- if($this->_cms == 'woocommerce') {
976
- return $this->_order->get_total_shipping();
977
- } /* WooCommerce end */
978
-
979
- /* Magento start */
980
- if($this->_cms == 'magento') {
981
- return $this->_order->getShippingAmount();
982
- } /* Magento end */
983
- }
984
-
985
- /**
986
- *
987
- * Get the currency used for the order
988
- * @return string
989
- */
990
- private function getOrderPriceCurrency() {
991
-
992
- /* WooCommerce start */
993
- if($this->_cms == 'woocommerce') {
994
- return $this->_order->get_order_currency();
995
- } /* WooCommerce end */
996
-
997
- /* Magento start */
998
- if($this->_cms == 'magento') {
999
- return $this->_order->getOrderCurrencyCode();
1000
- } /* Magento end */
1001
- }
1002
-
1003
- /**
1004
- *
1005
- * Get the shipping address information
1006
- * @return array
1007
- */
1008
- private function getShippingAddress() {
1009
-
1010
- /* WooCommerce start */
1011
- if($this->_cms == 'woocommerce') {
1012
- return array(
1013
- 'receiverid'=> $this->_order->user_id,
1014
- 'company' => $this->_order->shipping_company,
1015
- 'name1' => $this->_order->shipping_first_name .' '. $this->_order->shipping_last_name,
1016
- 'name2' => null,
1017
- 'address1' => $this->_order->shipping_address_1,
1018
- 'address2' => $this->_order->shipping_address_2,
1019
- 'city' => $this->_order->shipping_city,
1020
- 'zip' => $this->_order->shipping_postcode,
1021
- 'country' => $this->_order->shipping_country,
1022
- 'sms' => $this->_order->billing_phone, // Billing used
1023
- 'mail' => $this->_order->billing_email // Billing used
1024
- );
1025
- } /* WooCommerce end */
1026
-
1027
- /* Magento start */
1028
- if($this->_cms == 'magento') {
1029
- return array(
1030
- 'receiverid'=> $this->_order->getShippingAddress()->getId(),
1031
- 'company' => $this->_order->getShippingAddress()->getCompany(),
1032
- 'name1' => $this->_order->getShippingAddress()->getFirstname() .' '. $this->_order->getShippingAddress()->getLastname(),
1033
- 'name2' => null,
1034
- 'address1' => $this->_order->getShippingAddress()->getStreet(1),
1035
- 'address2' => $this->_order->getShippingAddress()->getStreet(2),
1036
- 'city' => $this->_order->getShippingAddress()->getCity(),
1037
- 'zip' => $this->_order->getShippingAddress()->getPostcode(),
1038
- 'country' => $this->_order->getShippingAddress()->getCountry_id(),
1039
- 'sms' => $this->_order->getShippingAddress()->getTelephone(),
1040
- 'mail' => $this->_order->getShippingAddress()->getEmail()
1041
- );
1042
- } /* Magento end */
1043
- }
1044
-
1045
- /**
1046
- *
1047
- * Get the shipping address information
1048
- * @return array
1049
- */
1050
- private function getBillingAddress() {
1051
-
1052
- /* WooCommerce start */
1053
- if($this->_cms == 'woocommerce') {
1054
- return array(
1055
- 'receiverid'=> $this->_order->user_id,
1056
- 'company' => $this->_order->billing_company,
1057
- 'name1' => $this->_order->billing_first_name .' '. $this->_order->billing_last_name,
1058
- 'name2' => null,
1059
- 'address1' => $this->_order->billing_address_1,
1060
- 'address2' => $this->_order->billing_address_2,
1061
- 'city' => $this->_order->billing_city,
1062
- 'zip' => $this->_order->billing_postcode,
1063
- 'country' => $this->_order->billing_country,
1064
- 'sms' => $this->_order->billing_phone, // Billing used
1065
- 'mail' => $this->_order->billing_email // Billing used
1066
- );
1067
- } /* WooCommerce end */
1068
-
1069
- /* Magento start */
1070
- if($this->_cms == 'magento') {
1071
- return array(
1072
- 'receiverid'=> $this->_order->getBillingAddress()->getId(),
1073
- 'company' => $this->_order->getBillingAddress()->getCompany(),
1074
- 'name1' => $this->_order->getBillingAddress()->getFirstname() .' '. $this->_order->getBillingAddress()->getLastname(),
1075
- 'name2' => null,
1076
- 'address1' => $this->_order->getBillingAddress()->getStreet(1),
1077
- 'address2' => $this->_order->getBillingAddress()->getStreet(2),
1078
- 'city' => $this->_order->getBillingAddress()->getCity(),
1079
- 'zip' => $this->_order->getBillingAddress()->getPostcode(),
1080
- 'country' => $this->_order->getBillingAddress()->getCountry_id(),
1081
- 'sms' => $this->_order->getBillingAddress()->getTelephone(),
1082
- 'mail' => $this->_order->getBillingAddress()->getEmail()
1083
- );
1084
- } /* Magento end */
1085
- }
1086
-
1087
- /**
1088
- *
1089
- * Get pickup data for a SmartSend delivery point
1090
- * @return array
1091
- */
1092
- private function getPickupDataSmartsend() {
1093
-
1094
- /* WooCommerce start */
1095
- if($this->_cms == 'woocommerce') {
1096
- $store_pickup = get_post_custom($order->id);
1097
- $store_pickup = @unserialize($store_pickup['store_pickup'][0]);
1098
- if(!is_array($store_pickup)) $store_pickup = unserialize($store_pickup);
1099
-
1100
- if(!empty($store_pickup)){
1101
-
1102
- return array(
1103
- 'id' => (isset($store_pickup['id']) ? $store_pickup['id'] : 0)."-".time()."-".rand(9999,10000),
1104
- 'agentno' => (isset($store_pickup['id']) ? $store_pickup['id'] : null),
1105
- 'agenttype' => ($this->getShippingCarrier() == 'postdanmark' ? 'PDK' : null),
1106
- 'company' => (isset($store_pickup['company']) ? $store_pickup['company'] : null),
1107
- 'name1' => null,
1108
- 'name2' => null,
1109
- 'address1' => (isset($store_pickup['street']) ? $store_pickup['street'] : null),
1110
- 'address2' => null,
1111
- 'city' => (isset($store_pickup['city']) ? $store_pickup['city'] : null),
1112
- 'zip' => (isset($store_pickup['zip']) ? $store_pickup['zip'] : null),
1113
- 'country' => (isset($store_pickup['country']) ? $store_pickup['country'] : null),
1114
- 'sms' => null,
1115
- 'mail' => null,
1116
- );
1117
-
1118
- } else {
1119
- return null;
1120
- }
1121
- } /* WooCommerce end */
1122
-
1123
- /* Magento start */
1124
- if($this->_cms == 'magento') {
1125
-
1126
- $carrier = $this->formatCarrier($this->getShippingCarrier(),1);
1127
- switch ($carrier) {
1128
- case 'postdanmark':
1129
- $pickupModel = Mage::getModel('logistics/postdanmark');
1130
- break;
1131
- case 'posten':
1132
- $pickupModel = Mage::getModel('logistics/posten');
1133
- break;
1134
- case 'gls':
1135
- $pickupModel = Mage::getModel('logistics/gls');
1136
- break;
1137
- case 'bring':
1138
- $pickupModel = Mage::getModel('logistics/bring');
1139
- break;
1140
- default:
1141
- //Change this code for each CMS system
1142
- throw new Exception('Unable to get pickup data for Smart Send shipping method.');
1143
- }
1144
-
1145
- $order_id = $this->_order->getId(); //order id
1146
- $pickupData = $pickupModel->getCollection()->addFieldToFilter('order_id', $order_id)->getFirstItem(); //pickup data
1147
-
1148
- if ($pickupData->getData()) {
1149
-
1150
- return array(
1151
- 'id' => $pickupData->getPickUpId()."-".time()."-".rand(9999,10000),
1152
- 'agentno' => $pickupData->getPickUpId(),
1153
- 'agenttype' => ($this->getShippingCarrier() == 'postdanmark' ? 'PDK' : null),
1154
- 'company' => $pickupData->getCompany(),
1155
- 'name1' => null,
1156
- 'name2' => null,
1157
- 'address1' => $pickupData->getStreet(),
1158
- 'address2' => null,
1159
- 'city' => $pickupData->getCity(),
1160
- 'zip' => $pickupData->getZip(),
1161
- 'country' => $pickupData->getCountry(),
1162
- 'sms' => null,
1163
- 'mail' => null,
1164
- );
1165
-
1166
- } else {
1167
- return null;
1168
- }
1169
- } /* Magento end */
1170
  }
1171
-
1172
- /**
1173
- *
1174
- * Get the settings for Post Danmark
1175
- * @return array
1176
- */
1177
- private function getSettingsPostdanmark() {
1178
-
1179
- /* WooCommerce start */
1180
- if($this->_cms == 'woocommerce') {
1181
- $postdanmark = new Smartsend_Logistics_PostDanmark();
1182
- return array(
1183
- 'notemail' => ($postdanmark->get_option( 'notemail','yes') == 'yes' ? true : null),
1184
- 'notesms' => ($postdanmark->get_option( 'notesms','yes') == 'yes' ? true : null),
1185
- 'prenote' => ($postdanmark->get_option( 'prenote','yes') == 'yes' ? true : false),
1186
- 'prenote_from' => $postdanmark->get_option( 'prenote_sender',''),
1187
- 'prenote_receiver' => $postdanmark->get_option( 'prenote_receiver','user'),
1188
- 'prenote_message' => $postdanmark->get_option( 'prenote_message',''),
1189
- 'format' => $postdanmark->get_option( 'format','pdf'),
1190
- 'quickid' => $postdanmark->get_option( 'quickid','1'),
1191
- 'waybillid' => $postdanmark->get_option( 'waybillid',''),
1192
- 'return' => $postdanmark->get_option( 'return',''),
1193
- );
1194
- } /* WooCommerce end */
1195
-
1196
- /* Magento start */
1197
- if($this->_cms == 'magento') {
1198
- return array(
1199
- 'notemail' => Mage::getStoreConfig('carriers/smartsendpostdanmark/notemail'),
1200
- 'notesms' => Mage::getStoreConfig('carriers/smartsendpostdanmark/notesms'),
1201
- 'prenote' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote'),
1202
- 'prenote_from' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote_sender'),
1203
- 'prenote_receiver' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote_receiver'),
1204
- 'prenote_message' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote_message'),
1205
- 'format' => Mage::getStoreConfig('carriers/smartsendpostdanmark/format'),
1206
- 'quickid' => Mage::getStoreConfig('carriers/smartsendpostdanmark/quickid'),
1207
- 'waybillid' => Mage::getStoreConfig('carriers/smartsendpostdanmark/waybillid'),
1208
- 'return' => Mage::getStoreConfig('carriers/smartsendpostdanmark/return'),
1209
- );
1210
- } /* Magento end */
1211
- }
1212
-
1213
- /**
1214
- *
1215
- * Get the settings for Posten
1216
- * @return array
1217
- */
1218
- private function getSettingsPosten() {
1219
-
1220
- /* WooCommerce start */
1221
- if($this->_cms == 'woocommerce') {
1222
- $posten = new Smartsend_Logistics_Posten();
1223
- return array(
1224
- 'notemail' => ($posten->get_option( 'notemail','yes') == 'yes' ? true : null),
1225
- 'notesms' => ($posten->get_option( 'notesms','yes') == 'yes' ? true : null),
1226
- 'prenote' => ($posten->get_option( 'prenote','yes') == 'yes' ? true : false),
1227
- 'prenote_from' => $posten->get_option( 'prenote_sender',''),
1228
- 'prenote_receiver' => $posten->get_option( 'prenote_receiver','user'),
1229
- 'prenote_message' => $posten->get_option( 'prenote_message',''),
1230
- 'format' => $posten->get_option( 'format','pdf'),
1231
- 'quickid' => $posten->get_option( 'quickid','1'),
1232
- 'waybillid' => $posten->get_option( 'waybillid',''),
1233
- 'return' => $posten->get_option( 'return',''),
1234
- );
1235
- } /* WooCommerce end */
1236
-
1237
- /* Magento start */
1238
- if($this->_cms == 'magento') {
1239
- return array(
1240
- 'notemail' => Mage::getStoreConfig('carriers/smartsendposten/notemail'),
1241
- 'notesms' => Mage::getStoreConfig('carriers/smartsendposten/notesms'),
1242
- 'prenote' => Mage::getStoreConfig('carriers/smartsendposten/prenote'),
1243
- 'prenote_from' => Mage::getStoreConfig('carriers/smartsendposten/prenote_sender'),
1244
- 'prenote_receiver' => Mage::getStoreConfig('carriers/smartsendposten/prenote_receiver'),
1245
- 'prenote_message' => Mage::getStoreConfig('carriers/smartsendposten/prenote_message'),
1246
- 'format' => Mage::getStoreConfig('carriers/smartsendposten/format'),
1247
- 'quickid' => Mage::getStoreConfig('carriers/smartsendposten/quickid'),
1248
- 'waybillid' => Mage::getStoreConfig('carriers/smartsendposten/waybillid'),
1249
- 'return' => Mage::getStoreConfig('carriers/smartsendposten/return'),
1250
- );
1251
- } /* Magento end */
1252
- }
1253
-
1254
- /**
1255
- *
1256
- * Get the settings for GLS
1257
- * @return array
1258
- */
1259
- private function getSettingsGls() {
1260
-
1261
- /* WooCommerce start */
1262
- if($this->_cms == 'woocommerce') {
1263
- $gls = new Smartsend_Logistics_GLS();
1264
- return array(
1265
- 'notemail' => ($gls->get_option( 'notemail','yes') == 'yes' ? true : null),
1266
- 'notesms' => ($gls->get_option( 'notesms','yes') == 'yes' ? true : null),
1267
- 'prenote' => null,
1268
- 'prenote_from' => null,
1269
- 'prenote_receiver' => null,
1270
- 'prenote_message' => null,
1271
- 'format' => null,
1272
- 'quickid' => null,
1273
- 'waybillid' => null,
1274
- 'return' => $gls->get_option( 'return',''),
1275
- );
1276
- } /* WooCommerce end */
1277
-
1278
- /* Magento start */
1279
- if($this->_cms == 'magento') {
1280
- return array(
1281
- 'notemail' => Mage::getStoreConfig('carriers/smartsendgls/notemail'),
1282
- 'notesms' => Mage::getStoreConfig('carriers/smartsendgls/notesms'),
1283
- 'prenote' => null,
1284
- 'prenote_from' => null,
1285
- 'prenote_receiver' => null,
1286
- 'prenote_message' => null,
1287
- 'format' => null,
1288
- 'quickid' => null,
1289
- 'waybillid' => null,
1290
- 'return' => Mage::getStoreConfig('carriers/smartsendgls/return'),
1291
- );
1292
- } /* Magento end */
1293
- }
1294
-
1295
- /**
1296
- *
1297
- * Get the settings for Bring
1298
- * @return array
1299
- */
1300
- private function getSettingsBring() {
1301
-
1302
- /* WooCommerce start */
1303
- if($this->_cms == 'woocommerce') {
1304
- $bring = new Smartsend_Logistics_Bring();
1305
- return array(
1306
- 'notemail' => ($bring->get_option( 'notemail','yes') == 'yes' ? true : null),
1307
- 'notesms' => ($bring->get_option( 'notesms','yes') == 'yes' ? true : null),
1308
- 'prenote' => null,
1309
- 'prenote_from' => null,
1310
- 'prenote_receiver' => null,
1311
- 'prenote_message' => null,
1312
- 'format' => null,
1313
- 'quickid' => null,
1314
- 'waybillid' => null,
1315
- 'return' => $bring->get_option( 'return',''),
1316
- );
1317
- } /* WooCommerce end */
1318
-
1319
- /* Magento start */
1320
- if($this->_cms == 'magento') {
1321
- return array(
1322
- 'notemail' => Mage::getStoreConfig('carriers/smartsendbring/notemail'),
1323
- 'notesms' => Mage::getStoreConfig('carriers/smartsendbring/notesms'),
1324
- 'prenote' => null,
1325
- 'prenote_from' => null,
1326
- 'prenote_receiver' => null,
1327
- 'prenote_message' => null,
1328
- 'format' => null,
1329
- 'quickid' => null,
1330
- 'waybillid' => null,
1331
- 'return' => Mage::getStoreConfig('carriers/smartsendbring/return'),
1332
- );
1333
- } /* Magento end */
1334
- }
1335
-
1336
- /* CMS FUNCTIONS ABOUT PARCELS AND SHIPMENTS */
1337
-
1338
- /**
1339
- *
1340
- * Get the Track&Trace code for a given shipment
1341
- * @return string
1342
- */
1343
- private function getShipmentTrace($shipment) {
1344
-
1345
- /* WooCommerce start */
1346
- if($this->_cms == 'woocommerce') {
1347
- return false;
1348
- } /* WooCommerce end */
1349
-
1350
- /* Magento start */
1351
- if($this->_cms == 'magento') {
1352
- $tracknums = array();
1353
- foreach($shipment->getAllTracks() as $tracknum) {
1354
- $tracknums[]=$tracknum->getNumber();
1355
- }
1356
-
1357
- if(empty($tracknums)) {
1358
- return false;
1359
- } else {
1360
- return true;
1361
- }
1362
- } /* Magento end */
1363
- }
1364
-
1365
- /**
1366
- *
1367
- * Get the weight (in kg) of a given shipment
1368
- * @return float
1369
- */
1370
- private function getShipmentWeight($shipment) {
1371
-
1372
- /* WooCommerce start */
1373
- if($this->_cms == 'woocommerce') {
1374
- $weight = 0;
1375
- foreach($shipment as $eachShipmentItem) {
1376
- $itemWeight = $eachShipmentItem['unitweight'];
1377
- $itemQty = $eachShipmentItem['quantity'];
1378
- $rowWeight = $itemWeight*$itemQty;
1379
-
1380
- $weight = $weight + $rowWeight;
1381
- }
1382
- } /* WooCommerce end */
1383
-
1384
- /* Magento start */
1385
- if($this->_cms == 'magento') {
1386
- $weight = 0;
1387
- foreach($shipment->getAllItems() as $eachShipmentItem) {
1388
- $itemWeight = $eachShipmentItem->getWeight();
1389
- $itemQty = $eachShipmentItem->getQty();
1390
- $rowWeight = $itemWeight*$itemQty;
1391
-
1392
- $weight = $weight + $rowWeight;
1393
- }
1394
- } /* Magento end */
1395
-
1396
- /* All */
1397
- if($weight > 0) {
1398
- return $weight;
1399
- } else {
1400
- return null;
1401
- }
1402
- }
1403
-
1404
- /**
1405
- *
1406
- * Get the shipments for the order if any
1407
- * @return array
1408
- */
1409
- private function getShipments() {
1410
-
1411
- /* WooCommerce start */
1412
- if($this->_cms == 'woocommerce') {
1413
- return null;
1414
- } /* WooCommerce end */
1415
-
1416
- /* Magento start */
1417
- if($this->_cms == 'magento') {
1418
- if( $this->_order->hasShipments() ) {
1419
- return $this->_order->getShipmentsCollection();
1420
- } else {
1421
- return null;
1422
- }
1423
- } /* Magento end */
1424
- }
1425
-
1426
- /**
1427
- *
1428
- * Add a shipment to the request
1429
- */
1430
- private function addShipment($shipment) {
1431
-
1432
- /* WooCommerce start */
1433
- if($this->_cms == 'woocommerce') {
1434
- $this->_parcels[] = $shipment;
1435
- } /* WooCommerce end */
1436
-
1437
- /* Magento start */
1438
- if($this->_cms == 'magento') {
1439
- $parcel = array(
1440
- 'shipdate' => null,
1441
- 'reference' => $shipment->getId(),
1442
- 'weight' => $this->getShipmentWeight($shipment),
1443
- 'height' => null,
1444
- 'width' => null,
1445
- 'length' => null,
1446
- 'size' => null,
1447
- 'freetext1' => null,
1448
- 'freetext2' => null,
1449
- 'freetext3' => null,
1450
- 'items' => array(),
1451
- );
1452
-
1453
- $ordered_items = $shipment->getAllItems();
1454
- foreach($ordered_items as $item) {
1455
- $parcel['items'][] = $this->addItem($item);
1456
- }
1457
-
1458
- $this->_parcels[] = $parcel;
1459
- } /* Magento end */
1460
- }
1461
-
1462
- /**
1463
- *
1464
- * Format an item to be added to a parcel
1465
- * @return array
1466
- */
1467
- private function addItem($item) {
1468
-
1469
- /* Magento start */
1470
- if($this->_cms == 'magento') {
1471
- return array(
1472
- 'sku' => $item->getSku(),
1473
- 'title' => $item->getName(),
1474
- 'quantity' => $item->getQty(),
1475
- 'unitweight'=> $item->getWeight(),
1476
- 'unitprice' => $item->getPrice(),
1477
- 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode()
1478
- );
1479
- // $item->getItemId(); //product id
1480
- } /* Magento end */
1481
- }
1482
-
1483
- /**
1484
- *
1485
- * Get the unshipped items of the order
1486
- * @return array
1487
- */
1488
- private function getUnshippedItems() {
1489
-
1490
- /* WooCommerce start */
1491
- if($this->_cms == 'woocommerce') {
1492
- $ordered_items = $this->_order->get_items();
1493
- foreach($ordered_items as $item) {
1494
- $_product = $this->_order->get_product_from_item( $item );
1495
- if ( ! $_product->is_virtual() ) {
1496
- $weight = $_product->get_weight();
1497
- } else {
1498
- $weight = null;
1499
- }
1500
-
1501
- $items[] = array(
1502
- 'sku' => ($_product->get_sku() != '' ? $_product->get_sku() : null),
1503
- 'title' => ($_product->get_title() != '' ? $_product->get_title() : null),
1504
- 'quantity' => $item['qty'],
1505
- 'unitweight'=> ($weight != '' ? $weight : null),
1506
- 'unitprice' => $_product->get_price(),
1507
- 'currency' => get_woocommerce_currency()
1508
- );
1509
- }
1510
- } /* WooCommerce end */
1511
-
1512
- /* Magento start */
1513
- if($this->_cms == 'magento') {
1514
- $items = array();
1515
- foreach($this->_order->getAllItems() as $eachOrderItem){
1516
- $Itemqty = 0;
1517
- $Itemqty = $eachOrderItem->getQtyOrdered()
1518
- - $eachOrderItem->getQtyShipped()
1519
- - $eachOrderItem->getQtyRefunded()
1520
- - $eachOrderItem->getQtyCanceled();
1521
- if($Itemqty > 0) {
1522
- $items[$eachOrderItem->getId()] = $Itemqty;
1523
- }
1524
- }
1525
- } /* Magento end */
1526
-
1527
- /* All */
1528
- if(!empty($items)) {
1529
- return $items;
1530
- } else {
1531
- return null;
1532
- }
1533
-
1534
- }
1535
-
1536
- /**
1537
- *
1538
- * Create a parcel containing all unshipped items.
1539
- * Add the parcel to the request.
1540
- */
1541
- private function createShipment() {
1542
-
1543
- /* WooCommerce start */
1544
- if($this->_cms == 'woocommerce') {
1545
- //create and object, $shipment, with all items
1546
- if ( sizeof( $this->_order->get_items() ) > 0 ) {
1547
- $shipment = array(
1548
- 'shipdate' => null,
1549
- 'reference' => $this->_order->id,
1550
- 'weight' => $this->getShipmentWeight($this->getUnshippedItems()),
1551
- 'height' => null,
1552
- 'width' => null,
1553
- 'length' => null,
1554
- 'size' => null,
1555
- 'freetext1' => null,
1556
- 'freetext2' => null,
1557
- 'freetext3' => null,
1558
- 'items' => $this->getUnshippedItems()
1559
- );
1560
- } else {
1561
- //Order has no shipments and cannot be shipped
1562
- throw new Exception(__("No items that could be shipped"));
1563
- }
1564
- } /* WooCommerce end */
1565
-
1566
- /* Magento start */
1567
- if($this->_cms == 'magento') {
1568
- $order = $this->_order;
1569
- $qty = $this->getUnshippedItems();
1570
-
1571
- /* check order shipment is prossiable or not */
1572
-
1573
- $email = false;
1574
- $includeComment = false;
1575
- $comment = "";
1576
-
1577
- if ($order->canShip()) {
1578
- // @var $shipment Mage_Sales_Model_Order_Shipment
1579
- // prepare to create shipment
1580
- $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($qty);
1581
- if ($shipment) {
1582
- $shipment->register();
1583
-
1584
- //Add a comment. Second parameter is whether or not to email the comment to the user
1585
- $shipment->addComment($comment, $email && $includeComment);
1586
-
1587
- // Set the order status as 'Processing'
1588
- $order->setIsInProcess($email);
1589
- $order->addStatusHistoryComment('Label generated by Smart Send Logistics.', false);
1590
-
1591
- try {
1592
- $transactionSave = Mage::getModel('core/resource_transaction')
1593
- ->addObject($shipment)
1594
- ->addObject($order)
1595
- ->save();
1596
-
1597
- //Email the customer that the order is sent
1598
- $shipment->sendEmail($email, ($includeComment ? $comment : ''));
1599
-
1600
- //Set order status as complete
1601
- //$order->setData('state', Mage_Sales_Model_Order::STATE_COMPLETE);
1602
- //$order->setData('status', Mage_Sales_Model_Order::STATE_COMPLETE);
1603
- //$order->save();
1604
-
1605
- //var_dump($qty); exit();
1606
- } catch (Mage_Core_Exception $e) {
1607
- throw new Exception(Mage::helper('logistics')->__("Error while creating parcel: ".$e));
1608
- }
1609
- }
1610
- }
1611
-
1612
- } /* Magento end */
1613
-
1614
- /* All */
1615
- if ($shipment) {
1616
- //Lastly add the shipment to the order array.
1617
- $this->addShipment($shipment);
1618
- }
1619
-
1620
- }
1621
 
1622
  }
1
  <?php
2
 
3
  /**
4
+ * Smartsend_Logistics Order class
5
+ *
6
+ * Create order objects that is included in the final Smart Send label API callout.
7
+ *
8
+ * LICENSE
9
  *
10
  * This source file is subject to the GNU General Public License v3.0
11
  * that is bundled with this package in the file license.txt.
21
  * versions in the future. If you wish to customize the plugin for your
22
  * needs please refer to http://www.smartsend.dk
23
  *
24
+ * @class Smartsend_Logistics_Model_Order
25
  * @folder /app/code/community/Smartsend/Logistics/Model/Order.php
26
  * @category Smartsend
27
  * @package Smartsend_Logistics
28
+ * @author Smart Send
29
  * @url www.smartsend.dk
30
+ * @version 7.1.0
31
+ *
32
+ * // Overall functions
33
+ * public function _construct()
34
+ * public function setOrderObject($order_object)
35
+ * public function setReturn($return=false)
36
+ * public function getFinalOrder()
37
+ *
38
+ * // Logical functions
39
+ * public function isSmartsendOrVConnect()
40
+ * public function isPickup()
41
+ * public function isReturn()
42
+ * public function isSmartsend()
43
+ * public function isVconnect()
44
+ * public function isPickupSmartsend()
45
+ * public function isPickupVconnect()
46
+ * public function isSmartDelivery()
47
+ *
48
+ * // Shipping functions
49
+ * protected function getShippingCarrierAndMethod()
50
+ * protected function renameShippingCarrier($shipping_string)
51
+ * protected function renameShippingMethod($shipping_string)
52
+ * public function getShippingCarrier($format=0)
53
+ * public function getShippingMethod()
54
+ *
55
+ * // Order set functions
56
+ * public function setInfo()
57
+ * public function setReceiver()
58
+ * public function setSender()
59
+ * public function setAgent()
60
+ * public function setService()
61
+ * public function setParcels()
62
+ *
63
+ * // Order get functions
64
+ * public function getPickupId()
65
+ * public function getPickupData()
66
+ * public function getSettingsCarrier()
67
+ * public function getWaybill($string,$country)
68
+ * protected function getFreetext()
69
+ *
70
+ *
71
+ * // This class is called by using the code:
72
+ * $order = new Smartsend_Logistics_Order();
73
+ * $order->setOrderObject($order_object);
74
+ * $order->setReturn(true);
75
+ * try{
76
+ * $order->setInfo();
77
+ * $order->setReceiver();
78
+ * $order->setSender();
79
+ * $order->setAgent();
80
+ * $order->setService();
81
+ * $order->setParcels();
82
+ *
83
+ * //All done. Add to request.
84
+ * $request_array[] = $order->getFinalOrder();
85
+ * } catch (Exception $e) {
86
+ * echo 'Caught exception: ', $e->getMessage(), "\n";
87
+ * }
88
+ *
89
+ */
90
 
91
  class Smartsend_Logistics_Model_Order extends Mage_Core_Model_Abstract {
92
 
93
+ protected $_order;
94
+ protected $_info;
95
+ protected $_receiver;
96
+ protected $_sender;
97
+ protected $_agent;
98
+ protected $_service;
99
+ protected $_parcels = array();
100
+ protected $_return = false;
 
 
 
 
101
 
102
+ protected $_test = false;
 
 
 
 
103
 
104
+ /*****************************************************************************************
105
+ * Overall functions
106
+ ****************************************************************************************/
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  /**
109
  *
110
  * Set the order object
111
+ * @param object $order_object order object
112
  */
113
  public function setOrderObject($order_object) {
114
  $this->_order = $order_object;
117
  /**
118
  *
119
  * Set wheter or not the label is a return label
120
+ * @param boolean $return wheter or not the label is a return label
121
  */
122
  public function setReturn($return=false) {
123
  $this->_return = $return;
140
 
141
 
142
  /*****************************************************************************************
143
+ * Logical functions: Functions to return true/false for different statements
144
  ****************************************************************************************/
145
 
146
  /**
148
  * Check if order is placed by a SmartSend or a vConnect shipping method
149
  * @return boolean
150
  */
151
+ public function isSmartsendOrVConnect() {
152
 
153
  if($this->isSmartsend() == true) {
154
  return true;
164
  * Check if order is a pickup shipping method from SmartSend or vConnect
165
  * @return boolean
166
  */
167
+ public function isPickup() {
168
 
169
  if($this->isPickupSmartsend() == true) {
170
  return true;
181
  * Check if the label is a return label for the order
182
  * @return boolean
183
  */
184
+ public function isReturn() {
185
  return $this->_return;
186
  }
187
 
 
 
 
 
 
188
  /**
189
  *
190
  * Check if order is placed by a SmartSend shipping method
191
  * @return boolean
192
  */
193
+ public function isSmartsend() {
194
 
195
+ $method = strtolower($this->getShippingId());
196
 
197
  //Check if shipping methode starts with 'smartsend'
198
  if(substr($method, 0, strlen('smartsend')) === 'smartsend') {
208
  * Check if order is placed by a vConnect shipping method
209
  * @return boolean
210
  */
211
+ public function isVconnect() {
212
 
213
+ $method = strtolower($this->getShippingId());
214
 
215
  //Check if shipping methode starts with 'vconnect' or 'vc'
216
  if(substr($method, 0, strlen('vconnect')) === 'vconnect') {
228
  * Check if order is a pickup shipping method from SmartSend
229
  * @return boolean
230
  */
231
+ public function isPickupSmartsend() {
232
 
233
  if($this->isSmartsend() == true) {
234
  $method = $this->getShippingMethod();
250
  * Check if order is a pickup shipping method from vConnect
251
  * @return boolean
252
  */
253
+ public function isPickupVconnect() {
254
 
255
  if($this->isVconnect() == true) {
256
  $method = $this->getShippingMethod();
265
  return false;
266
  }
267
  }
268
+
269
  /**
270
  *
271
+ * Check if Smart Delivery is active
272
+ * @return boolean
273
  */
274
+ public function isSmartDelivery() {
 
 
 
275
 
276
+ false;
277
+
278
  }
279
+
280
+ /*****************************************************************************************
281
+ * Shipping functions
282
+ ****************************************************************************************/
283
+
284
  /**
285
  *
286
+ * Get shipping carrier and method
287
+ * 0: @string shipping carrier. Example: 'postdanmark'
288
+ * 1: @string shipping method. Example: 'private'
289
  * @return array
290
+ */
291
+ protected function getShippingCarrierAndMethod() {
292
+
293
+ // Retreive unique shipping id. Example: 'postdanmark_private'
294
+ $shipping_string = $this->getShippingId();
295
+
296
+ $carrier = $this->renameShippingCarrier($shipping_string);
297
+ $method = $this->renameShippingMethod($shipping_string);
298
+
299
+ if($this->isReturn() == true) {
300
+ switch ($carrier) {
301
+ case 'postdanmark':
302
+ $settings = $this->getSettingsPostdanmark();
303
+ $shipping_string = $settings['return'];
304
+ break;
305
+ case 'posten':
306
+ $settings = $this->getSettingsPosten();
307
+ $return_shipping_method = $settings['return'];
308
+ break;
309
+ case 'gls':
310
+ $settings = $this->getSettingsGls();
311
+ $return_shipping_method = $settings['return'];
312
+ break;
313
+ case 'bring':
314
+ $settings = $this->getSettingsBring();
315
+ $return_shipping_method = $settings['return'];
316
+ break;
317
+ default:
318
+ //Change this code for each CMS system
319
+ throw new Exception($this->_errors[2301]);
320
+ }
321
+
322
+ // Check if the carrier must be changed
323
+ try{
324
+ $carrier = $this->renameShippingCarrier($shipping_string);
325
+ } catch(Exception $e) {
326
+ // Do nothing if no return shipping carrier is found
327
+ }
328
+
329
+ // Check if the method must be changed
330
+ try{
331
+ $new_method = $this->renameShippingMethod($shipping_string);
332
+ if(isset($new_method) && $new_method != '' && $new_method != 'auto') {
333
+ $method = $new_method;
334
+ }
335
+ } catch(Exception $e) {
336
+ // Do nothing if no return shipping method is found
337
+ }
338
+ }
339
+
340
+ if(!isset($carrier) || $carrier == '') {
341
+ throw new Exception($this->_errors[2302]);
342
+ } elseif(!isset($method) || $method == '') {
343
+ throw new Exception($this->_errors[2303]);
344
  } else {
345
+ return array($carrier,$method);
346
  }
347
+
348
  }
349
 
350
+ /**
351
+ *
352
+ * Find the shipping carrier from a string and return as lower case single word
353
+ * @param string $carrier to be determined. Example: 'smartsendpostdanmark_private' would give 'postdanmark'
354
+ * @return array
355
+ */
356
+ protected function renameShippingCarrier($shipping_string) {
357
 
358
+ $shipping_string = strtolower($shipping_string);
359
 
360
+ // Smart Send shipping methods
361
+ if(substr($shipping_string, 0, strlen('smartsendpickup')) === 'smartsendpickup' || substr($shipping_string, 0, strlen('smartsend_pickup')) === 'smartsend_pickup') {
362
+ $carrier = $this->getPickupCarrier();
363
+ if(!isset($carrier) || $carrier == '') {
364
+ throw new Exception($this->_errors[2304]);
365
+ }
366
+ } elseif(substr($shipping_string, 0, strlen('smartsendbring')) === 'smartsendbring' || substr($shipping_string, 0, strlen('smartsend_bring')) === 'smartsend_bring') {
367
+ $carrier = 'bring';
368
+ } elseif(substr($shipping_string, 0, strlen('smartsendgls')) === 'smartsendgls' || substr($shipping_string, 0, strlen('smartsend_gls')) === 'smartsend_gls') {
369
+ $carrier = 'gls';
370
+ } elseif(substr($shipping_string, 0, strlen('smartsendpostdanmark')) === 'smartsendpostdanmark' || substr($shipping_string, 0, strlen('smartsend_postdanmark')) === 'smartsend_postdanmark') {
371
+ $carrier = 'postdanmark';
372
+ } elseif(substr($shipping_string, 0, strlen('smartsendposten')) === 'smartsendposten' || substr($shipping_string, 0, strlen('smartsend_posten')) === 'smartsend_posten') {
373
+ $carrier = 'posten';
 
 
 
 
 
374
 
375
+ // vConnect All-in-1 module shipping methods
376
+ } elseif(substr($shipping_string, 0, strlen('vconnect_postnord_dk')) === 'vconnect_postnord_dk') {
377
+ $carrier = 'postdanmark';
378
+ } elseif(substr($shipping_string, 0, strlen('vconnect_postnord_se')) === 'vconnect_postnord_se') {
379
+ $carrier = 'posten';
380
+ } elseif(substr($shipping_string, 0, strlen('vconnect_postnord_no')) === 'vconnect_postnord_no') {
381
+ $carrier = 'postnordnorway';
382
+ } elseif(substr($shipping_string, 0, strlen('vconnect_postnord_fi')) === 'vconnect_postnord_fi') {
383
+ $carrier = 'postnordfinland';
384
 
385
+ // Old vConnect shipping methods
386
+ } elseif(substr($shipping_string, 0, strlen('vconnect_postdanmark')) === 'vconnect_postdanmark' || substr($shipping_string, 0, strlen('vc_postdanmark')) === 'vc_postdanmark' || substr($shipping_string, 0, strlen('vc_allinone_vconnectpostdanmark')) === 'vc_allinone_vconnectpostdanmark') {
387
+ $carrier = 'postdanmark';
388
+ } elseif(substr($shipping_string, 0, strlen('vconnect_posten')) === 'vconnect_posten' || substr($shipping_string, 0, strlen('vc_posten')) === 'vc_posten' || substr($shipping_string, 0, strlen('vc_allinone_vconnectposten')) === 'vc_allinone_vconnectposten') {
389
+ $carrier = 'posten';
390
+ } elseif(substr($shipping_string, 0, strlen('vconnect_postnord')) === 'vconnect_postnord' || substr($shipping_string, 0, strlen('vc_postnord')) === 'vc_postnord' || substr($shipping_string, 0, strlen('vc_allinone_vconnectpostnord')) === 'vc_allinone_vconnectpostnord') {
391
+ $carrier = 'postdanmark';
392
+ } elseif(substr($shipping_string, 0, strlen('vconnect_gls')) === 'vconnect_gls' || substr($shipping_string, 0, strlen('vc_gls')) === 'vc_gls') {
393
+ $carrier = 'gls';
394
+ } elseif(substr($shipping_string, 0, strlen('vconnect_bring')) === 'vconnect_bring' || substr($shipping_string, 0, strlen('vc_bring')) === 'vc_bring') {
395
+ $carrier = 'bring';
396
+ } elseif(substr($shipping_string, 0, strlen('vconnect_pdkalpha')) === 'vconnect_pdkalpha') {
397
+ $carrier = 'postdanmark';
398
+
399
+ // If the shipping method is unknown throw an error
400
+ } else {
401
+ throw new Exception( $this->_errors[2305] .': '. $shipping_string );
402
+ }
403
+
404
+ return $carrier;
405
+ }
406
+
407
+ /**
408
+ *
409
+ * Find the shipping method from a string and return as lower case single word
410
+ * @param string $carrier to be determined. Example: 'smartsendpostdanmark_private' would give 'private'
411
+ * @return array
412
+ */
413
+ protected function renameShippingMethod($shipping_string) {
414
+
415
+ $shipping_string = strtolower($shipping_string);
416
+
417
+ if(substr($shipping_string, -strlen('pickup')) === 'pickup') {
418
+ $method = 'pickup';
419
+ } elseif(substr($shipping_string, -strlen('private')) === 'private') {
420
+ $method = 'private';
421
+ } elseif(substr($shipping_string, -strlen('privatehome')) === 'privatehome') {
422
+ $method = 'privatehome';
423
+ } elseif(substr($shipping_string, -strlen('commercial')) === 'commercial') {
424
+ $method = 'commercial';
425
+ } elseif(substr($shipping_string, -strlen('express')) === 'express') {
426
+ $method = 'express';
427
+ } elseif(substr($shipping_string, -strlen('privatesamsending')) === 'privatesamsending') {
428
+ $method = 'privatesamsending';
429
+ } elseif(substr($shipping_string, -strlen('privatepriority')) === 'privatepriority') {
430
+ $method = 'privatepriority';
431
+ } elseif(substr($shipping_string, -strlen('privateeconomy')) === 'privateeconomy') {
432
+ $method = 'privateeconomy';
433
+ } elseif(substr($shipping_string, -strlen('lastmile')) === 'lastmile') {
434
+ $method = 'lastmile';
435
+ } elseif(substr($shipping_string, -strlen('businesspriority')) === 'businesspriority') {
436
+ $method = 'businesspriority';
437
+ } elseif(substr($shipping_string, -strlen('dpdclassic')) === 'dpdclassic') {
438
+ $method = 'dpdclassic';
439
+ } elseif(substr($shipping_string, -strlen('dpdguarantee')) === 'dpdguarantee') {
440
+ $method = 'dpdguarantee';
441
+ } elseif(substr($shipping_string, -strlen('valuemail')) === 'valuemail') {
442
+ $method = 'valuemail';
443
+ } elseif(substr($shipping_string, -strlen('valuemailfirstclass')) === 'valuemailfirstclass') {
444
+ $method = 'valuemailfirstclass';
445
+ } elseif(substr($shipping_string, -strlen('valuemaileconomy')) === 'valuemaileconomy') {
446
+ $method = 'valuemaileconomy';
447
+ } elseif(substr($shipping_string, -strlen('maximail')) === 'maximail') {
448
+ $method = 'maximail';
449
+ } elseif(substr($shipping_string, -strlen('miniparcel')) === 'miniparcel') {
450
+ $method = 'miniparcel';
451
+ } elseif(substr($shipping_string, -strlen('private_bulksplit')) === 'private_bulksplit') {
452
+ $method = 'private_bulksplit';
453
+ } elseif(substr($shipping_string, -strlen('privatehome_bulksplit')) === 'privatehome_bulksplit') {
454
+ $method = 'privatehome_bulksplit';
455
+ } elseif(substr($shipping_string, -strlen('commercial_bulksplit')) === 'commercial_bulksplit') {
456
+ $method = 'commercial_bulksplit';
457
+ } elseif(substr($shipping_string, -strlen('bestway')) === 'bestway') {
458
+ $method = 'pickup';
459
+ } elseif(substr($shipping_string, -strlen('postdanmark')) === 'postdanmark') {
460
+ $method = 'pickup';
461
+ } elseif(substr($shipping_string, -strlen('posten')) === 'posten') {
462
+ $method = 'pickup';
463
+ } elseif(substr($shipping_string, -strlen('postnord')) === 'postnord') {
464
+ $method = 'pickup';
465
+ } elseif(substr($shipping_string, -strlen('bring')) === 'bring') {
466
+ $method = 'pickup';
467
+ } elseif(substr($shipping_string, -strlen('gls')) === 'gls') {
468
+ $method = 'pickup';
469
+ // Support for vConnect shipping method 'pdkalpha'
470
+ } elseif(substr($shipping_string, 0, strlen('vconnect_pdkalpha')) === 'vconnect_pdkalpha') {
471
+ $method = 'lastmile';
472
+ } else {
473
+ // If the shipping method is unknown throw an error
474
+ throw new Exception( $this->_errors[2306] .': '. $shipping_string );
475
  }
476
 
477
+ return $method;
478
+ }
479
+
480
  /**
481
  *
482
+ * Get shipping carrier
483
+ * Format 0: lowercase single word (default). Example: 'postdanmark'
484
+ * Format 1: Capilized user friendly output. Example: 'Post Danmark'
485
+ * @param int $format defines the format of the shipping carrier
486
  * @return string
487
  */
488
+ public function getShippingCarrier($format=0) {
489
+ $shipping_info = $this->getShippingCarrierAndMethod();
490
 
491
+ if(isset($shipping_info[0]) && $shipping_info[0] != '') {
492
+ $carrier_lowcase = strtolower($shipping_info[0]);
493
+ } else {
494
+ throw new Exception( $this->_errors[2307] );
495
  }
496
 
 
 
497
  switch ($carrier_lowcase) {
498
  case 'postdanmark':
499
  if($format == 0) {
 
 
500
  return 'postdanmark';
501
+ } else {
 
 
502
  return 'Post Danmark';
 
 
503
  }
504
  break;
505
  case 'posten':
506
  if($format == 0) {
 
 
507
  return 'posten';
508
+ } else {
 
 
509
  return 'Posten';
 
 
510
  }
511
  break;
512
  case 'gls':
513
  if($format == 0) {
 
 
514
  return 'gls';
515
+ } else {
 
 
516
  return 'GLS';
 
 
517
  }
518
  break;
519
  case 'bring':
520
  if($format == 0) {
 
 
521
  return 'bring';
522
+ } else {
 
 
523
  return 'Bring';
 
 
524
  }
525
  break;
526
  default:
527
+ throw new Exception( $this->_errors[2308] );
 
528
  }
529
+
530
  }
531
 
532
  /**
533
  *
534
+ * Get shipping method
535
+ * Example: 'pickup'
536
+ * @return string
 
537
  */
538
+ public function getShippingMethod() {
539
+ $shipping_info = $this->getShippingCarrierAndMethod();
540
 
541
+ if(isset($shipping_info[1]) && $shipping_info[1] != '') {
542
+ return $shipping_info[1];
543
+ } else {
544
+ //Change this code for each CMS system
545
+ throw new Exception( $this->_errors[2309] );
546
+ }
547
+ }
548
+
549
+
550
+ /*****************************************************************************************
551
+ * Order set functions: Functions to set order parameters
552
+ ****************************************************************************************/
553
+
554
+ /**
555
+ *
556
+ * Set the meta data for the order
557
+ */
558
+ public function setInfo() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
 
560
+ $carrier = $this->getShippingCarrier();
561
+ $method = $this->getShippingMethod();
562
+
563
+ $settings = $this->getSettingsCarrier();
564
+ $type = (isset($settings['format']) ? $settings['format'] : null);
565
+
566
+ $this->_info = array(
567
+ 'orderno' => $this->getOrderId(),
568
+ 'type' => $type,
569
+ 'reference' => $this->getOrderReference(),
570
+ 'carrier' => $carrier,
571
+ 'method' => $method,
572
+ 'return' => $this->isReturn(),
573
+ 'totalprice' => $this->getOrderPriceTotal(),
574
+ 'shipprice' => $this->getOrderPriceShipping(),
575
+ 'currency' => $this->getOrderPriceCurrency(),
576
+ 'test' => $this->_test,
577
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
578
 
 
579
  }
580
 
581
  /**
582
  *
583
+ * Set the receiver information
 
 
584
  */
585
+ public function setReceiver() {
586
+
587
+ if($this->isPickupVconnect() == true) {
588
+ $shipping_address = $this->getShippingAddress();
589
+ $service_point = str_replace(' ', '', $shipping_address['address2']); //remove spaces
590
+ $service_point = strtolower($service_point); //Make lowercase
591
+ if( strpos($service_point, strtolower('ServicePointID')) !== false || strpos($service_point, strtolower('Pakkeshop')) !== false ) {
592
+ $this->_receiver = $this->getBillingAddress();
593
+ } else {
594
+ $this->_receiver = $this->getShippingAddress();
595
+ }
596
  } else {
597
+ $this->_receiver = $this->getShippingAddress();
 
598
  }
599
 
600
  }
601
 
602
  /**
603
  *
604
+ * Set the sender information
 
 
605
  */
606
+ public function setSender() {
607
+
608
+ $carrier = $this->getShippingCarrier();
609
 
610
+ switch ($carrier) {
611
+ case 'postdanmark':
612
+ $settings = $this->getSettingsPostdanmark();
613
+ $sender = array(
614
+ 'senderid' => (isset($settings['quickid']) ? $settings['quickid'] : null),
615
+ 'company' => null,
616
+ 'name1' => null,
617
+ 'name2' => null,
618
+ 'address1' => null,
619
+ 'address2' => null,
620
+ 'zip' => null,
621
+ 'city' => null,
622
+ 'country' => null,
623
+ 'sms' => null,
624
+ 'mail' => null
625
+ );
626
+ break;
627
+ case 'posten':
628
+ $settings = $this->getSettingsPosten();
629
+ $sender = array(
630
+ 'senderid' => (isset($settings['quickid']) ? $settings['quickid'] : null),
631
+ 'company' => null,
632
+ 'name1' => null,
633
+ 'name2' => null,
634
+ 'address1' => null,
635
+ 'address2' => null,
636
+ 'zip' => null,
637
+ 'city' => null,
638
+ 'country' => null,
639
+ 'sms' => null,
640
+ 'mail' => null
641
+ );
642
+ break;
643
+ default:
644
+ $sender = array(
645
+ 'senderid' => null,
646
+ 'company' => null,
647
+ 'name1' => null,
648
+ 'name2' => null,
649
+ 'address1' => null,
650
+ 'address2' => null,
651
+ 'zip' => null,
652
+ 'city' => null,
653
+ 'country' => null,
654
+ 'sms' => null,
655
+ 'mail' => null
656
+ );
657
  }
658
+
659
+ $this->_sender = $sender;
660
+
661
  }
662
 
663
  /**
664
  *
665
+ * Set the agen information
 
 
666
  */
667
+ public function setAgent() {
668
+
669
+ if($this->isPickup() == true) {
670
+ $this->_agent = $this->getPickupData();
 
671
  } else {
672
+ $this->_agent = null;
 
673
  }
674
 
675
  }
676
 
677
  /**
678
  *
679
+ * Set the services that is used for the order
 
 
680
  */
681
+ public function setService() {
682
+
683
+ $settings = $this->getSettingsCarrier();
684
 
685
+ $this->_service = array(
686
+ 'notemail' => ($settings['notemail'] == 1 ? $this->_receiver['mail'] : null),
687
+ 'notesms' => ($settings['notesms'] == 1 ? $this->_receiver['sms'] : null),
688
+ 'prenote' => $settings['prenote'],
689
+ 'prenote_from' => $settings['prenote_from'],
690
+ 'prenote_receiver' => ($settings['prenote_receiver'] == '' ? $this->_receiver['mail'] : $settings['prenote_receiver']),
691
+ 'prenote_message' => ($settings['prenote_message'] != '' ? $settings['prenote_message'] : null),
692
+ 'flex' => ($this->getFlexDeliveryNote() ? true : null),
693
+ 'waybillid' => $this->getWaybill($settings['waybillid'],$this->_receiver['country']),
694
+ 'smartdelivery' => $this->isSmartDelivery(),
695
+ 'smartdelivery_start' => $this->getSmartDeliveryTimeStart(),
696
+ 'smartdelivery_end' => $this->getSmartDeliveryTimeEnd(),
697
+ );
698
 
699
  }
700
 
701
  /**
702
  *
703
+ * Set the parcels. Each parcel contains items.
 
 
 
704
  */
705
+ public function setParcels() {
706
+
707
+ //Get all shipments for the order
708
+ $shipments = $this->getShipments();
 
 
 
709
 
710
+ if(!empty($shipments)) {
711
+ //Go through shipments and check for Track & Trace
712
+ foreach($shipments as $shipment) {
713
+ if($this->isReturn() == true) {
714
+ //Add shipment to order object as a parcel
715
+ $this->addShipment($shipment);
716
+ } else {
717
+ if( !$this->getShipmentTrace($shipment) ) {
718
+ //Add shipment to order object as a parcel
719
+ $this->addShipment($shipment);
720
+ }
721
+ }
 
 
 
 
 
 
 
 
 
 
722
  }
723
 
724
+ if(empty($this->_parcels)) {
725
+ throw new Exception( $this->_errors[2401] );
726
+ }
727
+ } else {
728
+ if($this->getUnshippedItems() != null) {
729
+ $this->createShipment();
730
+ } else {
731
+ throw new Exception( $this->_errors[2402] );
732
  }
733
  }
734
+
735
+ if(empty($this->_parcels)) {
736
+ throw new Exception( $this->_errors[2401] );
737
+ }
738
+
739
  }
740
+
741
+ /*****************************************************************************************
742
+ * Order get functions: Functions to get order parameters
743
+ ****************************************************************************************/
744
 
745
  /**
746
  *
747
+ * Get pickup id of delivery point
748
  * @return string
749
+ */
750
+ public function getPickupId() {
751
+
752
+ $pickupdata = $this->getPickupData();
753
+ return (isset($pickupdata['id']) ? $pickupdata['id'] : null);
754
+
755
+ }
756
+
757
+ /**
758
+ *
759
+ * Get pickup data for delivery point
760
+ * @return array
761
+ */
762
+ public function getPickupData() {
763
+
764
+ if($this->isPickupSmartsend() == true) {
765
+ return $this->getPickupDataSmartsend();
766
+ } elseif($this->isPickupVconnect() == true) {
767
+ return $this->getPickupDataVconnect();
768
+ } else {
769
+ throw new Exception( $this->_errors[2501] );
770
+ }
771
+
772
+ }
773
 
774
  /**
775
  *
778
  * for return labels.
779
  * @return array
780
  */
781
+ public function getSettingsCarrier() {
782
 
783
+ $carrier = $this->getShippingCarrier();
784
  switch ($carrier) {
785
  case 'postdanmark':
786
  $settings = $this->getSettingsPostdanmark();
807
  * Function to return if waybill id if any
808
  * @return string
809
  */
810
+ public function getWaybill($string,$country) {
811
 
812
  //Devide string into array
813
  $array = explode(";", $string);
842
  }
843
 
844
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
845
 
846
  /**
847
+ *
848
+ * Function to return freetext that is displayed on the label
849
+ * @return string
850
+ */
851
+ protected function getFreetext() {
852
+ // If there is a flexdelivery note, return this
853
+ if( $this->getFlexDeliveryNote() ) {
854
+ return $this->getFlexDeliveryNote();
 
855
  }
856
+ // If the setting is to include the order comment, include a trimmed comment
857
+ elseif( $this->getSettingIncludeOrderComment() ) {
858
+ return $this->getCustomerComment();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
859
  }
860
+ // Otherwise return an empty string
861
+ else {
862
+ return null;
863
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
864
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
 
866
  }
app/code/community/Smartsend/Logistics/Model/Ordermagento.php ADDED
@@ -0,0 +1,706 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Smartsend_Logistics Order class
5
+ *
6
+ * Create order objects that is included in the final Smart Send label API callout.
7
+ * These are the CMS dependent functions that is used by the order class.
8
+ *
9
+ * LICENSE
10
+ *
11
+ * This source file is subject to the GNU General Public License v3.0
12
+ * that is bundled with this package in the file license.txt.
13
+ * It is also available through the world-wide-web at this URL:
14
+ * http://www.gnu.org/licenses/gpl-3.0.html
15
+ * If you did not receive a copy of the license and are unable to
16
+ * obtain it through the world-wide-web, please send an email
17
+ * to license@smartsend.dk so we can send you a copy immediately.
18
+ *
19
+ * DISCLAIMER
20
+ *
21
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
22
+ * versions in the future. If you wish to customize the plugin for your
23
+ * needs please refer to http://www.smartsend.dk
24
+ *
25
+ *
26
+ * @class Smartsend_Logistics_Model_Ordermagento
27
+ * @folder /app/code/community/Smartsend/Logistics/Model/Ordermagento.php
28
+ * @category Smartsend
29
+ * @package Smartsend_Logistics
30
+ * @author Smart Send
31
+ * @url www.smartsend.dk
32
+ * @version 7.1.0
33
+ *
34
+ * // Order
35
+ * public function getShippingId()
36
+ * public function getPickupCarrier()
37
+ * public function getOrderId()
38
+ * public function getOrderReference()
39
+ * public function getOrderPriceTotal()
40
+ * public function getOrderPriceShipping()
41
+ * public function getOrderPriceCurrency()
42
+ * public function getCustomerComment()
43
+ * public function getShippingAddress()
44
+ * public function getBillingAddress()
45
+ * public function getPickupDataSmartsend()
46
+ * public function getPickupDataVconnect()
47
+ * public function getFlexDeliveryNote()
48
+ *
49
+ * // Settings
50
+ * public function getSettingsPostdanmark()
51
+ * public function getSettingsPosten()
52
+ * public function getSettingsGls()
53
+ * public function getSettingsBring()
54
+ * protected function getSettingIncludeOrderComment
55
+ *
56
+ * // Shipments
57
+ * public function getShipments()
58
+ * public function getShipmentTrace($shipment)
59
+ * public function getShipmentWeight($shipment)
60
+ * protected function getUnshippedItems()
61
+ * protected function createShipment()
62
+ * protected function addShipment($shipment)
63
+ * protected function addItem($item)
64
+ *
65
+ */
66
+
67
+ class Smartsend_Logistics_Model_Ordermagento extends Smartsend_Logistics_Model_Order {
68
+
69
+ public $_errors = array(
70
+ // Shipping
71
+ 2301 => 'Unable to determine the shipping method used for return parcels',
72
+ 2302 => 'Unable to determine the shipping carrier',
73
+ 2303 => 'Unable to determine the shipping method',
74
+ 2304 => 'Unable to determine carrier for pickup shipping method',
75
+ 2305 => 'Unsupported carrier',
76
+ 2306 => 'Unable to determine shipping method for carrier',
77
+ 2307 => 'Unable to determine shipping carrier',
78
+ 2308 => 'Unknown shipping carrier',
79
+ 2309 => 'Unable to determine shipping method',
80
+ // Order set
81
+ 2401 => 'All packages has been shipped. No parcels without trace code exists. Remove existing tracecodes to re-generate labels.',
82
+ 2402 => 'No items to ship',
83
+ 2403 => 'No parcels to ship',
84
+ // Order get
85
+ 2501 => 'Trying to access pickup data for an order that is not a pickup point order',
86
+ );
87
+
88
+ public function __construct() {
89
+
90
+ // Translate the error string of the $_error array
91
+ foreach($this->_errors as $key=>$value) {
92
+ $this->_errors[$key] = Mage::helper('logistics')->__($value);
93
+ }
94
+ }
95
+
96
+ /*****************************************************************************************
97
+ * Order
98
+ ****************************************************************************************/
99
+
100
+ /**
101
+ *
102
+ * Get shipping name/id
103
+ * @return string
104
+ */
105
+ public function getShippingId() {
106
+
107
+ $shipMethod_id = $this->_order->getShippingMethod();
108
+
109
+ return $shipMethod_id; //return unique id of shipping method
110
+
111
+ }
112
+
113
+ /**
114
+ *
115
+ * Get carrier name based on the pickup information.
116
+ * Used if the shipping method is 'closest pickup point'
117
+ * @return string
118
+ * ## Depricted function ##
119
+ */
120
+ public function getPickupCarrier() {
121
+ /*
122
+ $pickupModel = Mage::getModel('logistics/pickup');
123
+ $pickupData = $pickupModel->getCollection()->addFieldToFilter('order_id', $this->_order->getOrderId() )->getFirstItem(); //pickup data
124
+ if ($pickupData->getData()) {
125
+ $carrier = $pickupData->getCarrier();
126
+ } else {
127
+ $carrier = null;
128
+ }
129
+ */
130
+ }
131
+
132
+ /**
133
+ *
134
+ * Get the order id (SQL id)
135
+ * @return string
136
+ */
137
+ public function getOrderId() {
138
+
139
+ return $this->_order->getId();
140
+
141
+ }
142
+
143
+ /**
144
+ *
145
+ * Get the order refernce (the one the customer sees)
146
+ * @return string
147
+ */
148
+ public function getOrderReference() {
149
+
150
+ return $this->_order->getIncrementId();
151
+
152
+ }
153
+
154
+ /**
155
+ *
156
+ * Get total price of order including tax
157
+ * @return float
158
+ */
159
+ public function getOrderPriceTotal() {
160
+
161
+ return $this->_order->getGrandTotal();
162
+
163
+ }
164
+
165
+ /**
166
+ *
167
+ * Get shipping costs including tax
168
+ * @return float
169
+ */
170
+ public function getOrderPriceShipping() {
171
+
172
+ return $this->_order->getShippingAmount();
173
+
174
+ }
175
+
176
+ /**
177
+ *
178
+ * Get the currency used for the order
179
+ * @return string
180
+ */
181
+ public function getOrderPriceCurrency() {
182
+
183
+ return $this->_order->getOrderCurrencyCode();
184
+
185
+ }
186
+
187
+ /**
188
+ *
189
+ * Get the comment that the user provided during checkout
190
+ * @return string
191
+ */
192
+ public function getCustomerComment() {
193
+ $comments_collection_object = $this->_order->getStatusHistoryCollection(true);
194
+ return $comments_collection_object->getLastItem()->getComment();
195
+ }
196
+
197
+ /**
198
+ *
199
+ * Get the shipping address information
200
+ * @return array
201
+ */
202
+ public function getShippingAddress() {
203
+
204
+ return array(
205
+ 'receiverid'=> ($this->_order->getShippingAddress()->getId() != '' ? $this->_order->getShippingAddress()->getId() : 'guest-'.rand(100000,999999)),
206
+ 'company' => $this->_order->getShippingAddress()->getCompany(),
207
+ 'name1' => $this->_order->getShippingAddress()->getFirstname() .' '. $this->_order->getShippingAddress()->getLastname(),
208
+ 'name2' => null,
209
+ 'address1' => $this->_order->getShippingAddress()->getStreet(1),
210
+ 'address2' => $this->_order->getShippingAddress()->getStreet(2),
211
+ 'city' => $this->_order->getShippingAddress()->getCity(),
212
+ 'zip' => $this->_order->getShippingAddress()->getPostcode(),
213
+ 'country' => $this->_order->getShippingAddress()->getCountry_id(),
214
+ 'sms' => $this->_order->getShippingAddress()->getTelephone(),
215
+ 'mail' => $this->_order->getShippingAddress()->getEmail()
216
+ );
217
+
218
+ }
219
+
220
+ /**
221
+ *
222
+ * Get the shipping address information
223
+ * @return array
224
+ */
225
+ public function getBillingAddress() {
226
+
227
+ return array(
228
+ 'receiverid'=> ($this->_order->getBillingAddress()->getId() != '' ? $this->_order->getBillingAddress()->getId() : 'guest-'.rand(100000,999999)),
229
+ 'company' => $this->_order->getBillingAddress()->getCompany(),
230
+ 'name1' => $this->_order->getBillingAddress()->getFirstname() .' '. $this->_order->getBillingAddress()->getLastname(),
231
+ 'name2' => null,
232
+ 'address1' => $this->_order->getBillingAddress()->getStreet(1),
233
+ 'address2' => $this->_order->getBillingAddress()->getStreet(2),
234
+ 'city' => $this->_order->getBillingAddress()->getCity(),
235
+ 'zip' => $this->_order->getBillingAddress()->getPostcode(),
236
+ 'country' => $this->_order->getBillingAddress()->getCountry_id(),
237
+ 'sms' => $this->_order->getBillingAddress()->getTelephone(),
238
+ 'mail' => $this->_order->getBillingAddress()->getEmail()
239
+ );
240
+
241
+ }
242
+
243
+ /**
244
+ *
245
+ * Get pickup data for a SmartSend delivery point
246
+ * @return array
247
+ */
248
+ public function getPickupDataSmartsend() {
249
+
250
+ $carrier = $this->getShippingCarrier();
251
+ switch ($carrier) {
252
+ case 'postdanmark':
253
+ $pickupModel = Mage::getModel('logistics/postdanmark');
254
+ break;
255
+ case 'posten':
256
+ $pickupModel = Mage::getModel('logistics/posten');
257
+ break;
258
+ case 'gls':
259
+ $pickupModel = Mage::getModel('logistics/gls');
260
+ break;
261
+ case 'bring':
262
+ $pickupModel = Mage::getModel('logistics/bring');
263
+ break;
264
+ default:
265
+ throw new Exception( $this->_errors[2302] );
266
+ }
267
+
268
+ $order_id = $this->_order->getId(); //order id
269
+ $pickupData = $pickupModel->getCollection()->addFieldToFilter('order_id', $order_id)->getFirstItem(); //pickup data
270
+
271
+ if ($pickupData->getData()) {
272
+
273
+ return array(
274
+ 'id' => $pickupData->getPickUpId()."-".time()."-".rand(9999,10000),
275
+ 'agentno' => $pickupData->getPickUpId(),
276
+ 'agenttype' => ($this->getShippingCarrier() == 'postdanmark' ? 'PDK' : null),
277
+ 'company' => $pickupData->getCompany(),
278
+ 'name1' => null,
279
+ 'name2' => null,
280
+ 'address1' => $pickupData->getStreet(),
281
+ 'address2' => null,
282
+ 'city' => $pickupData->getCity(),
283
+ 'zip' => $pickupData->getZip(),
284
+ 'country' => $pickupData->getCountry(),
285
+ 'sms' => null,
286
+ 'mail' => null,
287
+ );
288
+
289
+ } else {
290
+ return null;
291
+ }
292
+
293
+ }
294
+
295
+ /**
296
+ *
297
+ * Get pickup data for a vConnect delivery point
298
+ * @return array
299
+ */
300
+ public function getPickupDataVconnect() {
301
+
302
+ if($this->_order->hasData('vconnect_postnord_data')){
303
+ $postnordShippingInfoArray = Mage::helper('core')->jsonDecode($this->_order->getData('vconnect_postnord_data'));
304
+ if(isset($postnordShippingInfoArray['data']['servicePointId']) && $postnordShippingInfoArray['data']['servicePointId'] != ''){
305
+ $pickuppoint = $postnordShippingInfoArray['data'];
306
+
307
+ return array(
308
+ 'id' => $pickuppoint['servicePointId']."-".time()."-".rand(9999,10000),
309
+ 'agentno' => $pickuppoint['servicePointId'],
310
+ 'agenttype' => ($this->getShippingCarrier() == 'postdanmark' ? 'PDK' : null),
311
+ 'company' => $pickuppoint['name'],
312
+ 'name1' => null,
313
+ 'name2' => null,
314
+ 'address1' => $pickuppoint['deliveryAddress']['streetName'].($pickuppoint['deliveryAddress']['streetNumber'] != '' ? ' '.$pickuppoint['deliveryAddress']['streetNumber'] : ''),
315
+ 'address2' => null,
316
+ 'city' => $pickuppoint['deliveryAddress']['city'],
317
+ 'zip' => $pickuppoint['deliveryAddress']['postalCode'],
318
+ 'country' => $pickuppoint['deliveryAddress']['countryCode'],
319
+ 'sms' => null,
320
+ 'mail' => null,
321
+ );
322
+
323
+ } else {
324
+ return null;
325
+ }
326
+ } else {
327
+ $billing_address = $this->getShippingAddress();
328
+
329
+ $pacsoftServicePoint = str_replace(' ', '', $billing_address['address2']); //remove spaces
330
+ $pacsoftServicePointArray = explode(":",$pacsoftServicePoint); //devide into a array by :
331
+
332
+ if ( isset($pacsoftServicePointArray) && ( strtolower($pacsoftServicePointArray[0]) == strtolower('ServicePointID') ) || strtolower($pacsoftServicePointArray[0]) == strtolower('Pakkeshop') ){
333
+ $pickupData = array(
334
+ 'id' => $pacsoftServicePointArray[1]."-".time()."-".rand(9999,10000),
335
+ 'agentno' => $pacsoftServicePointArray[1],
336
+ 'agenttype' => ($this->getShippingCarrier() == 'postdanmark' ? 'PDK' : null),
337
+ 'company' => $billing_address['company'],
338
+ 'name1' => $billing_address['name1'],
339
+ 'name2' => $billing_address['name2'],
340
+ 'address1' => $billing_address['address1'],
341
+ 'address2' => null,
342
+ 'city' => $billing_address['city'],
343
+ 'zip' => $billing_address['zip'],
344
+ 'country' => $billing_address['country'],
345
+ 'sms' => null,
346
+ 'mail' => null,
347
+ );
348
+
349
+ return $pickupData;
350
+
351
+ } else {
352
+ return null;
353
+ }
354
+ }
355
+
356
+ }
357
+
358
+ /**
359
+ *
360
+ * Get the Flex delivery comment (where to place the parcel) from Mysql
361
+ * @return string / null
362
+ */
363
+ public function getFlexDeliveryNote() {
364
+ if( $this->isSmartsend() ) {
365
+ //This is a Smart Send order
366
+ $flexModel = Mage::getModel('logistics/flex');
367
+ $flexData = $flexModel->getCollection()->addFieldToFilter('order_id', $this->_order->getId())->getFirstItem(); //pickup data
368
+ if ($flexData->getData()) {
369
+ if($flexData->getFlexnote() != '') {
370
+ return $flexData->getFlexnote();
371
+ } else {
372
+ return null;
373
+ }
374
+ } else {
375
+ return null;
376
+ }
377
+ } elseif( $this->isVconnect() ) {
378
+ if($this->_order->hasData('vconnect_postnord_data')){
379
+ $postnordShippingInfoArray = Mage::helper('core')->jsonDecode($this->_order->getData('vconnect_postnord_data'));
380
+ }
381
+ if(isset($postnordShippingInfoArray['flexdelivery']) && $postnordShippingInfoArray['flexdelivery'] != '') {
382
+ return $postnordShippingInfoArray['flexdelivery'];
383
+ } else {
384
+ return null;
385
+ }
386
+ } else {
387
+ return null;
388
+ }
389
+ }
390
+
391
+ /**
392
+ *
393
+ * Get the start time for Smart Delivery from MySQL
394
+ * @return string / null
395
+ */
396
+ public function getSmartDeliveryTimeStart() {
397
+ return null;
398
+ }
399
+
400
+ /**
401
+ *
402
+ * Get the end time for Smart Delivery from MySQL
403
+ * @return string / null
404
+ */
405
+ public function getSmartDeliveryTimeEnd() {
406
+ return null;
407
+ }
408
+
409
+ /*****************************************************************************************
410
+ * Settings
411
+ ****************************************************************************************/
412
+
413
+ /**
414
+ *
415
+ * Get the settings for Post Danmark
416
+ * @return array
417
+ */
418
+ public function getSettingsPostdanmark() {
419
+
420
+ return array(
421
+ 'notemail' => Mage::getStoreConfig('carriers/smartsendpostdanmark/notemail'),
422
+ 'notesms' => Mage::getStoreConfig('carriers/smartsendpostdanmark/notesms'),
423
+ 'prenote' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote'),
424
+ 'prenote_from' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote_sender'),
425
+ 'prenote_receiver' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote_receiver'),
426
+ 'prenote_message' => Mage::getStoreConfig('carriers/smartsendpostdanmark/prenote_message'),
427
+ 'flex' => null,
428
+ 'format' => Mage::getStoreConfig('carriers/smartsendpostdanmark/format'),
429
+ 'quickid' => Mage::getStoreConfig('carriers/smartsendpostdanmark/quickid'),
430
+ 'waybillid' => Mage::getStoreConfig('carriers/smartsendpostdanmark/waybillid'),
431
+ 'return' => Mage::getStoreConfig('carriers/smartsendpostdanmark/return'),
432
+ );
433
+
434
+ }
435
+
436
+ /**
437
+ *
438
+ * Get the settings for Posten
439
+ * @return array
440
+ */
441
+ public function getSettingsPosten() {
442
+
443
+ return array(
444
+ 'notemail' => Mage::getStoreConfig('carriers/smartsendposten/notemail'),
445
+ 'notesms' => Mage::getStoreConfig('carriers/smartsendposten/notesms'),
446
+ 'prenote' => Mage::getStoreConfig('carriers/smartsendposten/prenote'),
447
+ 'prenote_from' => Mage::getStoreConfig('carriers/smartsendposten/prenote_sender'),
448
+ 'prenote_receiver' => Mage::getStoreConfig('carriers/smartsendposten/prenote_receiver'),
449
+ 'prenote_message' => Mage::getStoreConfig('carriers/smartsendposten/prenote_message'),
450
+ 'flex' => null,
451
+ 'format' => Mage::getStoreConfig('carriers/smartsendposten/format'),
452
+ 'quickid' => Mage::getStoreConfig('carriers/smartsendposten/quickid'),
453
+ 'waybillid' => Mage::getStoreConfig('carriers/smartsendposten/waybillid'),
454
+ 'return' => Mage::getStoreConfig('carriers/smartsendposten/return'),
455
+ );
456
+
457
+ }
458
+
459
+ /**
460
+ *
461
+ * Get the settings for GLS
462
+ * @return array
463
+ */
464
+ public function getSettingsGls() {
465
+
466
+ return array(
467
+ 'notemail' => Mage::getStoreConfig('carriers/smartsendgls/notemail'),
468
+ 'notesms' => Mage::getStoreConfig('carriers/smartsendgls/notesms'),
469
+ 'prenote' => null,
470
+ 'prenote_from' => null,
471
+ 'prenote_receiver' => null,
472
+ 'prenote_message' => null,
473
+ 'flex' => null,
474
+ 'format' => null,
475
+ 'quickid' => null,
476
+ 'waybillid' => null,
477
+ 'return' => Mage::getStoreConfig('carriers/smartsendgls/return'),
478
+ );
479
+
480
+ }
481
+
482
+ /**
483
+ *
484
+ * Get the settings for Bring
485
+ * @return array
486
+ */
487
+ public function getSettingsBring() {
488
+
489
+ return array(
490
+ 'notemail' => Mage::getStoreConfig('carriers/smartsendbring/notemail'),
491
+ 'notesms' => Mage::getStoreConfig('carriers/smartsendbring/notesms'),
492
+ 'prenote' => null,
493
+ 'prenote_from' => null,
494
+ 'prenote_receiver' => null,
495
+ 'prenote_message' => null,
496
+ 'flex' => null,
497
+ 'format' => null,
498
+ 'quickid' => null,
499
+ 'waybillid' => null,
500
+ 'return' => Mage::getStoreConfig('carriers/smartsendbring/return'),
501
+ );
502
+
503
+ }
504
+
505
+ /**
506
+ *
507
+ * Should the order comment be included as freetext on label
508
+ *
509
+ * @return boolean
510
+ */
511
+ protected function getSettingIncludeOrderComment() {
512
+ return Mage::getStoreConfig('carriers/smartsend/includeordercomment');
513
+ }
514
+
515
+ /*****************************************************************************************
516
+ * Shipments
517
+ ****************************************************************************************/
518
+
519
+ /**
520
+ *
521
+ * Get the shipments for the order if any
522
+ * @return array
523
+ */
524
+ public function getShipments() {
525
+
526
+ if( $this->_order->hasShipments() ) {
527
+ return $this->_order->getShipmentsCollection();
528
+ } else {
529
+ return null;
530
+ }
531
+ }
532
+
533
+ /**
534
+ *
535
+ * Get the Track&Trace code for a given shipment
536
+ * @return string
537
+ */
538
+ public function getShipmentTrace($shipment) {
539
+
540
+ $tracknums = array();
541
+ foreach($shipment->getAllTracks() as $tracknum) {
542
+ $tracknums[]=$tracknum->getNumber();
543
+ }
544
+
545
+ if(empty($tracknums)) {
546
+ return false;
547
+ } else {
548
+ return true;
549
+ }
550
+
551
+ }
552
+
553
+ /**
554
+ *
555
+ * Get the weight (in kg) of a given shipment
556
+ * @return float
557
+ */
558
+ public function getShipmentWeight($shipment) {
559
+
560
+ $weight = 0;
561
+ foreach($shipment->getAllItems() as $eachShipmentItem) {
562
+ $itemWeight = $eachShipmentItem->getWeight();
563
+ $itemQty = $eachShipmentItem->getQty();
564
+ $rowWeight = $itemWeight*$itemQty;
565
+
566
+ $weight = $weight + $rowWeight;
567
+ }
568
+
569
+ if(isset($weight) && $weight > 0) {
570
+ return $weight;
571
+ } else {
572
+ return null;
573
+ }
574
+ }
575
+
576
+ /**
577
+ *
578
+ * Get the unshipped items of the order
579
+ * @return array
580
+ */
581
+ protected function getUnshippedItems() {
582
+
583
+ $items = array();
584
+ foreach($this->_order->getAllItems() as $eachOrderItem){
585
+ $Itemqty = 0;
586
+ $Itemqty = $eachOrderItem->getQtyOrdered()
587
+ - $eachOrderItem->getQtyShipped()
588
+ - $eachOrderItem->getQtyRefunded()
589
+ - $eachOrderItem->getQtyCanceled();
590
+ if($Itemqty > 0) {
591
+ $items[$eachOrderItem->getId()] = $Itemqty;
592
+ }
593
+ }
594
+
595
+ if(!empty($items)) {
596
+ return $items;
597
+ } else {
598
+ return null;
599
+ }
600
+
601
+ }
602
+
603
+ /**
604
+ *
605
+ * Create a parcel containing all unshipped items.
606
+ * Add the parcel to the request.
607
+ */
608
+ protected function createShipment() {
609
+
610
+ $order = $this->_order;
611
+ $qty = $this->getUnshippedItems();
612
+
613
+ /* check order shipment is prossiable or not */
614
+
615
+ $email = false;
616
+ $includeComment = false;
617
+ $comment = "";
618
+
619
+ if ($order->canShip()) {
620
+ // @var $shipment Mage_Sales_Model_Order_Shipment
621
+ // prepare to create shipment
622
+ $shipment = Mage::getModel('sales/service_order', $order)->prepareShipment($qty);
623
+ if ($shipment) {
624
+ $shipment->register();
625
+
626
+ //Add a comment. Second parameter is whether or not to email the comment to the user
627
+ $shipment->addComment($comment, $email && $includeComment);
628
+
629
+ // Set the order status as 'Processing'
630
+ $order->setIsInProcess($email);
631
+ $order->addStatusHistoryComment(Mage::helper('logistics')->__('Shipment generated by Smart Send Logistics'), false);
632
+
633
+ try {
634
+ $transactionSave = Mage::getModel('core/resource_transaction')
635
+ ->addObject($shipment)
636
+ ->addObject($order)
637
+ ->save();
638
+
639
+ //Email the customer that the order is sent
640
+ $shipment->sendEmail($email, ($includeComment ? $comment : ''));
641
+
642
+ //Set order status as complete
643
+ //$order->setData('state', Mage_Sales_Model_Order::STATE_COMPLETE);
644
+ //$order->setData('status', Mage_Sales_Model_Order::STATE_COMPLETE);
645
+ //$order->save();
646
+
647
+ //var_dump($qty); exit();
648
+ } catch (Mage_Core_Exception $e) {
649
+ throw new Exception($this->_errors[2402].': '.$e);
650
+ }
651
+ }
652
+ }
653
+
654
+ if ($shipment) {
655
+ //Lastly add the shipment to the order array.
656
+ $this->addShipment($shipment);
657
+ }
658
+
659
+ }
660
+
661
+ /**
662
+ *
663
+ * Add a shipment to the request
664
+ */
665
+ protected function addShipment($shipment) {
666
+
667
+ $parcel = array(
668
+ 'shipdate' => null,
669
+ 'reference' => $shipment->getId(),
670
+ 'weight' => $this->getShipmentWeight($shipment),
671
+ 'height' => null,
672
+ 'width' => null,
673
+ 'length' => null,
674
+ 'size' => null,
675
+ 'freetext1' => $this->getFreetext(),
676
+ 'items' => array(),
677
+ );
678
+
679
+ $ordered_items = $shipment->getAllItems();
680
+ foreach($ordered_items as $item) {
681
+ $parcel['items'][] = $this->addItem($item);
682
+ }
683
+
684
+ $this->_parcels[] = $parcel;
685
+
686
+ }
687
+
688
+ /**
689
+ *
690
+ * Format an item to be added to a parcel
691
+ * @return array
692
+ */
693
+ protected function addItem($item) {
694
+
695
+ return array(
696
+ 'sku' => $item->getSku(),
697
+ 'title' => $item->getName(),
698
+ 'quantity' => $item->getQty(),
699
+ 'unitweight'=> $item->getWeight(),
700
+ 'unitprice' => $item->getPrice(),
701
+ 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode()
702
+ );
703
+ // $item->getItemId(); //product id
704
+ }
705
+
706
+ }
app/code/community/Smartsend/Logistics/Model/Rewrite/Sales/Total/Quote/Shipping.php CHANGED
@@ -23,21 +23,17 @@
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
 
26
 
27
- class Smartsend_Logistics_Model_Rewrite_Sales_Total_Quote_Shipping extends Mage_Tax_Model_Sales_Total_Quote_Shipping
28
- {
29
-
30
- public function collect(Mage_Sales_Model_Quote_Address $address)
31
- {
32
-
33
  $this->_setAddress($address);
34
  /**
35
  * Reset amounts
36
  */
37
  $this->_setAmount(0);
38
  $this->_setBaseAmount(0);
39
-
40
-
41
  $calc = $this->_calculator;
42
  $store = $address->getQuote()->getStore();
43
  $storeTaxRequest = $calc->getRateOriginRequest($store);
@@ -47,70 +43,99 @@ class Smartsend_Logistics_Model_Rewrite_Sales_Total_Quote_Shipping extends Mage
47
  $address->getQuote()->getCustomerTaxClassId(),
48
  $store
49
  );
50
-
51
- $shippingTaxClass = $this->_config->getShippingTaxClass($store);
52
-
53
 
54
  //custom code - start
55
- $shipping_method = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
56
 
57
- if(substr($shipping_method, 0, strlen('smartsend')) === 'smartsend') {
58
- $carrier = explode('_',$shipping_method);
59
- $smartsend_carrier = $carrier['0'];
60
-
61
- $exclude_tax = Mage::getStoreConfig("carriers/".$smartsend_carrier."/excludetax");
62
-
63
- if($exclude_tax) {
64
- $shippingTaxClass=0;
65
- }
66
- }
67
- //custom code - end
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  $storeTaxRequest->setProductClassId($shippingTaxClass);
70
  $addressTaxRequest->setProductClassId($shippingTaxClass);
 
 
71
 
72
- $priceIncludesTax = $this->_config->shippingPriceIncludesTax($store);
73
  if ($priceIncludesTax) {
74
- $this->_areTaxRequestsSimilar = $calc->compareRequests($addressTaxRequest, $storeTaxRequest);
 
 
 
 
 
75
  }
76
 
77
- $shipping = $taxShipping = $address->getShippingAmount();
78
- $baseShipping = $baseTaxShipping = $address->getBaseShippingAmount();
79
  $rate = $calc->getRate($addressTaxRequest);
80
  if ($priceIncludesTax) {
81
  if ($this->_areTaxRequestsSimilar) {
82
- $taxExact = $calc->calcTaxAmount($shipping, $rate, true, false);
83
- $baseTaxExact = $calc->calcTaxAmount($baseShipping, $rate, true, false);
 
84
  $taxShipping = $shipping;
85
  $baseTaxShipping = $baseShipping;
86
- $shippingExact = $shipping - $taxExact;
87
- $baseShippingExact = $baseShipping - $baseTaxExact;
88
  $taxable = $taxShipping;
89
  $baseTaxable = $baseTaxShipping;
90
  $isPriceInclTax = true;
91
- $address->setTotalAmount('shipping', $shippingExact);
92
- $address->setBaseTotalAmount('shipping', $baseShippingExact);
93
  } else {
94
  $storeRate = $calc->getStoreRate($addressTaxRequest, $store);
95
  $storeTax = $calc->calcTaxAmount($shipping, $storeRate, true, false);
96
  $baseStoreTax = $calc->calcTaxAmount($baseShipping, $storeRate, true, false);
97
  $shipping = $calc->round($shipping - $storeTax);
98
  $baseShipping = $calc->round($baseShipping - $baseStoreTax);
99
- $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), $rate, false);
100
  $baseTax = $this->_round(
101
- $calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, false, 'base');
102
  $taxShipping = $shipping + $tax;
103
  $baseTaxShipping = $baseShipping + $baseTax;
104
- $taxable = $shipping;
105
- $baseTaxable = $baseShipping;
106
- $isPriceInclTax = false;
107
  $address->setTotalAmount('shipping', $shipping);
108
  $address->setBaseTotalAmount('shipping', $baseShipping);
109
  }
110
  } else {
111
- $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), $rate, false);
112
- $baseTax = $this->_round(
113
- $calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, false, 'base');
 
 
 
 
 
 
 
 
 
114
  $taxShipping = $shipping + $tax;
115
  $baseTaxShipping = $baseShipping + $baseTax;
116
  $taxable = $shipping;
@@ -129,8 +154,6 @@ class Smartsend_Logistics_Model_Rewrite_Sales_Total_Quote_Shipping extends Mage
129
  $address->setBaseShippingAmountForDiscount($baseTaxShipping);
130
  }
131
  return $this;
132
-
133
  }
134
 
135
- }
136
-
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
+ class Smartsend_Logistics_Model_Rewrite_Sales_Total_Quote_Shipping extends Mage_Tax_Model_Sales_Total_Quote_Shipping {
27
 
28
+ public function collect(Mage_Sales_Model_Quote_Address $address) {
29
+
 
 
 
 
30
  $this->_setAddress($address);
31
  /**
32
  * Reset amounts
33
  */
34
  $this->_setAmount(0);
35
  $this->_setBaseAmount(0);
36
+
 
37
  $calc = $this->_calculator;
38
  $store = $address->getQuote()->getStore();
39
  $storeTaxRequest = $calc->getRateOriginRequest($store);
43
  $address->getQuote()->getCustomerTaxClassId(),
44
  $store
45
  );
 
 
 
46
 
47
  //custom code - start
 
48
 
49
+ $shippingTaxClass = $this->_config->getShippingTaxClass($store);
50
+ $priceIncludesTax = $this->_config->shippingPriceIncludesTax($store);
51
+
52
+ $smartsend_exclude = false;
53
+
54
+ $shipping_method = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
55
+
56
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend') {
57
+ $carrier = explode('_', $shipping_method);
58
+ $smartsend_carrier = $carrier['0'];
59
+
60
+ $exclude_tax = Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax");
61
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
62
+
63
+ if ($exclude_tax && $excludedMethod) {
64
+ $smartsend_exclude = true;
65
+ $shippingTaxClass = 0;
66
+ }
67
+ }
68
+
69
+ $shipping = $taxShipping = $address->getShippingAmount();
70
+ $baseShipping = $baseTaxShipping = $address->getBaseShippingAmount();
71
+
72
+ if ($smartsend_exclude && $priceIncludesTax) {
73
+ $rate = $calc->getRate($addressTaxRequest);
74
+ $taxExact = $calc->calcTaxAmount($shipping, $rate, true, false);
75
+ $baseTaxExact = $calc->calcTaxAmount($baseShipping, $rate, true, false);
76
+ $shipping = $taxShipping = $shipping - $taxExact;
77
+ $baseShipping = $baseTaxShipping = $baseShipping - $baseTaxExact;
78
+ }
79
+
80
  $storeTaxRequest->setProductClassId($shippingTaxClass);
81
  $addressTaxRequest->setProductClassId($shippingTaxClass);
82
+
83
+ //custom code - end
84
 
 
85
  if ($priceIncludesTax) {
86
+ if ($this->_helper->isCrossBorderTradeEnabled($store)) {
87
+ $this->_areTaxRequestsSimilar = true;
88
+ } else {
89
+ $this->_areTaxRequestsSimilar =
90
+ $this->_calculator->compareRequests($storeTaxRequest, $addressTaxRequest);
91
+ }
92
  }
93
 
 
 
94
  $rate = $calc->getRate($addressTaxRequest);
95
  if ($priceIncludesTax) {
96
  if ($this->_areTaxRequestsSimilar) {
97
+ $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, true, false), $rate, true);
98
+ $baseTax = $this->_round(
99
+ $calc->calcTaxAmount($baseShipping, $rate, true, false), $rate, true, 'base');
100
  $taxShipping = $shipping;
101
  $baseTaxShipping = $baseShipping;
102
+ $shipping = $shipping - $tax;
103
+ $baseShipping = $baseShipping - $baseTax;
104
  $taxable = $taxShipping;
105
  $baseTaxable = $baseTaxShipping;
106
  $isPriceInclTax = true;
107
+ $address->setTotalAmount('shipping', $shipping);
108
+ $address->setBaseTotalAmount('shipping', $baseShipping);
109
  } else {
110
  $storeRate = $calc->getStoreRate($addressTaxRequest, $store);
111
  $storeTax = $calc->calcTaxAmount($shipping, $storeRate, true, false);
112
  $baseStoreTax = $calc->calcTaxAmount($baseShipping, $storeRate, true, false);
113
  $shipping = $calc->round($shipping - $storeTax);
114
  $baseShipping = $calc->round($baseShipping - $baseStoreTax);
115
+ $tax = $this->_round($calc->calcTaxAmount($shipping, $rate, false, false), $rate, true);
116
  $baseTax = $this->_round(
117
+ $calc->calcTaxAmount($baseShipping, $rate, false, false), $rate, true, 'base');
118
  $taxShipping = $shipping + $tax;
119
  $baseTaxShipping = $baseShipping + $baseTax;
120
+ $taxable = $taxShipping;
121
+ $baseTaxable = $baseTaxShipping;
122
+ $isPriceInclTax = true;
123
  $address->setTotalAmount('shipping', $shipping);
124
  $address->setBaseTotalAmount('shipping', $baseShipping);
125
  }
126
  } else {
127
+ $appliedRates = $calc->getAppliedRates($addressTaxRequest);
128
+ $taxes = array();
129
+ $baseTaxes = array();
130
+ foreach ($appliedRates as $appliedRate) {
131
+ $taxRate = $appliedRate['percent'];
132
+ $taxId = $appliedRate['id'];
133
+ $taxes[] = $this->_round($calc->calcTaxAmount($shipping, $taxRate, false, false), $taxId, false);
134
+ $baseTaxes[] = $this->_round(
135
+ $calc->calcTaxAmount($baseShipping, $taxRate, false, false), $taxId, false, 'base');
136
+ }
137
+ $tax = array_sum($taxes);
138
+ $baseTax = array_sum($baseTaxes);
139
  $taxShipping = $shipping + $tax;
140
  $baseTaxShipping = $baseShipping + $baseTax;
141
  $taxable = $shipping;
154
  $address->setBaseShippingAmountForDiscount($baseTaxShipping);
155
  }
156
  return $this;
 
157
  }
158
 
159
+ }
 
app/code/community/Smartsend/Logistics/Model/Rewrite/Sales/Total/Quote/Tax.php CHANGED
@@ -33,7 +33,7 @@ class Smartsend_Logistics_Model_Rewrite_Sales_Total_Quote_Tax extends Mage_Tax_
33
  $taxRateRequest->setProductClassId($this->_config->getShippingTaxClass($this->_store));
34
 
35
 
36
- //custom code - start
37
  $shipping_method= Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
38
 
39
  if(substr($shipping_method, 0, strlen('smartsend')) === 'smartsend') {
@@ -41,13 +41,13 @@ class Smartsend_Logistics_Model_Rewrite_Sales_Total_Quote_Tax extends Mage_Tax_
41
  $carrier=explode('_',$shipping_method);
42
  $smartsend_carrier=$carrier['0'];
43
 
44
- $exclude_tax= Mage::getStoreConfig("carriers/".$smartsend_carrier."/excludetax");
45
-
46
- if($exclude_tax) {
47
- $taxRateRequest->setProductClassId(0);
48
  }
49
  }
50
- //custom code - end
51
 
52
 
53
  $rate = $this->_calculator->getRate($taxRateRequest);
33
  $taxRateRequest->setProductClassId($this->_config->getShippingTaxClass($this->_store));
34
 
35
 
36
+ //Smart Send custom code - start
37
  $shipping_method= Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingMethod();
38
 
39
  if(substr($shipping_method, 0, strlen('smartsend')) === 'smartsend') {
41
  $carrier=explode('_',$shipping_method);
42
  $smartsend_carrier=$carrier['0'];
43
 
44
+ $exclude_tax = Mage::getStoreConfig("carriers/".$smartsend_carrier."/excludetax");
45
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
46
+ if ($exclude_tax && $excludedMethod) {
47
+ $taxRateRequest->setProductClassId(0);
48
  }
49
  }
50
+ //Smart Send custom code - end
51
 
52
 
53
  $rate = $this->_calculator->getRate($taxRateRequest);
app/code/community/Smartsend/Logistics/Model/ShippingMethods.php CHANGED
@@ -17,7 +17,7 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Status.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
@@ -25,198 +25,104 @@
25
  */
26
  class Smartsend_Logistics_Model_ShippingMethods extends Varien_Object {
27
 
 
 
 
 
 
 
 
28
  static public function getOptionArray($carrier) {
29
 
30
-
31
  $carrier_name = explode('groups[', $carrier); //getting carrier name
32
-
33
  $carrier_name = explode(']', $carrier_name[1]);
34
-
35
  $carrier_name = $carrier_name[0];
36
 
37
- if ($carrier_name == 'smartsendbring') {
38
-
39
- //Bring shipping methods
40
- $shipping_methods = array(
41
- 'private',
42
- 'privatehome',
43
- 'commercial',
44
- 'commercial_bulksplit',
45
- 'private_bulksplit',
46
- 'privatehome_bulksplit'
47
- );
48
- if(Mage::helper('logistics/data')->isVconnetEnabled() == false) {
49
- array_unshift($shipping_methods,'pickup');
50
- }
51
-
52
- $method_names = array_flip(Mage::getModel('logistics/shippingMethods')->getMethodName());
53
-
54
- $methods_array = array();
55
- foreach ($shipping_methods as $key => $value) {
56
-
57
- if (array_key_exists($value, $method_names)) {
58
- $methods_array[$method_names[$value]] = $method_names[$value];
59
- }
60
- }
61
-
62
- return $methods_array;
63
- } elseif ($carrier_name == 'smartsendpostdanmark') {
64
-
65
- //Post Danmark shipping methods
66
- $shipping_methods = array(
67
- 'private',
68
- 'privatehome',
69
- 'commercial',
70
- 'dpdclassic',
71
- 'dpdguranty',
72
- 'valuemail',
73
- 'privatesamsending',
74
- 'privatepriority',
75
- 'privateeconomy'
76
- );
77
- if(Mage::helper('logistics/data')->isVconnetEnabled() == false) {
78
- array_unshift($shipping_methods,'pickup');
79
- }
80
-
81
- $method_names = array_flip(Mage::getModel('logistics/shippingMethods')->getMethodName());
82
-
83
- $methods_array = array();
84
- foreach ($shipping_methods as $key => $value) {
85
-
86
- if (array_key_exists($value, $method_names)) {
87
- $methods_array[$method_names[$value]] = $method_names[$value];
88
- }
89
- }
90
-
91
- return $methods_array;
92
- } elseif ($carrier_name == 'smartsendposten') {
93
-
94
- //Posten shipping methods
95
- $shipping_methods = array(
96
- 'private',
97
- 'privatehome',
98
- 'commercial',
99
- 'valuemail',
100
- 'valuemailfirstclass',
101
- 'valuemaileconomy',
102
- 'maximail'
103
- );
104
- if(Mage::helper('logistics/data')->isVconnetEnabled() == false) {
105
- array_unshift($shipping_methods,'pickup');
106
- }
107
-
108
- $method_names = array_flip(Mage::getModel('logistics/shippingMethods')->getMethodName());
109
-
110
- $methods_array = array();
111
- foreach ($shipping_methods as $key => $value) {
112
-
113
- if (array_key_exists($value, $method_names)) {
114
- $methods_array[$method_names[$value]] = $method_names[$value];
115
- }
116
- }
117
-
118
- return $methods_array;
119
- } elseif ($carrier_name == 'smartsendswipbox') {
120
-
121
- //SwipBox shipping methods
122
- $shipping_methods = array(
123
- 'pickup'
124
- );
125
-
126
- $method_names = array_flip(Mage::getModel('logistics/shippingMethods')->getMethodName());
127
-
128
- $methods_array = array();
129
- foreach ($shipping_methods as $key => $value) {
130
-
131
- if (array_key_exists($value, $method_names)) {
132
- $methods_array[$method_names[$value]] = $method_names[$value];
133
- }
134
- }
135
-
136
- return $methods_array;
137
- } elseif ($carrier_name == 'smartsendpickup') {
138
-
139
- //Closest shipping methods
140
- $shipping_methods = array();
141
- if(Mage::helper('logistics/data')->isVconnetEnabled() == false) {
142
- array_unshift($shipping_methods,'pickup');
143
- }
144
-
145
- $method_names = array_flip(Mage::getModel('logistics/shippingMethods')->getMethodName());
146
-
147
- $methods_array = array();
148
- foreach ($shipping_methods as $key => $value) {
149
-
150
- if (array_key_exists($value, $method_names)) {
151
- $methods_array[$method_names[$value]] = $method_names[$value];
152
- }
153
- }
154
-
155
- return $methods_array;
156
- } elseif ($carrier_name == 'smartsendgls') {
157
-
158
- //GLS shipping methods
159
- $shipping_methods = array(
160
- 'private',
161
- 'privatehome',
162
- 'commercial'
163
- );
164
- if(Mage::helper('logistics/data')->isVconnetEnabled() == false) {
165
- array_unshift($shipping_methods,'pickup');
166
- }
167
-
168
- $method_names = array_flip(Mage::getModel('logistics/shippingMethods')->getMethodName());
169
-
170
- $methods_array = array();
171
- foreach ($shipping_methods as $key => $value) {
172
-
173
- if (array_key_exists($value, $method_names)) {
174
- $methods_array[$method_names[$value]] = $method_names[$value];
175
- }
176
- }
177
-
178
- return $methods_array;
179
- }
180
- }
181
-
182
- public function getMethodName() {
183
-
184
- return array(
185
- 'Pickuppoint' => 'pickup',
186
- 'Private to home' => 'privatehome',
187
- 'Commercial' => 'commercial',
188
- 'Private' => 'private',
189
- 'DPDclassic' => 'dpdclassic',
190
- 'DPDguarantee' => 'dpdguranty',
191
- 'Valuemail' => 'valuemail',
192
- 'Valuemailfirstclass' => 'valuemailfirstclass',
193
- 'Valuemaileconomy' => 'valuemaileconomy',
194
- 'Maximail' => 'maximail',
195
- 'Commercial Bulksplit' => 'commercial_bulksplit',
196
- 'Private Bulksplit' => 'private_bulksplit',
197
- 'Privatehome Bulksplit' => 'privatehome_bulksplit',
198
- 'Private samsending' => 'privatesamsending',
199
- 'Private priority' => 'privatepriority',
200
- 'Private economy' => 'privateeconomy'
201
- );
202
  }
203
-
204
- public function getTitleValue($opt) {
205
-
206
- if ($opt == "Private") { //getting title of the shipping method
207
- $label = "Privat";
208
- } elseif ($opt == "Commercial") {
209
- $label = "Erhverv";
210
- } else {
211
- $label = $opt;
212
- }
213
-
214
- return $label;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
 
217
- public function checkShippingFee($carrier, $shipping_country) { //cheking shipping fees for the shipping method
218
- $orderPrice = Mage::getModel('checkout/session')->getQuote()->getGrandTotal(); //getting order total
219
- $orderWeight = Mage::registry('ordweight'); //getting order weight
220
 
221
  if (Mage::getStoreConfig('carriers/' . $carrier . '/price') != "") {
222
  $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/' . $carrier . '/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
@@ -233,12 +139,14 @@ class Smartsend_Logistics_Model_ShippingMethods extends Varien_Object {
233
  if (is_array($pickupShippingRates)) {
234
 
235
  foreach ($pickupShippingRates as $pickupShippingRate) {
236
- $countries = explode(',', $pickupShippingRate['countries']);
237
- $countries = array_map("strtoupper", $countries);
238
-
239
- if(in_array(strtoupper($shipping_country), $countries)
240
- && (float)$pickupShippingRate['orderminprice'] <= (float)$orderPrice && (float)$pickupShippingRate['ordermaxprice'] >= (float)$orderPrice
241
- && (float)$pickupShippingRate['orderminweight'] <= (float)$orderWeight && (float)$pickupShippingRate['ordermaxweight'] >= (float)$orderWeight
 
 
242
  ) {
243
 
244
  // The shipping rate is valid.
@@ -247,28 +155,50 @@ class Smartsend_Logistics_Model_ShippingMethods extends Varien_Object {
247
  //There is already a shipping method with the name in the array of valid shipping methods.
248
  if ( (int)$cheapestexpensive == 0 && ( (float) $shippingmethods[$pickupShippingRate['methods']] > (float) $pickupShippingRate['pickupshippingfee'] )) {
249
  //This method is cheaper and will override existing shipping method
250
- $shippingmethods[$pickupShippingRate['methods']] = $pickupShippingRate['pickupshippingfee'];
 
 
 
251
  } elseif ( (int)$cheapestexpensive == 1 && ( (float) $shippingmethods[$rates['methods']] < (float) $pickupShippingRate['pickupshippingfee'] )) {
252
  //This method is more expensive and will override existing shipping method
253
- $shippingmethods[$pickupShippingRate['methods']] = $pickupShippingRate['pickupshippingfee'];
 
 
 
 
254
  }
255
  } else {
256
  //Add the shipping method to the array of valid methods.
257
- $shippingmethods[$pickupShippingRate['methods']] = $pickupShippingRate['pickupshippingfee'];
 
 
 
 
258
  }
259
 
260
  }
261
  }
262
  }
 
263
  return $shippingmethods;
264
  }
265
 
266
- public function getLabel() { //generate label method
267
- // Dummy function that is not used
268
- }
 
 
 
 
 
 
269
 
270
- public function getReturnLabel() { //generate label method
271
- // Dummy function that is not used
 
 
 
 
 
272
  }
273
-
274
  }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/ShippingMethods.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
25
  */
26
  class Smartsend_Logistics_Model_ShippingMethods extends Varien_Object {
27
 
28
+ /**
29
+ * Function to return an array of shipping methods for a given carrier
30
+ *
31
+ * @param string $carrier is the carrier id formatted as 'groups[$carrier]'
32
+ *
33
+ * @return array of shipping methods with key as id and value as translated name
34
+ */
35
  static public function getOptionArray($carrier) {
36
 
 
37
  $carrier_name = explode('groups[', $carrier); //getting carrier name
 
38
  $carrier_name = explode(']', $carrier_name[1]);
 
39
  $carrier_name = $carrier_name[0];
40
 
41
+ return self::getShippingMethodByCarrier($carrier_name);
42
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
+
45
+ /**
46
+ * Function to return an array of shipping methods for a given carrier
47
+ *
48
+ * @param string $carrier_name is the id of the carrier
49
+ *
50
+ * @return array $shipping_methods of shipping methods with key as id and value as translated name
51
+ */
52
+ static public function getShippingMethodByCarrier($carrier_name) {
53
+
54
+ switch ($carrier_name) {
55
+ case 'smartsendbring':
56
+ //All Bring shipping methods
57
+ $shipping_methods = array(
58
+ 'pickup' => Mage::helper('logistics')->__('Pickuppoint'),
59
+ 'private' => Mage::helper('logistics')->__('Private'),
60
+ 'privatehome' => Mage::helper('logistics')->__('Private to home'),
61
+ 'commercial' => Mage::helper('logistics')->__('Commercial'),
62
+ 'commercial_bulksplit' => Mage::helper('logistics')->__('Commercial Bulksplit'),
63
+ 'private_bulksplit' => Mage::helper('logistics')->__('Private Bulksplit'),
64
+ 'privatehome_bulksplit' => Mage::helper('logistics')->__('Private to home Bulksplit'),
65
+ 'express' => Mage::helper('logistics')->__('Express'),
66
+ 'miniparcel' => Mage::helper('logistics')->__('Mini parcel'),
67
+ );
68
+ break;
69
+ case 'smartsendpostdanmark':
70
+ //All Post Danmark shipping methods
71
+ $shipping_methods = array(
72
+ 'pickup' => Mage::helper('logistics')->__('Pickuppoint'),
73
+ 'private' => Mage::helper('logistics')->__('Private'),
74
+ 'privatehome' => Mage::helper('logistics')->__('Private to home'),
75
+ 'commercial' => Mage::helper('logistics')->__('Commercial'),
76
+ 'dpdclassic' => Mage::helper('logistics')->__('DPD Classic'),
77
+ 'dpdguarantee' => Mage::helper('logistics')->__('DPD Guarantee'),
78
+ 'valuemail' => Mage::helper('logistics')->__('Value mail'),
79
+ 'privatesamsending' => Mage::helper('logistics')->__('Private collective'),
80
+ 'privatepriority' => Mage::helper('logistics')->__('Private priority'),
81
+ 'privateeconomy' => Mage::helper('logistics')->__('Private economy'),
82
+ 'lastmile' => Mage::helper('logistics')->__('Service Logistics'),
83
+ 'businesspriority' => Mage::helper('logistics')->__('Commercial priority'),
84
+ );
85
+ // If vConnect is installed remove pickup as shipping method
86
+ if(Mage::helper('logistics/data')->isVconnetEnabled() == true) {
87
+ unset($shipping_methods['pickup']);
88
+ }
89
+ break;
90
+ case 'smartsendposten':
91
+ //All Posten shipping methods
92
+ $shipping_methods = array(
93
+ 'pickup' => Mage::helper('logistics')->__('Pickuppoint'),
94
+ 'private' => Mage::helper('logistics')->__('Private'),
95
+ 'privatehome' => Mage::helper('logistics')->__('Private to home'),
96
+ 'commercial' => Mage::helper('logistics')->__('Commercial'),
97
+ 'valuemail' => Mage::helper('logistics')->__('Value mail'),
98
+ 'valuemailfirstclass' => Mage::helper('logistics')->__('Value mail first class'),
99
+ 'valuemaileconomy' => Mage::helper('logistics')->__('Value mail economy'),
100
+ 'maximail' => Mage::helper('logistics')->__('Maxi mail'),
101
+ );
102
+ // If vConnect is installed remove pickup as shipping method
103
+ if(Mage::helper('logistics/data')->isVconnetEnabled() == true) {
104
+ unset($shipping_methods['pickup']);
105
+ }
106
+ break;
107
+ case 'smartsendgls':
108
+ //All GLS shipping methods
109
+ $shipping_methods = array(
110
+ 'pickup' => Mage::helper('logistics')->__('Pickuppoint'),
111
+ 'private' => Mage::helper('logistics')->__('Private'),
112
+ 'privatehome' => Mage::helper('logistics')->__('Private to home'),
113
+ 'commercial' => Mage::helper('logistics')->__('Commercial'),
114
+ );
115
+ break;
116
+ default:
117
+ $shipping_methods = array();
118
+ break;
119
+ }
120
+
121
+ return $shipping_methods;
122
+
123
  }
124
 
125
+ public function checkShippingFee($carrier, $shipping_country, $orderPrice, $orderWeight) { //cheking shipping fees for the shipping method
 
 
126
 
127
  if (Mage::getStoreConfig('carriers/' . $carrier . '/price') != "") {
128
  $pickupShippingRates = unserialize(Mage::getStoreConfig('carriers/' . $carrier . '/price', Mage::app()->getStore())); //unserializing the shipping rates from the shipping rate table
139
  if (is_array($pickupShippingRates)) {
140
 
141
  foreach ($pickupShippingRates as $pickupShippingRate) {
142
+ $countries = strtoupper(str_replace(" ", "",$pickupShippingRate['countries']));
143
+ $countries = explode(',', $countries);
144
+
145
+ if( (in_array(strtoupper($shipping_country), $countries) || in_array('*', $countries))
146
+ && (float)$pickupShippingRate['orderminprice'] <= (float)$orderPrice
147
+ && ( (float)$pickupShippingRate['ordermaxprice'] >= (float)$orderPrice || (float)$pickupShippingRate['ordermaxprice'] == 0)
148
+ && (float)$pickupShippingRate['orderminweight'] <= (float)$orderWeight
149
+ && ( (float)$pickupShippingRate['ordermaxweight'] >= (float)$orderWeight || (float)$pickupShippingRate['ordermaxweight'] == 0)
150
  ) {
151
 
152
  // The shipping rate is valid.
155
  //There is already a shipping method with the name in the array of valid shipping methods.
156
  if ( (int)$cheapestexpensive == 0 && ( (float) $shippingmethods[$pickupShippingRate['methods']] > (float) $pickupShippingRate['pickupshippingfee'] )) {
157
  //This method is cheaper and will override existing shipping method
158
+ $shippingmethods[$pickupShippingRate['methods']] = array(
159
+ 'shippingfee' => $pickupShippingRate['pickupshippingfee'],
160
+ 'frontend_title' => $pickupShippingRate['method_name']
161
+ );
162
  } elseif ( (int)$cheapestexpensive == 1 && ( (float) $shippingmethods[$rates['methods']] < (float) $pickupShippingRate['pickupshippingfee'] )) {
163
  //This method is more expensive and will override existing shipping method
164
+ $shippingmethods[$pickupShippingRate['methods']] = array(
165
+ 'shippingfee' => $pickupShippingRate['pickupshippingfee'],
166
+ 'frontend_title' => $pickupShippingRate['method_name']
167
+ );
168
+
169
  }
170
  } else {
171
  //Add the shipping method to the array of valid methods.
172
+ $shippingmethods[$pickupShippingRate['methods']] = array(
173
+ 'shippingfee' => $pickupShippingRate['pickupshippingfee'],
174
+ 'frontend_title' => $pickupShippingRate['method_name']
175
+ );
176
+
177
  }
178
 
179
  }
180
  }
181
  }
182
+
183
  return $shippingmethods;
184
  }
185
 
186
+
187
+ public function excludedTax($shipping_method){
188
+ $shippingmethods=array();
189
+
190
+ $shippingmethods[]='smartsendpostdanmark_pickup';
191
+ $shippingmethods[]='smartsendpostdanmark_private';
192
+ $shippingmethods[]='smartsendpostdanmark_privatehome';
193
+ $shippingmethods[]='smartsendpostdanmark_privatepriority';
194
+ $shippingmethods[]='smartsendpostdanmark_valuemail';
195
 
196
+
197
+ if(in_array($shipping_method,$shippingmethods)){
198
+ return true;
199
+ }else{
200
+ return false;
201
+ }
202
+
203
  }
 
204
  }
app/code/community/Smartsend/Logistics/Model/System/.DS_Store ADDED
Binary file
app/code/community/Smartsend/Logistics/Model/System/CombinePdf.php CHANGED
@@ -26,9 +26,9 @@
26
 
27
  class Smartsend_Logistics_Model_System_CombinePdf extends Mage_Core_Model_Config_Data {
28
 
29
- public function toOptionArray() { //Cheapest or Most Expensive method
30
- $opt[] = array('value' => 0, 'label' => Mage::helper('adminhtml')->__("Seperate pdf's"));
31
- $opt[] = array('value' => 1, 'label' => Mage::helper('adminhtml')->__("Combine pdf's into one file"));
32
  return $opt;
33
  }
34
 
26
 
27
  class Smartsend_Logistics_Model_System_CombinePdf extends Mage_Core_Model_Config_Data {
28
 
29
+ public function toOptionArray() {
30
+ $opt[] = array('value' => 1, 'label' => Mage::helper('logistics')->__("Merged PDF file"));
31
+ $opt[] = array('value' => 0, 'label' => Mage::helper('logistics')->__("Separate PDF files"));
32
  return $opt;
33
  }
34
 
app/code/community/Smartsend/Logistics/Model/System/Listformat.php CHANGED
@@ -27,10 +27,10 @@
27
  class Smartsend_Logistics_Model_System_Listformat extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() { //address list format for the admin system config
30
- $opt[1] = array('value' => 1, 'label' => Mage::helper('adminhtml')->__("#Company, #Street, #Zipcode #City"));
31
- $opt[2] = array('value' => 2, 'label' => Mage::helper('adminhtml')->__("#Company, #Street, #Zipcode"));
32
- $opt[3] = array('value' => 3, 'label' => Mage::helper('adminhtml')->__("#Company, #Street, #City"));
33
- $opt[4] = array('value' => 4, 'label' => Mage::helper('adminhtml')->__("#Company, #Street"));
34
  return $opt;
35
  }
36
 
27
  class Smartsend_Logistics_Model_System_Listformat extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() { //address list format for the admin system config
30
+ $opt[1] = array('value' => 1, 'label' => "#".Mage::helper('logistics')->__("Company").", #".Mage::helper('logistics')->__("Street").", #".Mage::helper('logistics')->__("Zipcode")." #".Mage::helper('logistics')->__("City"));
31
+ $opt[2] = array('value' => 2, 'label' => "#".Mage::helper('logistics')->__("Company").", #".Mage::helper('logistics')->__("Street").", #".Mage::helper('logistics')->__("Zipcode"));
32
+ $opt[3] = array('value' => 3, 'label' => "#".Mage::helper('logistics')->__("Company").", #".Mage::helper('logistics')->__("Street").", #".Mage::helper('logistics')->__("City"));
33
+ $opt[4] = array('value' => 4, 'label' => "#".Mage::helper('logistics')->__("Company").", #".Mage::helper('logistics')->__("Street"));
34
  return $opt;
35
  }
36
 
app/code/community/Smartsend/Logistics/Model/System/OrderOption.php CHANGED
@@ -27,8 +27,8 @@
27
  class Smartsend_Logistics_Model_System_OrderOption extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() { //Cheapest or Most Expensive method
30
- $opt[] = array('value' => 0, 'label' => Mage::helper('adminhtml')->__("Cheapest"));
31
- $opt[] = array('value' => 1, 'label' => Mage::helper('adminhtml')->__("Most Expensive"));
32
  return $opt;
33
  }
34
 
27
  class Smartsend_Logistics_Model_System_OrderOption extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() { //Cheapest or Most Expensive method
30
+ $opt[] = array('value' => 0, 'label' => Mage::helper('logistics')->__("Cheapest"));
31
+ $opt[] = array('value' => 1, 'label' => Mage::helper('logistics')->__("Most expensive"));
32
  return $opt;
33
  }
34
 
app/code/community/Smartsend/Logistics/Model/System/Pacsoftformat.php CHANGED
@@ -27,8 +27,8 @@
27
  class Smartsend_Logistics_Model_System_Pacsoftformat extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() {
30
- $opt[] = array('value' => 'link', 'label' => Mage::helper('adminhtml')->__("Pacsoft link"));
31
- $opt[] = array('value' => 'pdf', 'label' => Mage::helper('adminhtml')->__("PDF file"));
32
  return $opt;
33
  }
34
 
27
  class Smartsend_Logistics_Model_System_Pacsoftformat extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() {
30
+ $opt[] = array('value' => 'link', 'label' => Mage::helper('logistics')->__("Pacsoft link"));
31
+ $opt[] = array('value' => 'pdf', 'label' => Mage::helper('logistics')->__("PDF file"));
32
  return $opt;
33
  }
34
 
app/code/community/Smartsend/Logistics/Model/System/{PickupMethods.php → Postdanmark/Flexdelivery.php} RENAMED
@@ -17,23 +17,26 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/System/PickupMethods.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
 
27
 
28
- class Smartsend_Logistics_Model_System_PickupMethods extends Mage_Core_Model_Config_Data {
 
 
 
 
 
 
 
 
29
 
30
- public function toOptionArray() { //different pickup methods
31
- $opt[] = array('value' => 'postdanmark', 'label' => Mage::helper('adminhtml')->__("PostDanmark"));
32
- $opt[] = array('value' => 'swipbox', 'label' => Mage::helper('adminhtml')->__("Swipbox"));
33
- $opt[] = array('value' => 'bring', 'label' => Mage::helper('adminhtml')->__("Bring"));
34
- $opt[] = array('value' => 'gls', 'label' => Mage::helper('adminhtml')->__("GLS"));
35
- $opt[] = array('value' => 'posten', 'label' => Mage::helper('adminhtml')->__("Posten"));
36
- return $opt;
37
  }
38
 
39
  }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/System/Postdanmark/Flexdelivery.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
+ class Smartsend_Logistics_Model_System_Postdanmark_Flexdelivery extends Mage_Core_Model_Config_Data {
28
 
29
+ public function toOptionArray()
30
+ {
31
+ $carrier = 'smartsendpostdanmark';
32
+ $shipping_methods = Mage::getModel('logistics/ShippingMethods')->getShippingMethodByCarrier( $carrier );
33
+
34
+ $option_array = array();
35
+ foreach($shipping_methods as $shipping_method_key => $shipping_method_value) {
36
+ $option_array[] = array('value' => $carrier.'_'.$shipping_method_key, 'label' => $shipping_method_value);
37
+ }
38
 
39
+ return $option_array;
 
 
 
 
 
 
40
  }
41
 
42
  }
app/code/community/Smartsend/Logistics/Model/System/{Pickup/Listformat.php → Posten/Flexdelivery.php} RENAMED
@@ -17,18 +17,26 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/System/Pickup/Listformat.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
- class Smartsend_Logistics_Model_System_Pickup_Listformat extends Smartsend_Logistics_Model_System_Listformat {
28
 
29
- public function toOptionArray() { //address list format for the admin system config
30
- $opt[0] = array('value' => 0, 'label' => Mage::helper('adminhtml')->__("#Company, #Street, #Zipcode #City (#Carrier)"));
31
- return $opt + parent::toOptionArray();
 
 
 
 
 
 
 
 
32
  }
33
 
34
  }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/System/Posten/Flexdelivery.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
+ class Smartsend_Logistics_Model_System_Posten_Flexdelivery extends Mage_Core_Model_Config_Data {
28
 
29
+ public function toOptionArray()
30
+ {
31
+ $carrier = 'smartsendposten';
32
+ $shipping_methods = Mage::getModel('logistics/ShippingMethods')->getShippingMethodByCarrier( $carrier );
33
+
34
+ $option_array = array();
35
+ foreach($shipping_methods as $shipping_method_key => $shipping_method_value) {
36
+ $option_array[] = array('value' => $carrier.'_'.$shipping_method_key, 'label' => $shipping_method_value);
37
+ }
38
+
39
+ return $option_array;
40
  }
41
 
42
  }
app/code/community/Smartsend/Logistics/Model/System/Return.php CHANGED
@@ -27,11 +27,11 @@
27
  class Smartsend_Logistics_Model_System_Return extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() { //address list format for the admin system config
30
- $opt[] = array('value' => '', 'label' => Mage::helper('adminhtml')->__("Same carrier"));
31
- $opt[] = array('value' => 'smartsendpostdanmark_private', 'label' => Mage::helper('adminhtml')->__("Post Danmark"));
32
- $opt[] = array('value' => 'smartsendgls_private', 'label' => Mage::helper('adminhtml')->__("GLS"));
33
- $opt[] = array('value' => 'smartsendbring_private', 'label' => Mage::helper('adminhtml')->__("Bring"));
34
- $opt[] = array('value' => 'smartsendposten_private', 'label' => Mage::helper('adminhtml')->__("Posten"));
35
  return $opt;
36
  }
37
 
27
  class Smartsend_Logistics_Model_System_Return extends Mage_Core_Model_Config_Data {
28
 
29
  public function toOptionArray() { //address list format for the admin system config
30
+ $opt[] = array('value' => '', 'label' => Mage::helper('logistics')->__("Same carrier"));
31
+ $opt[] = array('value' => 'smartsendpostdanmark_private', 'label' => Mage::helper('logistics')->__("Post Danmark"));
32
+ $opt[] = array('value' => 'smartsendgls_private', 'label' => Mage::helper('logistics')->__("GLS"));
33
+ $opt[] = array('value' => 'smartsendbring_private', 'label' => Mage::helper('logistics')->__("Bring"));
34
+ $opt[] = array('value' => 'smartsendposten_private', 'label' => Mage::helper('logistics')->__("Posten"));
35
  return $opt;
36
  }
37
 
app/code/community/Smartsend/Logistics/Model/System/{Size.php → Status.php} RENAMED
@@ -17,20 +17,26 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/System/Pickup/Size.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
- class Smartsend_Logistics_Model_System_Size extends Mage_Core_Model_Config_Data {
 
 
 
 
 
 
 
 
 
 
28
 
29
- public function toOptionArray() {
30
- $opt[] = array('value' => 0, 'label' => Mage::helper('adminhtml')->__("Small"));
31
- $opt[] = array('value' => 1, 'label' => Mage::helper('adminhtml')->__("Medium"));
32
- $opt[] = array('value' => 2, 'label' => Mage::helper('adminhtml')->__("Large"));
33
  return $opt;
34
  }
35
 
36
- }
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/Model/System/Status.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
 
27
+ class Smartsend_Logistics_Model_System_Status extends Mage_Core_Model_Config_Data {
28
+
29
+ public function toOptionArray() { //address list format for the admin system config
30
+
31
+ $opt[] = array('value' => '', 'label' => Mage::helper('logistics')->__("Don't change order status"));
32
+
33
+ // Create status array
34
+ $all_status = Mage::getModel('sales/order_status')->getResourceCollection()->getData();
35
+ foreach($all_status as $single_status) {
36
+ $opt[] = array('value' => $single_status["status"], 'label' => $single_status["label"]);
37
+ }
38
 
 
 
 
 
39
  return $opt;
40
  }
41
 
42
+ }
app/code/community/Smartsend/Logistics/Model/System/Validateuser.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * GoMage LightCheckout Extension
4
+ *
5
+ * @category Extension
6
+ * @copyright Copyright (c) 2010-2015 GoMage (http://www.gomage.com)
7
+ * @author GoMage
8
+ * @license http://www.gomage.com/license-agreement/ Single domain license
9
+ * @terms of use http://www.gomage.com/terms-of-use
10
+ * @version Release: 5.9
11
+ * @since Class available since Release 2.0
12
+ */
13
+
14
+ class Smartsend_Logistics_Model_System_Validateuser extends Mage_Adminhtml_Block_System_Config_Form_Field {
15
+
16
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
17
+ {
18
+
19
+ $r = Mage::getStoreConfig('gomage_activation/lightcheckout/ar');
20
+
21
+ $validation = false;
22
+
23
+ if($validation) {
24
+ return sprintf('<strong class="required">%s</strong>', $this->__('User account verified'));
25
+
26
+ } else {
27
+ return sprintf('<strong class="required">%s</strong>', $this->__('Please enter a valid key'));
28
+ }
29
+
30
+ }
31
+ }
app/code/community/Smartsend/Logistics/controllers/LogisticsController.php CHANGED
@@ -1,19 +1,32 @@
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  class Smartsend_Logistics_LogisticsController extends Mage_Adminhtml_Controller_Action {
4
 
5
- protected $request=array();
6
- protected $response;
7
-
8
- /*
9
- $label = Mage::getModel('logistics/shippingMethods')->getLabel(); //calling label method in: /app/code/community/Smartsend/Logistics/Model/ShippingMethods.php
10
- $returnlabel = Mage::getModel('logistics/shippingMethods')->getReturnLabel(); //calling label method in: /app/code/community/Smartsend/Logistics/Model/ShippingMethods.php
11
- $this->_getSession()->addSuccess('Success message 2');
12
- $this->_getSession()->addNotice('Notice message 2');
13
- $this->_getSession()->addError('Error message 2');
14
- */
15
-
16
-
17
  /***********
18
  * Functions called from action buttons
19
  ***********/
@@ -22,125 +35,79 @@ class Smartsend_Logistics_LogisticsController extends Mage_Adminhtml_Controller_
22
  /*
23
  * Action: Create single order
24
  */
25
- public function labelAction() { //label action
26
- $orderId = $this->getRequest()->getParam('order_id');
27
- $order = Mage::getModel('sales/order')->load($orderId);
28
 
29
- if((Mage::getStoreConfig('carriers/smartsend/username') == '' || Mage::getStoreConfig('carriers/smartsend/licencekey') == '') &&
30
- (Mage::getStoreConfig('vconnect_postnord/general/username') == '' || Mage::getStoreConfig('vconnect_postnord/general/license_key') == '')) {
31
- $this->_getSession()->addError($this->__("Username and licencekey must be entered in settings"));
32
- } else {
33
- $this->createOrder($order,false);
34
-
35
- if($this->isRequest()) {
36
- try{
37
- $this->postRequest(true);
38
- $this->handleRequest();
39
- } catch(Exception $e) {
40
- $this->_getSession()->addError($e->getMessage());
41
- }
42
- }
43
- }
44
-
45
  $this->_redirectReferer();
46
- return ;
47
  }
48
 
49
  /*
50
  * Action: Create array of orders
51
  */
52
- public function labelMassAction() { //label mass action
53
 
54
- if((Mage::getStoreConfig('carriers/smartsend/username') == '' || Mage::getStoreConfig('carriers/smartsend/licencekey') == '') &&
55
- (Mage::getStoreConfig('vconnect_postnord/general/username') == '' || Mage::getStoreConfig('vconnect_postnord/general/license_key') == '')) {
56
- $this->_getSession()->addError($this->__("Username and licencekey must be entered in settings"));
57
- } else {
58
-
59
- $orderIds = $this->getRequest()->getPost('order_ids');
60
- if (!empty($orderIds)) {
61
- foreach($orderIds as $orderId) {
62
- $order = Mage::getModel('sales/order')->load($orderId);
63
- $this->createOrder($order,false);
64
- }
65
- } else {
66
- $this->_getSession()->addError($this->__('No orders selected'));
67
- }
68
-
69
- if($this->isRequest()) {
70
- try{
71
- $this->postRequest(false);
72
- $this->handleRequest();
73
- } catch(Exception $e) {
74
- $this->_getSession()->addError($e->getMessage());
75
- }
76
- }
77
-
78
- }
79
-
80
  $this->_redirectReferer();
81
- return ;
82
  }
83
 
84
  /*
85
  * Action: Create single return order
86
  */
87
- public function labelreturnAction() { // return label action
88
- $orderId = $this->getRequest()->getParam('order_id');
89
- $order = Mage::getModel('sales/order')->load($orderId);
90
 
91
- if((Mage::getStoreConfig('carriers/smartsend/username') == '' || Mage::getStoreConfig('carriers/smartsend/licencekey') == '') &&
92
- (Mage::getStoreConfig('vconnect_postnord/general/username') == '' || Mage::getStoreConfig('vconnect_postnord/general/license_key') == '')) {
93
- $this->_getSession()->addError($this->__("Username and licencekey must be entered in settings"));
94
- } else {
95
- $this->createOrder($order,true);
96
-
97
- if($this->isRequest()) {
98
- try{
99
- $this->postRequest(true);
100
- $this->handleRequest();
101
- } catch(Exception $e) {
102
- $this->_getSession()->addError($e->getMessage());
103
- }
104
- }
105
- }
106
-
107
  $this->_redirectReferer();
108
- return ;
109
  }
110
 
111
  /*
112
  * Action: Create array of return orders
113
  */
114
- public function labelreturnMassAction() { //label return mass action
 
 
 
 
 
 
 
 
115
 
116
- if((Mage::getStoreConfig('carriers/smartsend/username') == '' || Mage::getStoreConfig('carriers/smartsend/licencekey') == '') &&
117
- (Mage::getStoreConfig('vconnect_postnord/general/username') == '' || Mage::getStoreConfig('vconnect_postnord/general/license_key') == '')) {
118
- $this->_getSession()->addError($this->__("Username and licencekey must be entered in settings"));
119
- } else {
120
 
121
- $orderIds = $this->getRequest()->getPost('order_ids');
122
- if (!empty($orderIds)) {
123
- foreach($orderIds as $orderId) {
124
- $order = Mage::getModel('sales/order')->load($orderId);
125
- $this->createOrder($order,true);
126
- }
127
- } else {
128
- $this->_getSession()->addError($this->__('No orders selected'));
129
- }
130
-
131
- if($this->isRequest()) {
132
- try{
133
- $this->postRequest(false);
134
- $this->handleRequest();
135
- } catch(Exception $e) {
136
- $this->_getSession()->addError($e->getMessage());
137
- }
138
- }
139
-
140
- }
141
-
142
  $this->_redirectReferer();
143
- return ;
144
  }
145
 
146
 
@@ -148,252 +115,68 @@ class Smartsend_Logistics_LogisticsController extends Mage_Adminhtml_Controller_
148
  /***********
149
  * Functions used to generate labels
150
  ***********/
151
-
152
- /*
153
- * Function: is there a requerst?
154
- * both for single and mass generation
155
- */
156
- private function isRequest() {
157
- if(empty($this->request)) {
158
- return false;
159
- } else {
160
- return true;
161
- }
162
- }
163
-
164
-
165
- /*
166
- * Function: Get JSON request
167
- * both for single and mass generation
168
- */
169
- private function getJsonRequest() {
170
- if(empty($this->request)) {
171
- throw new Exception($this->__("Trying to send empty order array"));
172
- } else {
173
- return json_encode($this->request);
174
- }
175
- }
176
-
177
- /*
178
- * Function: Create an order request
179
- * both for single and mass generation
180
- */
181
- private function createOrder($order,$return=false) {
182
-
183
- $smartsendorder = Mage::getModel('logistics/order');
184
- $smartsendorder->setOrderObject($order);
185
- $smartsendorder->setReturn($return);
186
- try {
187
- $smartsendorder->setInfo();
188
- $smartsendorder->setReceiver();
189
- $smartsendorder->setSender();
190
- $smartsendorder->setAgent();
191
- $smartsendorder->setService();
192
- $smartsendorder->setParcels();
193
-
194
- //All done. Add to request.
195
- $this->request[] = $smartsendorder->getFinalOrder();
196
-
197
- //$this->_getSession()->addNotice("Order " . $order->getIncrementId() .": ".json_encode($smartsendorder->getFinalOrder()));
198
- } catch(Exception $e) {
199
- $this->_getSession()->addError("Order #" . $order->getIncrementId() .": ".$e->getMessage());
200
- }
201
- }
202
-
203
- /*
204
- * Function: POST final cURL request
205
- * both for single and mass generation
206
- */
207
- private function postRequest($single=false) {
208
-
209
- $ch = curl_init(); //intitiate curl
210
 
211
- /* Script URL */
212
- if($single == true) {
213
- $url = 'https://smartsend-prod.apigee.net/v7/booking/order';
214
- } elseif($single == false) {
215
- $url = 'https://smartsend-prod.apigee.net/v7/booking/orders';
216
- } else {
217
- throw new Exception('Unknown post method: '.$single);
218
- }
219
-
220
- if(Mage::getStoreConfig('carriers/smartsend/username') == '' && Mage::helper('core')->isModuleEnabled('Vconnect_Postnord')) {
221
- $username = Mage::getStoreConfig('vconnect_postnord/general/username');
222
- $licensekey = Mage::getStoreConfig('vconnect_postnord/general/license_key');
223
- } else {
224
- $username = Mage::getStoreConfig('carriers/smartsend/username');
225
- $licensekey = Mage::getStoreConfig('carriers/smartsend/licencekey');
226
- }
227
-
228
- curl_setopt($ch, CURLOPT_URL, $url); //curl url
229
- curl_setopt($ch, CURLOPT_POST, true);
230
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->getJsonRequest());
231
- //curl_setopt($ch, CURLOPT_HTTPGET, true); //curl request method
232
- //curl_setopt($ch, CURLOPT_HEADER, false);
233
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
234
- 'apikey:yL18TETUVQ7E9pgVb6JeV1erIYHAMcwe',
235
- 'smartsendmail:'.$username,
236
- 'smartsendlicence:'.$licensekey,
237
- 'cmssystem:Magento',
238
- 'cmsversion:'.Mage::getVersion(),
239
- 'appversion:'.Mage::getConfig()->getNode('modules/Smartsend_Logistics')->version,
240
- 'Content-Type:application/json; charset=UTF-8'
241
- )); //curl request header
242
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
243
-
244
- $this->response = new StdClass(); //creating new class
245
- $this->response->body = curl_exec($ch); //executing the curl
246
- $this->response->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
247
- $this->response->meta = curl_getinfo($ch);
248
- $curl_error = ($this->response->code > 0 ? null : curl_error($ch) . ' (' . curl_errno($ch) . ')'); //getting error from curl if any
249
-
250
- curl_close($ch); //closing the curl
251
-
252
- if ($curl_error) {
253
- throw new Exception($this->__('An error occurred while sending order').': ' . $curl_error);
254
- }
255
-
256
- if(!($this->response->code >= '200') || !($this->response->code <= '210')) {
257
- throw new Exception($this->__('Response').': ('.$this->response->code.') '.$this->response->body);
258
- }
259
-
260
- }
261
-
262
-
263
- /*
264
- * Add Track and Trace number to parcels
265
- * @string shipment_reference: unique if of shipment
266
- * @string tracecode
267
- */
268
- private function addTraceToShipment($shipment_reference,$tracecode) {
269
-
270
- /* $shipment_collection = Mage::getResourceModel('sales/order_shipment_collection');
271
- $shipment_collection->addAttributeToFilter('order_id', $order_id);
272
-
273
- foreach($shipment_collection as $sc) {
274
- $shipment = Mage::getModel('sales/order_shipment');
275
- $shipment->load($sc->getId());
276
- if($shipment->getId() != '') {
277
- $track = Mage::getModel('sales/order_shipment_track')
278
- ->setShipment($shipment)
279
- ->setData('title', 'ShippingMethodName')
280
- ->setData('number', $track_no)
281
- ->setData('carrier_code', 'ShippingCarrierCode')
282
- ->setData('order_id', $shipment->getData('order_id'))
283
- ->save();
284
- }
285
- } */
286
-
287
- $shipment = Mage::getModel('sales/order_shipment');
288
- $shipment->load($shipment_reference);
289
- if($shipment->getId() != '') {
290
- $order = Mage::getModel('sales/order')->load($shipment->getData('order_id'));
291
- $smartsendorder = Mage::getModel('logistics/order');
292
- $smartsendorder->setOrderObject($order);
293
-
294
- $track = Mage::getModel('sales/order_shipment_track')
295
- ->setShipment($shipment)
296
- ->setData('title', $smartsendorder->getShippingMethod())
297
- ->setData('number', $tracecode)
298
- ->setData('carrier_code', $smartsendorder->getShippingCarrierId())
299
- ->setData('order_id', $shipment->getData('order_id'))
300
- ->save();
301
- } else {
302
- throw new Exception($this->__('Failed to insert tracecode'));
303
- }
304
-
305
- }
306
-
307
- /*
308
- * Function: go through parcels and add trace code
309
- */
310
- private function verifyParcels($json) {
311
- if(isset($json->parcels) && is_array($json->parcels)) {
312
- foreach($json->parcels as $parcel) {
313
- if(isset($parcel->reference) && $parcel->reference != '' && isset($parcel->tracecode) && $parcel->tracecode != '') {
314
- $this->addTraceToShipment($parcel->reference, $parcel->tracecode);
315
- }
316
- }
317
- }
318
- }
319
 
 
320
 
321
- /*
322
- * Function: Handle cURL response
323
- * both for single and mass generation
324
- */
325
- private function handleRequest() {
326
- if(strpos($this->response->meta['content_type'],'json') !== false) {
327
- $json = json_decode($this->response->body);
328
- /* $this->_getSession()->addNotice($this->getJsonRequest());
329
- $this->_getSession()->addNotice($this->response->body); */
330
-
331
- //Show a notice if info is given
332
- if(isset($json->info)) {
333
- if(is_array($json->info)) {
334
- foreach($json->info as $info) {
335
- $this->_getSession()->addNotice($info);
336
- }
337
- } else {
338
- $this->_getSession()->addNotice($json->info);
339
- }
340
- }
341
-
342
- if(isset($json->combine_pdf) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1) {
343
- $this->_getSession()->addSuccess('<a href="'. $json->combine_pdf .'" target="_blank">Combined PDF labels</a>');
344
- }
345
-
346
- if(isset($json->combine_link) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1) {
347
- $this->_getSession()->addSuccess('<a href="'. $json->combine_link .'" target="_blank">Combined label links</a>');
348
- }
349
-
350
- if(isset($json->orders) && is_array($json->orders)) {
351
- // An array of orders was returned
352
- foreach($json->orders as $json_order) {
353
- if(isset($json_order->pdflink) && !(isset($json->combine_pdf) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1)) {
354
- $this->_getSession()->addSuccess('Order #'.$json_order->orderno.': <a href="'. $json_order->pdflink .'" target="_blank">PDF label</a>');
355
- // Go through parcels and add trace to shipments
356
- $this->verifyParcels($json_order);
357
- } elseif(isset($json_order->link) && !(isset($json->combine_link) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1)) {
358
- $this->_getSession()->addSuccess('Order #'.$json_order->orderno.': <a href="'. $json_order->link .'" target="_blank">Label link</a>');
359
- // Go through parcels and add trace to shipments
360
- $this->verifyParcels($json_order);
361
- } elseif( (isset($json_order->pdflink) || isset($json_order->link) ) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1) {
362
- $this->_getSession()->addSuccess('Order #'.$json_order->orderno.': '. $json_order->message);
363
- $this->verifyParcels($json_order);
364
  } else {
365
- if(isset($json_order->status) && $json_order->status != '') {
366
- $this->_getSession()->addError('Order #'.$json_order->orderno.': '. $json_order->message);
367
- } else {
368
- $this->_getSession()->addError($this->__('Unknown status').': '. $json_order->message);
369
- }
370
  }
371
  }
372
-
373
- } else {
374
- // An array of orders was not returned. Check if just a single order was returned
375
-
376
- if(isset($json->pdflink) && !(isset($json->combine_pdf) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1)) {
377
- $this->_getSession()->addSuccess('Order #'.$json->orderno.': <a href="'. $json->pdflink .'" target="_blank">PDF label</a>');
378
- // Go through parcels and add trace to shipments
379
- $this->verifyParcels($json);
380
- } elseif(isset($json->link) && !(isset($json->combine_link) && Mage::getStoreConfig('carriers/smartsend/combinepdf') == 1)) {
381
- $this->_getSession()->addSuccess('Order #'.$json->orderno.': <a href="'. $json->link .'" target="_blank">Label link</a>');
382
- // Go through parcels and add trace to shipments
383
- $this->verifyParcels($json);
384
  } else {
385
- if(isset($json->status) && $json->status != '') {
386
- $this->_getSession()->addError('Order #'.$json->orderno.': '. $json->message);
387
- } else {
388
- $this->_getSession()->addError($this->__('Unknown status').': '. $json->message);
389
- }
390
  }
391
  }
392
-
393
- } else {
394
- throw new Exception($this->__('Unknown content type').': '.$this->response->meta['content_type']);
395
- }
396
-
397
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
 
399
  }
1
  <?php
2
+ /**
3
+ * Smartsend_Logistics
4
+ *
5
+ * This source file is subject to the GNU General Public License v3.0
6
+ * that is bundled with this package in the file license.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.html
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@smartsend.dk so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
16
+ * versions in the future. If you wish to customize the plugin for your
17
+ * needs please refer to http://www.smartsend.dk
18
+ *
19
+ * @folder /app/code/community/Smartsend/Logistics/controllers/LogisticsController.php
20
+ * @category Smartsend
21
+ * @package Smartsend_Logistics
22
+ * @author Anders Bilfeldt
23
+ * @url www.smartsend.dk
24
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license GNU General Public License v3.0
26
+ */
27
 
28
  class Smartsend_Logistics_LogisticsController extends Mage_Adminhtml_Controller_Action {
29
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  /***********
31
  * Functions called from action buttons
32
  ***********/
35
  /*
36
  * Action: Create single order
37
  */
38
+ public function labelNormalAction() { //label action
39
+
40
+ $order_id = $this->getRequest()->getParam('order_id');
41
 
42
+ $this->createLabelAction($order_id,false);
43
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  $this->_redirectReferer();
45
+ return;
46
  }
47
 
48
  /*
49
  * Action: Create array of orders
50
  */
51
+ public function labelNormalMassAction() { //label mass action
52
 
53
+ $order_ids = $this->getRequest()->getPost('order_ids');
54
+
55
+ $this->createLabelAction($order_ids,false);
56
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  $this->_redirectReferer();
58
+ return;
59
  }
60
 
61
  /*
62
  * Action: Create single return order
63
  */
64
+ public function labelReturnAction() { // return label action
 
 
65
 
66
+ $order_id = $this->getRequest()->getParam('order_id');
67
+
68
+ $this->createLabelAction($order_id,true);
69
+
 
 
 
 
 
 
 
 
 
 
 
 
70
  $this->_redirectReferer();
71
+ return;
72
  }
73
 
74
  /*
75
  * Action: Create array of return orders
76
  */
77
+ public function labelReturnMassAction() { //label return mass action
78
+
79
+ $order_ids = $this->getRequest()->getPost('order_ids');
80
+
81
+ $this->createLabelAction($order_ids,true);
82
+
83
+ $this->_redirectReferer();
84
+ return;
85
+ }
86
 
87
+ /*
88
+ * Action: Create single order + return
89
+ */
90
+ public function labelNormalReturnAction() { // return label action
91
 
92
+ $order_id = $this->getRequest()->getParam('order_id');
93
+
94
+ $this->createLabelAction($order_id,'both');
95
+
96
+ $this->_redirectReferer();
97
+ return;
98
+ }
99
+
100
+ /*
101
+ * Action: Create array of orders + return
102
+ */
103
+ public function labelNormalReturnMassAction() { //label + return mass action
104
+
105
+ $order_ids = $this->getRequest()->getPost('order_ids');
106
+
107
+ $this->createLabelAction($order_ids,'both');
108
+
 
 
 
 
109
  $this->_redirectReferer();
110
+ return;
111
  }
112
 
113
 
115
  /***********
116
  * Functions used to generate labels
117
  ***********/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
+ /*
120
+ * Function to generate a label
121
+ *
122
+ * @param array|string $order_ids is an array of the id of the orders to include in the API call or just a string of a single order id
123
+ * @param boolean $return indicated if the label is a normal (false) or return (true) label
124
+ *
125
+ * @return void
126
+ *
127
+ */
128
+ protected function createLabelAction($order_ids,$return=false) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
+ $label = Mage::getModel('logistics/labelmagento');
131
 
132
+ if(is_array($order_ids) && !empty($order_ids)) {
133
+ $label->setRequestType('bulk');
134
+ foreach($order_ids as $order_id) {
135
+ $order = Mage::getModel('sales/order')->load($order_id);
136
+ try{
137
+ if((string)$return == 'both') {
138
+ $label->addOrderToRequest($order,false);
139
+ $label->addOrderToRequest($order,true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  } else {
141
+ $label->addOrderToRequest($order,$return);
 
 
 
 
142
  }
143
  }
144
+ //catch exception
145
+ catch(Exception $e) {
146
+ $label->addErrorMessage( $this->__('Order') . ' ' . $order->getIncrementId() . ': ' . $e->getMessage() );
147
+ }
148
+ }
149
+ } elseif( !empty($order_ids) ) {
150
+ $order = Mage::getModel('sales/order')->load($order_ids);
151
+ try{
152
+ if((string)$return == 'both') {
153
+ $label->setRequestType('bulk');
154
+ $label->addOrderToRequest($order,false);
155
+ $label->addOrderToRequest($order,true);
156
  } else {
157
+ $label->setRequestType('single');
158
+ $label->addOrderToRequest($order,$return);
 
 
 
159
  }
160
  }
161
+ //catch exception
162
+ catch(Exception $e) {
163
+ $label->addErrorMessage( $this->__('Order') . ' ' . $order->getIncrementId() . ': ' . $e->getMessage() );
164
+ }
165
+ } else {
166
+ $this->_getSession()->addError($this->__('No orders selected'));
167
+ }
168
+
169
+ if( $label->hasRequestOrders() ) {
170
+ try{
171
+ $label->sendRequest();
172
+ $label->handleApiReponse($show_individual_succes);
173
+ } catch(Exception $e) {
174
+ $label->addErrorMessage( $e->getMessage() );
175
+ }
176
+ }
177
+
178
+ $label->showResult();
179
+
180
+ }
181
 
182
  }
app/code/community/Smartsend/Logistics/etc/.DS_Store ADDED
Binary file
app/code/community/Smartsend/Logistics/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Smartsend_Logistics>
5
- <version>7.0.5</version>
6
  </Smartsend_Logistics>
7
  </modules>
8
  <frontend>
@@ -33,16 +33,16 @@
33
  </layout>
34
  </frontend>
35
  <admin>
36
- <routers>
37
- <logistics>
38
- <use>admin</use>
39
- <args>
40
- <module>Smartsend_Logistics</module> <!--smartsend admin -->
41
- <frontName>logistics</frontName>
42
- </args>
43
- </logistics>
44
- </routers>
45
- </admin>
46
  <adminhtml>
47
  <translate>
48
  <modules>
@@ -136,6 +136,24 @@
136
  </sales_quote_load_after>
137
  </observers>
138
  </sales_quote_load_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  </events>
140
  <models>
141
  <logistics>
@@ -151,24 +169,15 @@
151
  <posten>
152
  <table>smartsend_pickup</table>
153
  </posten>
154
- <swipbox>
155
- <table>smartsend_pickup</table>
156
- </swipbox>
157
  <gls>
158
  <table>smartsend_pickup</table>
159
  </gls>
160
  <bring>
161
  <table>smartsend_pickup</table>
162
- </bring>
163
- <pickup>
164
- <table>smartsend_pickup</table>
165
- </pickup>
166
- <shipping>
167
- <table>shipping_rates_name</table>
168
- </shipping>
169
- <shippingrates>
170
- <table>pickup_shipping_rates</table>
171
- </shippingrates>
172
  </entities>
173
  </logistics_mysql4>
174
  </models>
@@ -216,14 +225,27 @@
216
  </rewrite>
217
  </tax>
218
  </models>
219
-
 
 
 
 
 
 
 
 
220
  </global>
221
  <default> <!-- default for the carriers -->
222
  <carriers>
223
  <smartsend>
224
  <username></username>
225
- <licencekey></licencekey>
226
- <combinepdf>0</combinepdf>
 
 
 
 
 
227
  </smartsend>
228
  <smartsendpostdanmark>
229
  <active>0</active> <!-- is not active -->
@@ -231,13 +253,13 @@
231
  <title>Post Danmark</title> <!-- title -->
232
  <cheapestexpensive>0</cheapestexpensive> <!-- is cheapest -->
233
  <excludetax>0</excludetax> <!-- Exclude from TAX -->
234
- <listformat>1</listformat> <!-- is listtype #Company, #Street, #Zipcode #City-->
235
  <format>pdf</format> <!-- format is PDF file -->
236
  <quickid>1</quickid> <!-- Default QuickId=1 -->
237
  <waybillid></waybillid> <!-- Default WaybillId=NULL -->
238
  <notemail>1</notemail> <!-- Email notification is ON -->
239
  <notesms>1</notesms> <!-- SMS notification is ON -->
240
  <prenote>0</prenote> <!-- pre-notification is OFF -->
 
241
  <return></return> <!-- standard return shipping method -->
242
  </smartsendpostdanmark>
243
  <smartsendposten>
@@ -245,14 +267,13 @@
245
  <model>logistics/carrier_posten</model>
246
  <title>Posten</title>
247
  <cheapestexpensive>0</cheapestexpensive>
248
- <excludetax>0</excludetax>
249
- <listformat>1</listformat>
250
  <format>pdf</format>
251
  <quickid>1</quickid>
252
  <waybillid></waybillid>
253
  <notemail>1</notemail>
254
  <notesms>1</notesms>
255
  <prenote>0</prenote>
 
256
  <return></return>
257
  </smartsendposten>
258
  <smartsendgls>
@@ -260,8 +281,6 @@
260
  <model>logistics/carrier_gls</model>
261
  <title>GLS</title>
262
  <cheapestexpensive>0</cheapestexpensive>
263
- <excludetax>0</excludetax>
264
- <listformat>1</listformat>
265
  <notemail>1</notemail>
266
  <notesms>1</notesms>
267
  <return></return>
@@ -271,33 +290,10 @@
271
  <model>logistics/carrier_bring</model>
272
  <title>Bring</title>
273
  <cheapestexpensive>0</cheapestexpensive>
274
- <excludetax>0</excludetax>
275
- <listformat>1</listformat>
276
  <notemail>1</notemail>
277
  <notesms>1</notesms>
278
  <return></return>
279
  </smartsendbring>
280
- <smartsendswipbox>
281
- <active>0</active>
282
- <model>logistics/carrier_swipbox</model>
283
- <title>SwipBox</title>
284
- <cheapestexpensive>0</cheapestexpensive>
285
- <excludetax>0</excludetax>
286
- <listformat>1</listformat>
287
- <size>0</size>
288
- <return></return>
289
- </smartsendswipbox>
290
- <smartsendpickup>
291
- <active>0</active>
292
- <model>logistics/carrier_pickup</model>
293
- <methods>postdanmark,swipbox,bring,gls,posten</methods>
294
- <title>Smart Send</title>
295
- <name>Closest pickup</name>
296
- <cheapestexpensive>0</cheapestexpensive>
297
- <excludetax>0</excludetax>
298
- <listformat>0</listformat>
299
- <return></return>
300
- </smartsendpickup>
301
  </carriers>
302
  </default>
303
  </config>
2
  <config>
3
  <modules>
4
  <Smartsend_Logistics>
5
+ <version>7.1.0</version>
6
  </Smartsend_Logistics>
7
  </modules>
8
  <frontend>
33
  </layout>
34
  </frontend>
35
  <admin>
36
+ <routers>
37
+ <adminhtml>
38
+ <args>
39
+ <modules>
40
+ <Smartsend_Logistics after="Mage_Adminhtml">Smartsend_Logistics</Smartsend_Logistics>
41
+ </modules>
42
+ </args>
43
+ </adminhtml>
44
+ </routers>
45
+ </admin>
46
  <adminhtml>
47
  <translate>
48
  <modules>
136
  </sales_quote_load_after>
137
  </observers>
138
  </sales_quote_load_after>
139
+ <admin_system_config_changed_section_carriers>
140
+ <observers>
141
+ <admin_system_config_changed_section_carriers>
142
+ <type>singleton</type>
143
+ <class>logistics/observer</class>
144
+ <method>changedSection</method>
145
+ </admin_system_config_changed_section_carriers>
146
+ </observers>
147
+ </admin_system_config_changed_section_carriers>
148
+ <controller_action_predispatch_adminhtml_system_config_save>
149
+ <observers>
150
+ <predispatch_adminhtml_system_config_save>
151
+ <type>singleton</type>
152
+ <class>logistics/observer</class>
153
+ <method>changedSectionBefore</method>
154
+ </predispatch_adminhtml_system_config_save>
155
+ </observers>
156
+ </controller_action_predispatch_adminhtml_system_config_save>
157
  </events>
158
  <models>
159
  <logistics>
169
  <posten>
170
  <table>smartsend_pickup</table>
171
  </posten>
 
 
 
172
  <gls>
173
  <table>smartsend_pickup</table>
174
  </gls>
175
  <bring>
176
  <table>smartsend_pickup</table>
177
+ </bring>
178
+ <flex>
179
+ <table>smartsend_flexdelivery</table>
180
+ </flex>
 
 
 
 
 
 
181
  </entities>
182
  </logistics_mysql4>
183
  </models>
225
  </rewrite>
226
  </tax>
227
  </models>
228
+ <template>
229
+ <email>
230
+ <smartsend_new_shipment_email translate="label" module="adminhtml">
231
+ <label>Smart Send: New Shipment</label>
232
+ <file>smartsend_new_shipment_email.html</file>
233
+ <type>html</type>
234
+ </smartsend_new_shipment_email>
235
+ </email>
236
+ </template>
237
  </global>
238
  <default> <!-- default for the carriers -->
239
  <carriers>
240
  <smartsend>
241
  <username></username>
242
+ <licencekey></licencekey>
243
+ <validation>Please enter valid user information</validation>
244
+ <combinepdf>1</combinepdf>
245
+ <listformat>1</listformat> <!-- is listtype #Company, #Street, #Zipcode #City-->
246
+ <status></status> <!-- order status -->
247
+ <sendemail>0</sendemail> <!-- send email with shipments -->
248
+ <includeordercomment>0</includeordercomment> <!-- include order comment on label -->
249
  </smartsend>
250
  <smartsendpostdanmark>
251
  <active>0</active> <!-- is not active -->
253
  <title>Post Danmark</title> <!-- title -->
254
  <cheapestexpensive>0</cheapestexpensive> <!-- is cheapest -->
255
  <excludetax>0</excludetax> <!-- Exclude from TAX -->
 
256
  <format>pdf</format> <!-- format is PDF file -->
257
  <quickid>1</quickid> <!-- Default QuickId=1 -->
258
  <waybillid></waybillid> <!-- Default WaybillId=NULL -->
259
  <notemail>1</notemail> <!-- Email notification is ON -->
260
  <notesms>1</notesms> <!-- SMS notification is ON -->
261
  <prenote>0</prenote> <!-- pre-notification is OFF -->
262
+ <flexdelivery>smartsendpostdanmark_lastmile</flexdelivery> <!-- Flexdelivery is activated for lastmile -->
263
  <return></return> <!-- standard return shipping method -->
264
  </smartsendpostdanmark>
265
  <smartsendposten>
267
  <model>logistics/carrier_posten</model>
268
  <title>Posten</title>
269
  <cheapestexpensive>0</cheapestexpensive>
 
 
270
  <format>pdf</format>
271
  <quickid>1</quickid>
272
  <waybillid></waybillid>
273
  <notemail>1</notemail>
274
  <notesms>1</notesms>
275
  <prenote>0</prenote>
276
+ <flexdelivery></flexdelivery>
277
  <return></return>
278
  </smartsendposten>
279
  <smartsendgls>
281
  <model>logistics/carrier_gls</model>
282
  <title>GLS</title>
283
  <cheapestexpensive>0</cheapestexpensive>
 
 
284
  <notemail>1</notemail>
285
  <notesms>1</notesms>
286
  <return></return>
290
  <model>logistics/carrier_bring</model>
291
  <title>Bring</title>
292
  <cheapestexpensive>0</cheapestexpensive>
 
 
293
  <notemail>1</notemail>
294
  <notesms>1</notesms>
295
  <return></return>
296
  </smartsendbring>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  </carriers>
298
  </default>
299
  </config>
app/code/community/Smartsend/Logistics/etc/system.xml CHANGED
@@ -5,11 +5,7 @@
5
  <groups>
6
  <smartsend translate="label" module="logistics">
7
  <label>Smart Send ApS</label>
8
- <comment>
9
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
10
- If you don't have a Smart Send subscription please create one at our website: <a href="http://www.smartsend.dk" target="_blank">Smart Send</a>
11
- </p></div>]]>
12
- </comment>
13
  <frontend_type>text</frontend_type>
14
  <sort_order>90</sort_order>
15
  <show_in_default>1</show_in_default>
@@ -21,35 +17,78 @@
21
  <frontend_type>text</frontend_type>
22
  <sort_order>110</sort_order>
23
  <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
  <show_in_store>1</show_in_store>
26
  </username>
27
- <licencekey translate="label">
28
- <label>Licencekey</label>
29
  <frontend_type>text</frontend_type>
30
- <sort_order>120</sort_order>
 
 
 
 
 
 
 
 
31
  <show_in_default>1</show_in_default>
32
  <show_in_website>1</show_in_website>
33
  <show_in_store>1</show_in_store>
34
- </licencekey>
35
  <combinepdf translate="label">
36
- <label>Combine PDF files?</label>
 
37
  <source_model>logistics/system_combinePdf</source_model>
38
  <frontend_type>radios</frontend_type>
39
- <sort_order>130</sort_order>
40
  <show_in_default>1</show_in_default>
41
  <show_in_website>1</show_in_website>
42
  <show_in_store>1</show_in_store>
43
  </combinepdf>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  </fields>
45
  </smartsend>
46
  <smartsendpostdanmark translate="label" module="logistics">
47
  <label>Smart Send - Post Danmark</label>
48
- <comment>
49
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
50
- This shipping method may only be used if a valid Smart Send licence is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.
51
- </p></div>]]>
52
- </comment>
53
  <frontend_type>text</frontend_type>
54
  <sort_order>91</sort_order>
55
  <show_in_default>1</show_in_default>
@@ -60,31 +99,34 @@
60
  <label>Enabled</label>
61
  <frontend_type>select</frontend_type>
62
  <source_model>adminhtml/system_config_source_yesno</source_model>
63
- <sort_order>110</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
  </active>
68
  <title translate="label">
69
- <label>Carrier Title</label>
 
70
  <frontend_type>text</frontend_type>
71
- <sort_order>115</sort_order>
72
  <show_in_default>1</show_in_default>
73
  <show_in_website>1</show_in_website>
74
  <show_in_store>1</show_in_store>
75
  </title>
76
  <price translate="label">
77
- <label>Price</label>
 
78
  <frontend_type>text</frontend_type>
79
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
80
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
81
- <sort_order>120</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
  </price>
86
  <cheapestexpensive translate="label">
87
- <label>Cheapest or most expensive?</label>
 
88
  <source_model>logistics/system_orderOption</source_model>
89
  <frontend_type>radios</frontend_type>
90
  <sort_order>125</sort_order>
@@ -94,7 +136,7 @@
94
  </cheapestexpensive>
95
  <excludetax translate="label">
96
  <label>Exclude from TAX</label>
97
- <comment>Carrier is excluded from TAX even though there is a Shipping Tax defined</comment>
98
  <source_model>adminhtml/system_config_source_yesno</source_model>
99
  <frontend_type>select</frontend_type>
100
  <sort_order>129</sort_order>
@@ -102,16 +144,6 @@
102
  <show_in_website>1</show_in_website>
103
  <show_in_store>1</show_in_store>
104
  </excludetax>
105
- <listformat translate="label">
106
- <label>Dropdown format</label>
107
- <comment>How the dropdown is formatted</comment>
108
- <source_model>logistics/system_listformat</source_model>
109
- <frontend_type>select</frontend_type>
110
- <sort_order>130</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
- </listformat>
115
  <heading_services translate="label">
116
  <label>Services</label>
117
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -121,7 +153,7 @@
121
  <show_in_store>1</show_in_store>
122
  </heading_services>
123
  <format translate="label">
124
- <label>Format</label>
125
  <source_model>logistics/system_pacsoftformat</source_model>
126
  <frontend_type>select</frontend_type>
127
  <sort_order>140</sort_order>
@@ -131,6 +163,7 @@
131
  </format>
132
  <quickid translate="label">
133
  <label>Pacsoft QuickID</label>
 
134
  <validate>validate-alphanum</validate>
135
  <frontend_type>text</frontend_type>
136
  <sort_order>145</sort_order>
@@ -149,6 +182,7 @@
149
  </waybillid>
150
  <notemail translate="label">
151
  <label>Email notification</label>
 
152
  <frontend_type>select</frontend_type>
153
  <source_model>adminhtml/system_config_source_yesno</source_model>
154
  <sort_order>150</sort_order>
@@ -158,6 +192,7 @@
158
  </notemail>
159
  <notesms translate="label">
160
  <label>SMS notification</label>
 
161
  <frontend_type>select</frontend_type>
162
  <source_model>adminhtml/system_config_source_yesno</source_model>
163
  <sort_order>155</sort_order>
@@ -167,6 +202,7 @@
167
  </notesms>
168
  <prenote translate="label">
169
  <label>Pre-notification</label>
 
170
  <frontend_type>select</frontend_type>
171
  <source_model>adminhtml/system_config_source_yesno</source_model>
172
  <sort_order>160</sort_order>
@@ -210,6 +246,17 @@
210
  <prenote>1</prenote>
211
  </depends>
212
  </prenote_message>
 
 
 
 
 
 
 
 
 
 
 
213
  <heading_return translate="label">
214
  <label>Return</label>
215
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -219,8 +266,8 @@
219
  <show_in_store>1</show_in_store>
220
  </heading_return>
221
  <return translate="label">
222
- <label>Return methode</label>
223
- <comment>Which carrier should handle return packages?</comment>
224
  <source_model>logistics/system_return</source_model>
225
  <frontend_type>select</frontend_type>
226
  <sort_order>180</sort_order>
@@ -232,11 +279,7 @@
232
  </smartsendpostdanmark>
233
  <smartsendgls translate="label" module="logistics">
234
  <label>Smart Send - GLS</label>
235
- <comment>
236
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
237
- This shipping method may only be used if a valid Smart Send licence is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.
238
- </p></div>]]>
239
- </comment>
240
  <frontend_type>text</frontend_type>
241
  <sort_order>92</sort_order>
242
  <show_in_default>1</show_in_default>
@@ -253,7 +296,7 @@
253
  <show_in_store>1</show_in_store>
254
  </active>
255
  <title translate="label">
256
- <label>Carrier Title</label>
257
  <frontend_type>text</frontend_type>
258
  <sort_order>132</sort_order>
259
  <show_in_default>1</show_in_default>
@@ -261,7 +304,8 @@
261
  <show_in_store>1</show_in_store>
262
  </title>
263
  <price translate="label">
264
- <label>Price</label>
 
265
  <frontend_type>text</frontend_type>
266
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
267
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
@@ -271,7 +315,9 @@
271
  <show_in_store>1</show_in_store>
272
  </price>
273
  <cheapestexpensive translate="label">
274
- <label>Cheapest or most expensive?</label>
 
 
275
  <source_model>logistics/system_orderOption</source_model>
276
  <frontend_type>radios</frontend_type>
277
  <sort_order>134</sort_order>
@@ -279,26 +325,6 @@
279
  <show_in_website>1</show_in_website>
280
  <show_in_store>1</show_in_store>
281
  </cheapestexpensive>
282
- <excludetax translate="label">
283
- <label>Exclude from TAX</label>
284
- <comment>Carrier is excluded from TAX even though there is a Shipping Tax defined</comment>
285
- <source_model>adminhtml/system_config_source_yesno</source_model>
286
- <frontend_type>select</frontend_type>
287
- <sort_order>135</sort_order>
288
- <show_in_default>1</show_in_default>
289
- <show_in_website>1</show_in_website>
290
- <show_in_store>1</show_in_store>
291
- </excludetax>
292
- <listformat translate="label">
293
- <label>Dropdown format</label>
294
- <comment>How the dropdown is formatted</comment>
295
- <source_model>logistics/system_listformat</source_model>
296
- <frontend_type>select</frontend_type>
297
- <sort_order>136</sort_order>
298
- <show_in_default>1</show_in_default>
299
- <show_in_website>1</show_in_website>
300
- <show_in_store>1</show_in_store>
301
- </listformat>
302
  <heading translate="label">
303
  <label>Services</label>
304
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -334,8 +360,8 @@
334
  <show_in_store>1</show_in_store>
335
  </heading_return>
336
  <return translate="label">
337
- <label>Return methode</label>
338
- <comment>Which carrier should handle return packages?</comment>
339
  <source_model>logistics/system_return</source_model>
340
  <frontend_type>select</frontend_type>
341
  <sort_order>141</sort_order>
@@ -347,11 +373,7 @@
347
  </smartsendgls>
348
  <smartsendbring translate="label" module="logistics">
349
  <label>Smart Send - Bring</label>
350
- <comment>
351
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
352
- This shipping method may only be used if a valid Smart Send licence is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.
353
- </p></div>]]>
354
- </comment>
355
  <frontend_type>text</frontend_type>
356
  <sort_order>93</sort_order>
357
  <show_in_default>1</show_in_default>
@@ -368,7 +390,7 @@
368
  <show_in_store>1</show_in_store>
369
  </active>
370
  <title translate="label">
371
- <label>Carrier Title</label>
372
  <frontend_type>text</frontend_type>
373
  <sort_order>152</sort_order>
374
  <show_in_default>1</show_in_default>
@@ -376,7 +398,8 @@
376
  <show_in_store>1</show_in_store>
377
  </title>
378
  <price translate="label">
379
- <label>Price</label>
 
380
  <frontend_type>text</frontend_type>
381
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
382
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
@@ -386,34 +409,16 @@
386
  <show_in_store>1</show_in_store>
387
  </price>
388
  <cheapestexpensive translate="label">
389
- <label>Cheapest or most expensive?</label>
 
 
390
  <source_model>logistics/system_orderOption</source_model>
391
  <frontend_type>radios</frontend_type>
392
- <sort_order>153</sort_order>
393
- <show_in_default>1</show_in_default>
394
- <show_in_website>1</show_in_website>
395
- <show_in_store>1</show_in_store>
396
- </cheapestexpensive>
397
- <excludetax translate="label">
398
- <label>Exclude from TAX</label>
399
- <comment>Carrier is excluded from TAX even though there is a Shipping Tax defined</comment>
400
- <source_model>adminhtml/system_config_source_yesno</source_model>
401
- <frontend_type>select</frontend_type>
402
  <sort_order>154</sort_order>
403
  <show_in_default>1</show_in_default>
404
  <show_in_website>1</show_in_website>
405
  <show_in_store>1</show_in_store>
406
- </excludetax>
407
- <listformat translate="label">
408
- <label>Dropdown format</label>
409
- <comment>How the dropdown is formatted</comment>
410
- <source_model>logistics/system_listformat</source_model>
411
- <frontend_type>select</frontend_type>
412
- <sort_order>155</sort_order>
413
- <show_in_default>1</show_in_default>
414
- <show_in_website>1</show_in_website>
415
- <show_in_store>1</show_in_store>
416
- </listformat>
417
  <heading translate="label">
418
  <label>Services</label>
419
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -449,8 +454,8 @@
449
  <show_in_store>1</show_in_store>
450
  </heading_return>
451
  <return translate="label">
452
- <label>Return methode</label>
453
- <comment>Which carrier should handle return packages?</comment>
454
  <source_model>logistics/system_return</source_model>
455
  <frontend_type>select</frontend_type>
456
  <sort_order>160</sort_order>
@@ -460,225 +465,9 @@
460
  </return>
461
  </fields>
462
  </smartsendbring>
463
- <smartsendswipbox translate="label" module="logistics">
464
- <label>Smart Send - SwipBox</label>
465
- <comment>
466
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
467
- This shipping method may only be used if a valid Smart Send licence is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.
468
- </p></div>]]>
469
- </comment>
470
- <frontend_type>text</frontend_type>
471
- <sort_order>94</sort_order>
472
- <show_in_default>1</show_in_default>
473
- <show_in_website>1</show_in_website>
474
- <show_in_store>1</show_in_store>
475
- <fields>
476
- <active translate="label">
477
- <label>Enabled</label>
478
- <frontend_type>select</frontend_type>
479
- <source_model>adminhtml/system_config_source_yesno</source_model>
480
- <sort_order>110</sort_order>
481
- <show_in_default>1</show_in_default>
482
- <show_in_website>1</show_in_website>
483
- <show_in_store>1</show_in_store>
484
- </active>
485
- <title translate="label">
486
- <label>Carrier Title</label>
487
- <frontend_type>text</frontend_type>
488
- <sort_order>115</sort_order>
489
- <show_in_default>1</show_in_default>
490
- <show_in_website>1</show_in_website>
491
- <show_in_store>1</show_in_store>
492
- </title>
493
- <price translate="label">
494
- <label>Price</label>
495
- <frontend_type>text</frontend_type>
496
- <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
497
- <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
498
- <sort_order>120</sort_order>
499
- <show_in_default>1</show_in_default>
500
- <show_in_website>1</show_in_website>
501
- <show_in_store>1</show_in_store>
502
- </price>
503
- <cheapestexpensive translate="label">
504
- <label>Cheapest or most expensive?</label>
505
- <source_model>logistics/system_orderOption</source_model>
506
- <frontend_type>radios</frontend_type>
507
- <sort_order>125</sort_order>
508
- <show_in_default>1</show_in_default>
509
- <show_in_website>1</show_in_website>
510
- <show_in_store>1</show_in_store>
511
- </cheapestexpensive>
512
- <excludetax translate="label">
513
- <label>Exclude from TAX</label>
514
- <comment>Carrier is excluded from TAX even though there is a Shipping Tax defined</comment>
515
- <source_model>adminhtml/system_config_source_yesno</source_model>
516
- <frontend_type>select</frontend_type>
517
- <sort_order>129</sort_order>
518
- <show_in_default>1</show_in_default>
519
- <show_in_website>1</show_in_website>
520
- <show_in_store>1</show_in_store>
521
- </excludetax>
522
- <listformat translate="label">
523
- <label>Dropdown format</label>
524
- <comment>How the dropdown is formatted</comment>
525
- <source_model>logistics/system_listformat</source_model>
526
- <frontend_type>select</frontend_type>
527
- <sort_order>130</sort_order>
528
- <show_in_default>1</show_in_default>
529
- <show_in_website>1</show_in_website>
530
- <show_in_store>1</show_in_store>
531
- </listformat>
532
- <heading translate="label">
533
- <label>Services</label>
534
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
535
- <sort_order>135</sort_order>
536
- <show_in_default>1</show_in_default>
537
- <show_in_website>1</show_in_website>
538
- <show_in_store>1</show_in_store>
539
- </heading>
540
- <size translate="label">
541
- <label>Size</label>
542
- <source_model>logistics/system_size</source_model>
543
- <frontend_type>select</frontend_type>
544
- <sort_order>140</sort_order>
545
- <show_in_default>1</show_in_default>
546
- <show_in_website>1</show_in_website>
547
- <show_in_store>1</show_in_store>
548
- </size>
549
- <heading_return translate="label">
550
- <label>Return</label>
551
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
552
- <sort_order>145</sort_order>
553
- <show_in_default>1</show_in_default>
554
- <show_in_website>1</show_in_website>
555
- <show_in_store>1</show_in_store>
556
- </heading_return>
557
- <return translate="label">
558
- <label>Return methode</label>
559
- <comment>Which carrier should handle return packages?</comment>
560
- <source_model>logistics/system_return</source_model>
561
- <frontend_type>select</frontend_type>
562
- <sort_order>150</sort_order>
563
- <show_in_default>1</show_in_default>
564
- <show_in_website>1</show_in_website>
565
- <show_in_store>1</show_in_store>
566
- </return>
567
- </fields>
568
- </smartsendswipbox>
569
- <smartsendpickup translate="label" module="logistics">
570
- <label>Smart Send - Closest Pickup</label>
571
- <comment>
572
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
573
- This shipping method may only be used if a valid Smart Send licence is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.
574
- </p></div>]]>
575
- </comment>
576
- <frontend_type>text</frontend_type>
577
- <sort_order>95</sort_order>
578
- <show_in_default>1</show_in_default>
579
- <show_in_website>1</show_in_website>
580
- <show_in_store>1</show_in_store>
581
- <fields>
582
- <active translate="label">
583
- <label>Enabled</label>
584
- <frontend_type>select</frontend_type>
585
- <source_model>adminhtml/system_config_source_yesno</source_model>
586
- <sort_order>501</sort_order>
587
- <show_in_default>1</show_in_default>
588
- <show_in_website>1</show_in_website>
589
- <show_in_store>1</show_in_store>
590
- </active>
591
- <methods translate="label">
592
- <label>Shipping Methods</label>
593
- <frontend_type>Multiselect</frontend_type>
594
- <source_model>logistics/system_pickupMethods</source_model>
595
- <sort_order>502</sort_order>
596
- <show_in_default>1</show_in_default>
597
- <show_in_website>1</show_in_website>
598
- <show_in_store>1</show_in_store>
599
- </methods>
600
- <title translate="label">
601
- <label>Carrier Title</label>
602
- <frontend_type>text</frontend_type>
603
- <sort_order>503</sort_order>
604
- <show_in_default>1</show_in_default>
605
- <show_in_website>1</show_in_website>
606
- <show_in_store>1</show_in_store>
607
- </title>
608
- <name translate="label">
609
- <label>Method Name</label>
610
- <frontend_type>text</frontend_type>
611
- <sort_order>504</sort_order>
612
- <show_in_default>1</show_in_default>
613
- <show_in_website>1</show_in_website>
614
- <show_in_store>1</show_in_store>
615
- </name>
616
- <price translate="label">
617
- <label>Price</label>
618
- <frontend_type>select</frontend_type>
619
- <sort_order>505</sort_order>
620
- <frontend_model>smartsend_logistics_block_adminhtml_pickupShipping</frontend_model>
621
- <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
622
- <show_in_default>1</show_in_default>
623
- <show_in_website>1</show_in_website>
624
- <show_in_store>1</show_in_store>
625
- </price>
626
- <cheapestexpensive translate="label">
627
- <label>Cheapest or most expensive?</label>
628
- <source_model>logistics/system_orderOption</source_model>
629
- <frontend_type>radios</frontend_type>
630
- <sort_order>506</sort_order>
631
- <show_in_default>1</show_in_default>
632
- <show_in_website>1</show_in_website>
633
- <show_in_store>1</show_in_store>
634
- </cheapestexpensive>
635
- <excludetax translate="label">
636
- <label>Exclude from TAX</label>
637
- <comment>Carrier is excluded from TAX even though there is a Shipping Tax defined</comment>
638
- <source_model>adminhtml/system_config_source_yesno</source_model>
639
- <frontend_type>select</frontend_type>
640
- <sort_order>507</sort_order>
641
- <show_in_default>1</show_in_default>
642
- <show_in_website>1</show_in_website>
643
- <show_in_store>1</show_in_store>
644
- </excludetax>
645
- <listformat translate="label">
646
- <label>Dropdown format</label>
647
- <comment>How the dropdown is formatted</comment>
648
- <source_model>logistics/system_pickup_listformat</source_model>
649
- <frontend_type>select</frontend_type>
650
- <sort_order>508</sort_order>
651
- <show_in_default>1</show_in_default>
652
- <show_in_website>1</show_in_website>
653
- <show_in_store>1</show_in_store>
654
- </listformat>
655
- <heading_return translate="label">
656
- <label>Return</label>
657
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
658
- <sort_order>509</sort_order>
659
- <show_in_default>1</show_in_default>
660
- <show_in_website>1</show_in_website>
661
- <show_in_store>1</show_in_store>
662
- </heading_return>
663
- <return translate="label">
664
- <label>Return methode</label>
665
- <comment>Which carrier should handle return packages?</comment>
666
- <source_model>logistics/system_return</source_model>
667
- <frontend_type>select</frontend_type>
668
- <sort_order>510</sort_order>
669
- <show_in_default>1</show_in_default>
670
- <show_in_website>1</show_in_website>
671
- <show_in_store>1</show_in_store>
672
- </return>
673
- </fields>
674
- </smartsendpickup>
675
  <smartsendposten translate="label" module="logistics">
676
  <label>Smart Send - Posten</label>
677
- <comment>
678
- <![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px;width:55%">
679
- This shipping method may only be used if a valid Smart Send licence is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.
680
- </p></div>]]>
681
- </comment>
682
  <frontend_type>text</frontend_type>
683
  <sort_order>96</sort_order>
684
  <show_in_default>1</show_in_default>
@@ -695,7 +484,7 @@
695
  <show_in_store>1</show_in_store>
696
  </active>
697
  <title translate="label">
698
- <label>Carrier Title</label>
699
  <frontend_type>text</frontend_type>
700
  <sort_order>602</sort_order>
701
  <show_in_default>1</show_in_default>
@@ -703,7 +492,7 @@
703
  <show_in_store>1</show_in_store>
704
  </title>
705
  <price translate="label">
706
- <label>Price</label>
707
  <frontend_type>text</frontend_type>
708
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
709
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
@@ -713,7 +502,9 @@
713
  <show_in_store>1</show_in_store>
714
  </price>
715
  <cheapestexpensive translate="label">
716
- <label>Cheapest or most expensive?</label>
 
 
717
  <source_model>logistics/system_orderOption</source_model>
718
  <frontend_type>radios</frontend_type>
719
  <sort_order>604</sort_order>
@@ -721,26 +512,6 @@
721
  <show_in_website>1</show_in_website>
722
  <show_in_store>1</show_in_store>
723
  </cheapestexpensive>
724
- <excludetax translate="label">
725
- <label>Exclude from TAX</label>
726
- <comment>Carrier is excluded from TAX even though there is a Shipping Tax defined</comment>
727
- <source_model>adminhtml/system_config_source_yesno</source_model>
728
- <frontend_type>select</frontend_type>
729
- <sort_order>605</sort_order>
730
- <show_in_default>1</show_in_default>
731
- <show_in_website>1</show_in_website>
732
- <show_in_store>1</show_in_store>
733
- </excludetax>
734
- <listformat translate="label">
735
- <label>Listing Format</label>
736
- <comment>How the dropdown is formatted</comment>
737
- <source_model>logistics/system_listformat</source_model>
738
- <frontend_type>select</frontend_type>
739
- <sort_order>606</sort_order>
740
- <show_in_default>1</show_in_default>
741
- <show_in_website>1</show_in_website>
742
- <show_in_store>1</show_in_store>
743
- </listformat>
744
  <heading translate="label">
745
  <label>Services</label>
746
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
@@ -750,7 +521,7 @@
750
  <show_in_store>1</show_in_store>
751
  </heading>
752
  <format translate="label">
753
- <label>Format</label>
754
  <source_model>logistics/system_pacsoftformat</source_model>
755
  <frontend_type>select</frontend_type>
756
  <sort_order>608</sort_order>
@@ -839,20 +610,31 @@
839
  <prenote>1</prenote>
840
  </depends>
841
  </prenote_message>
 
 
 
 
 
 
 
 
 
 
 
842
  <heading_return translate="label">
843
  <label>Return</label>
844
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
845
- <sort_order>617</sort_order>
846
  <show_in_default>1</show_in_default>
847
  <show_in_website>1</show_in_website>
848
  <show_in_store>1</show_in_store>
849
  </heading_return>
850
  <return translate="label">
851
- <label>Return methode</label>
852
- <comment>Which carrier should handle return packages?</comment>
853
  <source_model>logistics/system_return</source_model>
854
  <frontend_type>select</frontend_type>
855
- <sort_order>618</sort_order>
856
  <show_in_default>1</show_in_default>
857
  <show_in_website>1</show_in_website>
858
  <show_in_store>1</show_in_store>
5
  <groups>
6
  <smartsend translate="label" module="logistics">
7
  <label>Smart Send ApS</label>
8
+ <comment><![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px">If you don't have a Smart Send subscription please create one at our website: <a href="http://www.smartsend.dk/signup" target="_blank">Smart Send</a></p></div>]]></comment>
 
 
 
 
9
  <frontend_type>text</frontend_type>
10
  <sort_order>90</sort_order>
11
  <show_in_default>1</show_in_default>
17
  <frontend_type>text</frontend_type>
18
  <sort_order>110</sort_order>
19
  <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>Select a flexdelivery option
21
  <show_in_store>1</show_in_store>
22
  </username>
23
+ <licensekey translate="label">
24
+ <label>License key</label>
25
  <frontend_type>text</frontend_type>
26
+ <sort_order>111</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </licensekey>
31
+ <validation translate="label">
32
+ <label>Validation</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>112</sort_order>
35
  <show_in_default>1</show_in_default>
36
  <show_in_website>1</show_in_website>
37
  <show_in_store>1</show_in_store>
38
+ </validation>
39
  <combinepdf translate="label">
40
+ <label>Merge labels from multiple orders</label>
41
+ <comment>Generate PDF file containing all labels or create a single PDF file for each order</comment>
42
  <source_model>logistics/system_combinePdf</source_model>
43
  <frontend_type>radios</frontend_type>
44
+ <sort_order>113</sort_order>
45
  <show_in_default>1</show_in_default>
46
  <show_in_website>1</show_in_website>
47
  <show_in_store>1</show_in_store>
48
  </combinepdf>
49
+ <listformat translate="label">
50
+ <label>Dropdown format</label>
51
+ <comment>How the pickup points are listed during checkout</comment>
52
+ <source_model>logistics/system_listformat</source_model>
53
+ <frontend_type>select</frontend_type>
54
+ <sort_order>114</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
+ </listformat>
59
+ <status translate="label">
60
+ <label>Set order status after label print</label>
61
+ <source_model>logistics/system_status</source_model>
62
+ <frontend_type>select</frontend_type>
63
+ <sort_order>115</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
+ </status>
68
+ <sendemail translate="label">
69
+ <label>Send shipment email</label>
70
+ <comment>Send system shipment email to the customer after generating label</comment>
71
+ <frontend_type>select</frontend_type>
72
+ <source_model>adminhtml/system_config_source_yesno</source_model>
73
+ <sort_order>116</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </sendemail>
78
+ <includeordercomment translate="label">
79
+ <label>Include order comment on label</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>117</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </includeordercomment>
87
  </fields>
88
  </smartsend>
89
  <smartsendpostdanmark translate="label" module="logistics">
90
  <label>Smart Send - Post Danmark</label>
91
+ <comment><![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px">This shipping method may only be used if a valid Smart Send license is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.</p></div>]]></comment>
 
 
 
 
92
  <frontend_type>text</frontend_type>
93
  <sort_order>91</sort_order>
94
  <show_in_default>1</show_in_default>
99
  <label>Enabled</label>
100
  <frontend_type>select</frontend_type>
101
  <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>120</sort_order>
103
  <show_in_default>1</show_in_default>
104
  <show_in_website>1</show_in_website>
105
  <show_in_store>1</show_in_store>
106
  </active>
107
  <title translate="label">
108
+ <label>Carrier title</label>
109
+ <comment>Carrier title shown in frontend at customer checkout</comment>
110
  <frontend_type>text</frontend_type>
111
+ <sort_order>121</sort_order>
112
  <show_in_default>1</show_in_default>
113
  <show_in_website>1</show_in_website>
114
  <show_in_store>1</show_in_store>
115
  </title>
116
  <price translate="label">
117
+ <label>Table rate</label>
118
+ <comment>Countries can be entered as a comma-separated list in ISO 3166-1 alpha-2 format. Use * for all valid countries.</comment>
119
  <frontend_type>text</frontend_type>
120
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
121
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
122
+ <sort_order>122</sort_order>
123
  <show_in_default>1</show_in_default>
124
  <show_in_website>1</show_in_website>
125
  <show_in_store>1</show_in_store>
126
  </price>
127
  <cheapestexpensive translate="label">
128
+ <label>Handle multiple rates for same shipping method</label>
129
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
130
  <source_model>logistics/system_orderOption</source_model>
131
  <frontend_type>radios</frontend_type>
132
  <sort_order>125</sort_order>
136
  </cheapestexpensive>
137
  <excludetax translate="label">
138
  <label>Exclude from TAX</label>
139
+ <comment>Excluded private shipping methods to Denmark from TAX</comment>
140
  <source_model>adminhtml/system_config_source_yesno</source_model>
141
  <frontend_type>select</frontend_type>
142
  <sort_order>129</sort_order>
144
  <show_in_website>1</show_in_website>
145
  <show_in_store>1</show_in_store>
146
  </excludetax>
 
 
 
 
 
 
 
 
 
 
147
  <heading_services translate="label">
148
  <label>Services</label>
149
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
153
  <show_in_store>1</show_in_store>
154
  </heading_services>
155
  <format translate="label">
156
+ <label>Label format</label>
157
  <source_model>logistics/system_pacsoftformat</source_model>
158
  <frontend_type>select</frontend_type>
159
  <sort_order>140</sort_order>
163
  </format>
164
  <quickid translate="label">
165
  <label>Pacsoft QuickID</label>
166
+ <comment>ID of the Pacsoft sender appearing on the label</comment>
167
  <validate>validate-alphanum</validate>
168
  <frontend_type>text</frontend_type>
169
  <sort_order>145</sort_order>
182
  </waybillid>
183
  <notemail translate="label">
184
  <label>Email notification</label>
185
+ <comment>Send an email to the customer with info about delivery</comment>
186
  <frontend_type>select</frontend_type>
187
  <source_model>adminhtml/system_config_source_yesno</source_model>
188
  <sort_order>150</sort_order>
192
  </notemail>
193
  <notesms translate="label">
194
  <label>SMS notification</label>
195
+ <comment>Send a SMS to the customer with info about delivery</comment>
196
  <frontend_type>select</frontend_type>
197
  <source_model>adminhtml/system_config_source_yesno</source_model>
198
  <sort_order>155</sort_order>
202
  </notesms>
203
  <prenote translate="label">
204
  <label>Pre-notification</label>
205
+ <comment>Send and email with info about delivery at soon as a label is created</comment>
206
  <frontend_type>select</frontend_type>
207
  <source_model>adminhtml/system_config_source_yesno</source_model>
208
  <sort_order>160</sort_order>
246
  <prenote>1</prenote>
247
  </depends>
248
  </prenote_message>
249
+ <flexdelivery translate="label">
250
+ <label>Flex delivery</label>
251
+ <comment>Enable flex delivery for the selected shipping methods</comment>
252
+ <frontend_type>multiselect</frontend_type>
253
+ <source_model>logistics/system_postdanmark_flexdelivery</source_model>
254
+ <sort_order>172</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
+ <can_be_empty>1</can_be_empty><!-- Allow flexdelivery to be disabled -->
259
+ </flexdelivery>
260
  <heading_return translate="label">
261
  <label>Return</label>
262
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
266
  <show_in_store>1</show_in_store>
267
  </heading_return>
268
  <return translate="label">
269
+ <label>Return method</label>
270
+ <comment>Determines what carrier handles return packages</comment>
271
  <source_model>logistics/system_return</source_model>
272
  <frontend_type>select</frontend_type>
273
  <sort_order>180</sort_order>
279
  </smartsendpostdanmark>
280
  <smartsendgls translate="label" module="logistics">
281
  <label>Smart Send - GLS</label>
282
+ <comment><![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px">This shipping method may only be used if a valid Smart Send license is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.</p></div>]]></comment>
 
 
 
 
283
  <frontend_type>text</frontend_type>
284
  <sort_order>92</sort_order>
285
  <show_in_default>1</show_in_default>
296
  <show_in_store>1</show_in_store>
297
  </active>
298
  <title translate="label">
299
+ <label>Carrier title</label>
300
  <frontend_type>text</frontend_type>
301
  <sort_order>132</sort_order>
302
  <show_in_default>1</show_in_default>
304
  <show_in_store>1</show_in_store>
305
  </title>
306
  <price translate="label">
307
+ <label>Table rate</label>
308
+ <comment>Countries can be entered as a comma-separated list in ISO 3166-1 alpha-2 format. Use * for all valid countries.</comment>
309
  <frontend_type>text</frontend_type>
310
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
311
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
315
  <show_in_store>1</show_in_store>
316
  </price>
317
  <cheapestexpensive translate="label">
318
+ <label>Handle multiple rates for same shipping method</label>
319
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
320
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
321
  <source_model>logistics/system_orderOption</source_model>
322
  <frontend_type>radios</frontend_type>
323
  <sort_order>134</sort_order>
325
  <show_in_website>1</show_in_website>
326
  <show_in_store>1</show_in_store>
327
  </cheapestexpensive>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  <heading translate="label">
329
  <label>Services</label>
330
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
360
  <show_in_store>1</show_in_store>
361
  </heading_return>
362
  <return translate="label">
363
+ <label>Return method</label>
364
+ <comment>Determines what carrier handles return packages</comment>
365
  <source_model>logistics/system_return</source_model>
366
  <frontend_type>select</frontend_type>
367
  <sort_order>141</sort_order>
373
  </smartsendgls>
374
  <smartsendbring translate="label" module="logistics">
375
  <label>Smart Send - Bring</label>
376
+ <comment><![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px">This shipping method may only be used if a valid Smart Send license is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.</p></div>]]></comment>
 
 
 
 
377
  <frontend_type>text</frontend_type>
378
  <sort_order>93</sort_order>
379
  <show_in_default>1</show_in_default>
390
  <show_in_store>1</show_in_store>
391
  </active>
392
  <title translate="label">
393
+ <label>Carrier title</label>
394
  <frontend_type>text</frontend_type>
395
  <sort_order>152</sort_order>
396
  <show_in_default>1</show_in_default>
398
  <show_in_store>1</show_in_store>
399
  </title>
400
  <price translate="label">
401
+ <label>Table rate</label>
402
+ <comment>Countries can be entered as a comma-separated list in ISO 3166-1 alpha-2 format. Use * for all valid countries.</comment>
403
  <frontend_type>text</frontend_type>
404
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
405
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
409
  <show_in_store>1</show_in_store>
410
  </price>
411
  <cheapestexpensive translate="label">
412
+ <label>Handle multiple rates for same shipping method</label>
413
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
414
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
415
  <source_model>logistics/system_orderOption</source_model>
416
  <frontend_type>radios</frontend_type>
 
 
 
 
 
 
 
 
 
 
417
  <sort_order>154</sort_order>
418
  <show_in_default>1</show_in_default>
419
  <show_in_website>1</show_in_website>
420
  <show_in_store>1</show_in_store>
421
+ </cheapestexpensive>
 
 
 
 
 
 
 
 
 
 
422
  <heading translate="label">
423
  <label>Services</label>
424
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
454
  <show_in_store>1</show_in_store>
455
  </heading_return>
456
  <return translate="label">
457
+ <label>Return method</label>
458
+ <comment>Determines what carrier handles return packages</comment>
459
  <source_model>logistics/system_return</source_model>
460
  <frontend_type>select</frontend_type>
461
  <sort_order>160</sort_order>
465
  </return>
466
  </fields>
467
  </smartsendbring>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468
  <smartsendposten translate="label" module="logistics">
469
  <label>Smart Send - Posten</label>
470
+ <comment><![CDATA[<div class="smartsend"><p style="background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px">This shipping method may only be used if a valid Smart Send license is purchased. Please see <a href="http://www.smartsend.dk" target="_blank">Smart Send</a> for further information.</p></div>]]></comment>
 
 
 
 
471
  <frontend_type>text</frontend_type>
472
  <sort_order>96</sort_order>
473
  <show_in_default>1</show_in_default>
484
  <show_in_store>1</show_in_store>
485
  </active>
486
  <title translate="label">
487
+ <label>Carrier title</label>
488
  <frontend_type>text</frontend_type>
489
  <sort_order>602</sort_order>
490
  <show_in_default>1</show_in_default>
492
  <show_in_store>1</show_in_store>
493
  </title>
494
  <price translate="label">
495
+ <label>Table rate</label>
496
  <frontend_type>text</frontend_type>
497
  <frontend_model>smartsend_logistics_block_adminhtml_shipping</frontend_model>
498
  <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
502
  <show_in_store>1</show_in_store>
503
  </price>
504
  <cheapestexpensive translate="label">
505
+ <label>Handle multiple rates for same shipping method</label>
506
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
507
+ <comment>If multiple rates are valid for the same method, use either the cheapest or the most expensive rate</comment>
508
  <source_model>logistics/system_orderOption</source_model>
509
  <frontend_type>radios</frontend_type>
510
  <sort_order>604</sort_order>
512
  <show_in_website>1</show_in_website>
513
  <show_in_store>1</show_in_store>
514
  </cheapestexpensive>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
  <heading translate="label">
516
  <label>Services</label>
517
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
521
  <show_in_store>1</show_in_store>
522
  </heading>
523
  <format translate="label">
524
+ <label>Label format</label>
525
  <source_model>logistics/system_pacsoftformat</source_model>
526
  <frontend_type>select</frontend_type>
527
  <sort_order>608</sort_order>
610
  <prenote>1</prenote>
611
  </depends>
612
  </prenote_message>
613
+ <flexdelivery translate="label">
614
+ <label>Flex delivery</label>
615
+ <comment>Enable flex delivery for the selected shipping methods</comment>
616
+ <frontend_type>multiselect</frontend_type>
617
+ <source_model>logistics/system_posten_flexdelivery</source_model>
618
+ <sort_order>617</sort_order>
619
+ <show_in_default>1</show_in_default>
620
+ <show_in_website>1</show_in_website>
621
+ <show_in_store>1</show_in_store>
622
+ <can_be_empty>1</can_be_empty><!-- Allow flexdelivery to be disabled -->
623
+ </flexdelivery>
624
  <heading_return translate="label">
625
  <label>Return</label>
626
  <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
627
+ <sort_order>618</sort_order>
628
  <show_in_default>1</show_in_default>
629
  <show_in_website>1</show_in_website>
630
  <show_in_store>1</show_in_store>
631
  </heading_return>
632
  <return translate="label">
633
+ <label>Return method</label>
634
+ <comment>Determines what carrier handles return packages</comment>
635
  <source_model>logistics/system_return</source_model>
636
  <frontend_type>select</frontend_type>
637
+ <sort_order>619</sort_order>
638
  <show_in_default>1</show_in_default>
639
  <show_in_website>1</show_in_website>
640
  <show_in_store>1</show_in_store>
app/code/community/Smartsend/Logistics/sql/logistics_setup/mysql4-install-7.0.1.php CHANGED
@@ -24,6 +24,7 @@
24
  * @url www.smartsend.dk
25
  */
26
  $installer = $this;
 
27
 
28
  $installer->startSetup(); //start setup
29
 
@@ -31,7 +32,6 @@ $installer->run("
31
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_pickup')};
32
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_postdanmark')};
33
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_posten')};
34
- DROP TABLE IF EXISTS {$this->getTable('order_shipping_swipbox')};
35
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_bring')};
36
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_gls')};
37
  CREATE TABLE IF NOT EXISTS {$this->getTable('smartsend_pickup')} (
@@ -51,74 +51,283 @@ $installer->run("
51
 
52
  /* standard values for the table rate */
53
 
54
- for ($i = 0; $i < 6; $i++) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  switch ($i) { //shipping method case
57
- case 0:
58
- $carrier = "groups[smartsendpickup]";
59
- break;
60
  case 1:
61
- $carrier = "groups[smartsendpostdanmark]";
 
 
62
  break;
63
  case 2:
64
- $carrier = "groups[smartsendbring]";
 
 
65
  break;
66
  case 3:
67
- $carrier = "groups[smartsendswipbox]";
 
 
68
  break;
69
  case 4:
70
- $carrier = "groups[smartsendgls]";
71
- break;
72
- case 5:
73
- $carrier = "groups[smartsendposten]";
74
  break;
75
  }
76
 
77
- $shippingmethods = Mage::getModel('logistics/shippingMethods')->getOptionArray($carrier); //getting shipping methods for carriers
78
-
79
- $priceResult = array();
80
-
81
- $shippingArray_NotStandard = array('DPDguranty', 'Valuemail', 'Valuemailfirstclass', 'Valuemaileconomy', 'Maximail'); //shipping methods not having standard settings
82
 
83
- foreach ($shippingmethods as $key => $value) {
84
 
85
- if (!in_array($value, $shippingArray_NotStandard)) {
 
86
 
87
- $millisecond = round(microtime(true) * 1000);
88
- $id = '_' . $millisecond . '_' . rand(100, 999); //ids for the values
89
 
90
- $defaultResult = array();
91
- $defaultResult['orderminprice'] = 0;
92
- $defaultResult['ordermaxprice'] = 100000;
93
- $defaultResult['orderminweight'] = 0;
94
- $defaultResult['ordermaxweight'] = 100000;
95
- $defaultResult['pickupshippingfee'] = 10;
96
- $defaultResult['countries'] = 'DK';
97
- $defaultResult['_id'] = $id;
98
- $defaultResult['methods'] = $key;
99
-
100
- if ($i != 0) {
101
- $Title = Mage::getModel('logistics/shippingMethods')->getTitleValue($key); //getting title value of the shipping method
102
- $defaultResult['method_name'] = $Title;
103
- }
104
-
105
- $priceResult[$defaultResult['_id']] = $defaultResult;
106
-
107
- }
108
- }
109
-
110
- if ($i == 0) {
111
- $path = 'carriers/smartsendpickup/price';
112
- } elseif ($i == 1) {
113
- $path = 'carriers/smartsendpostdanmark/price';
114
- } elseif ($i == 2) {
115
- $path = 'carriers/smartsendbring/price';
116
- } elseif ($i == 3) {
117
- $path = 'carriers/smartsendswipbox/price';
118
- } elseif ($i == 4) {
119
- $path = 'carriers/smartsendgls/price';
120
- } elseif ($i == 5) {
121
- $path = 'carriers/smartsendposten/price';
122
  }
123
 
124
  $data = array();
24
  * @url www.smartsend.dk
25
  */
26
  $installer = $this;
27
+ Mage::log('Starting installation');
28
 
29
  $installer->startSetup(); //start setup
30
 
32
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_pickup')};
33
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_postdanmark')};
34
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_posten')};
 
35
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_bring')};
36
  DROP TABLE IF EXISTS {$this->getTable('order_shipping_gls')};
37
  CREATE TABLE IF NOT EXISTS {$this->getTable('smartsend_pickup')} (
51
 
52
  /* standard values for the table rate */
53
 
54
+ $install_shipping_methods = array(
55
+ "posten" => array(
56
+ array(
57
+ 'orderminprice' => 0,
58
+ 'ordermaxprice' => 500,
59
+ 'orderminweight' => 0,
60
+ 'ordermaxweight' => 100000,
61
+ 'pickupshippingfee' => 40,
62
+ 'countries' => 'SE',
63
+ 'methods' => 'pickup',
64
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
65
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
66
+ ),
67
+ array(
68
+ 'orderminprice' => 500,
69
+ 'ordermaxprice' => 100000,
70
+ 'orderminweight' => 0,
71
+ 'ordermaxweight' => 100000,
72
+ 'pickupshippingfee' => 0,
73
+ 'countries' => 'SE',
74
+ 'methods' => 'pickup',
75
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
76
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
77
+ ),
78
+ array(
79
+ 'orderminprice' => 0,
80
+ 'ordermaxprice' => 500,
81
+ 'orderminweight' => 0,
82
+ 'ordermaxweight' => 100000,
83
+ 'pickupshippingfee' => 50,
84
+ 'countries' => 'SE',
85
+ 'methods' => 'privatehome',
86
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
87
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
88
+ ),
89
+ array(
90
+ 'orderminprice' => 500,
91
+ 'ordermaxprice' => 100000,
92
+ 'orderminweight' => 0,
93
+ 'ordermaxweight' => 100000,
94
+ 'pickupshippingfee' => 10,
95
+ 'countries' => 'SE',
96
+ 'methods' => 'privatehome',
97
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
98
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
99
+ )
100
+ ),
101
+ "postdanmark" => array(
102
+ array(
103
+ 'orderminprice' => 0,
104
+ 'ordermaxprice' => 500,
105
+ 'orderminweight' => 0,
106
+ 'ordermaxweight' => 100000,
107
+ 'pickupshippingfee' => 40,
108
+ 'countries' => 'DK',
109
+ 'methods' => 'pickup',
110
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
111
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
112
+ ),
113
+ array(
114
+ 'orderminprice' => 500,
115
+ 'ordermaxprice' => 100000,
116
+ 'orderminweight' => 0,
117
+ 'ordermaxweight' => 100000,
118
+ 'pickupshippingfee' => 0,
119
+ 'countries' => 'DK',
120
+ 'methods' => 'pickup',
121
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
122
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
123
+ ),
124
+ array(
125
+ 'orderminprice' => 0,
126
+ 'ordermaxprice' => 500,
127
+ 'orderminweight' => 0,
128
+ 'ordermaxweight' => 100000,
129
+ 'pickupshippingfee' => 50,
130
+ 'countries' => 'DK',
131
+ 'methods' => 'privatehome',
132
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
133
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
134
+ ),
135
+ array(
136
+ 'orderminprice' => 500,
137
+ 'ordermaxprice' => 100000,
138
+ 'orderminweight' => 0,
139
+ 'ordermaxweight' => 100000,
140
+ 'pickupshippingfee' => 10,
141
+ 'countries' => 'DK',
142
+ 'methods' => 'privatehome',
143
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
144
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
145
+ ),
146
+ array(
147
+ 'orderminprice' => 0,
148
+ 'ordermaxprice' => 500,
149
+ 'orderminweight' => 0,
150
+ 'ordermaxweight' => 100000,
151
+ 'pickupshippingfee' => 90,
152
+ 'countries' => 'SE,NO,FI',
153
+ 'methods' => 'private',
154
+ 'method_name' => Mage::helper('logistics')->__('Private'),
155
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
156
+ ),
157
+ array(
158
+ 'orderminprice' => 500,
159
+ 'ordermaxprice' => 100000,
160
+ 'orderminweight' => 0,
161
+ 'ordermaxweight' => 100000,
162
+ 'pickupshippingfee' => 50,
163
+ 'countries' => 'SE,NO,FI',
164
+ 'methods' => 'private',
165
+ 'method_name' => Mage::helper('logistics')->__('Private'),
166
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
167
+ ),
168
+ array(
169
+ 'orderminprice' => 0,
170
+ 'ordermaxprice' => 100000,
171
+ 'orderminweight' => 0,
172
+ 'ordermaxweight' => 3,
173
+ 'pickupshippingfee' => 300,
174
+ 'countries' => 'FO,GL',
175
+ 'methods' => 'private',
176
+ 'method_name' => Mage::helper('logistics')->__('Private'),
177
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
178
+ ),
179
+ array(
180
+ 'orderminprice' => 0,
181
+ 'ordermaxprice' => 100000,
182
+ 'orderminweight' => 3,
183
+ 'ordermaxweight' => 10,
184
+ 'pickupshippingfee' => 400,
185
+ 'countries' => 'FO,GL',
186
+ 'methods' => 'private',
187
+ 'method_name' => Mage::helper('logistics')->__('Private'),
188
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
189
+ ),
190
+ array(
191
+ 'orderminprice' => 0,
192
+ 'ordermaxprice' => 100000,
193
+ 'orderminweight' => 10,
194
+ 'ordermaxweight' => 20,
195
+ 'pickupshippingfee' => 500,
196
+ 'countries' => 'FO,GL',
197
+ 'methods' => 'private',
198
+ 'method_name' => Mage::helper('logistics')->__('Private'),
199
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
200
+ )
201
+ ),
202
+ "gls" => array(
203
+ array(
204
+ 'orderminprice' => 0,
205
+ 'ordermaxprice' => 500,
206
+ 'orderminweight' => 0,
207
+ 'ordermaxweight' => 100000,
208
+ 'pickupshippingfee' => 40,
209
+ 'countries' => 'DK',
210
+ 'methods' => 'pickup',
211
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
212
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
213
+ ),
214
+ array(
215
+ 'orderminprice' => 500,
216
+ 'ordermaxprice' => 100000,
217
+ 'orderminweight' => 0,
218
+ 'ordermaxweight' => 100000,
219
+ 'pickupshippingfee' => 0,
220
+ 'countries' => 'DK',
221
+ 'methods' => 'pickup',
222
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
223
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
224
+ ),
225
+ array(
226
+ 'orderminprice' => 0,
227
+ 'ordermaxprice' => 500,
228
+ 'orderminweight' => 0,
229
+ 'ordermaxweight' => 100000,
230
+ 'pickupshippingfee' => 50,
231
+ 'countries' => 'DK',
232
+ 'methods' => 'privatehome',
233
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
234
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
235
+ ),
236
+ array(
237
+ 'orderminprice' => 500,
238
+ 'ordermaxprice' => 100000,
239
+ 'orderminweight' => 0,
240
+ 'ordermaxweight' => 100000,
241
+ 'pickupshippingfee' => 10,
242
+ 'countries' => 'DK',
243
+ 'methods' => 'privatehome',
244
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
245
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
246
+ )
247
+ ),
248
+ "bring" => array(
249
+ array(
250
+ 'orderminprice' => 0,
251
+ 'ordermaxprice' => 500,
252
+ 'orderminweight' => 0,
253
+ 'ordermaxweight' => 100000,
254
+ 'pickupshippingfee' => 40,
255
+ 'countries' => 'DK',
256
+ 'methods' => 'pickup',
257
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
258
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
259
+ ),
260
+ array(
261
+ 'orderminprice' => 500,
262
+ 'ordermaxprice' => 100000,
263
+ 'orderminweight' => 0,
264
+ 'ordermaxweight' => 100000,
265
+ 'pickupshippingfee' => 0,
266
+ 'countries' => 'DK',
267
+ 'methods' => 'pickup',
268
+ 'method_name' => Mage::helper('logistics')->__('Pickuppoint'),
269
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
270
+ ),
271
+ array(
272
+ 'orderminprice' => 0,
273
+ 'ordermaxprice' => 500,
274
+ 'orderminweight' => 0,
275
+ 'ordermaxweight' => 100000,
276
+ 'pickupshippingfee' => 50,
277
+ 'countries' => 'DK',
278
+ 'methods' => 'privatehome',
279
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
280
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
281
+ ),
282
+ array(
283
+ 'orderminprice' => 500,
284
+ 'ordermaxprice' => 100000,
285
+ 'orderminweight' => 0,
286
+ 'ordermaxweight' => 100000,
287
+ 'pickupshippingfee' => 10,
288
+ 'countries' => 'DK',
289
+ 'methods' => 'privatehome',
290
+ 'method_name' => Mage::helper('logistics')->__('Private to home'),
291
+ '_id' => '_' . number_format(microtime(true),0,'.','') . '_' . rand(100, 999)
292
+ )
293
+ )
294
+ );
295
+
296
+
297
+ for ($i = 1; $i < 5; $i++) {
298
 
299
  switch ($i) { //shipping method case
 
 
 
300
  case 1:
301
+ $carrier = "postdanmark";
302
+ $path = 'carriers/smartsendpostdanmark/price';
303
+ $shipping_methods = $install_shipping_methods['postdanmark'];
304
  break;
305
  case 2:
306
+ $carrier = "bring";
307
+ $path = 'carriers/smartsendbring/price';
308
+ $shipping_methods = $install_shipping_methods['bring'];
309
  break;
310
  case 3:
311
+ $carrier = "gls";
312
+ $path = 'carriers/smartsendgls/price';
313
+ $shipping_methods = $install_shipping_methods['gls'];
314
  break;
315
  case 4:
316
+ $carrier = "posten";
317
+ $path = 'carriers/smartsendposten/price';
318
+ $shipping_methods = $install_shipping_methods['posten'];
 
319
  break;
320
  }
321
 
322
+ $ettings = "groups[smartsend".$carrier."]";
 
 
 
 
323
 
324
+ $shipping_methods = $install_shipping_methods[$carrier];
325
 
326
+ $priceResult = array();
327
+ foreach ($shipping_methods as $shipping_method) {
328
 
329
+ $priceResult[$shipping_method['_id']] = $shipping_method;
 
330
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  }
332
 
333
  $data = array();
app/code/community/Smartsend/Logistics/sql/logistics_setup/mysql4-upgrade-7.0.5-7.0.6.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Smartsend_Logistics
5
+ *
6
+ * This source file is subject to the GNU General Public License v3.0
7
+ * that is bundled with this package in the file license.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://www.gnu.org/licenses/gpl-3.0.html
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@smartsend.dk so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
17
+ * versions in the future. If you wish to customize the plugin for your
18
+ * needs please refer to http://www.smartsend.dk
19
+ *
20
+ * @folder /app/code/community/Smartsend/Logistics/sql/logistics_setup/mysql4-upgrade-7.0.5-7.0.6.php
21
+ * @category Smartsend
22
+ * @package Smartsend_Logistics
23
+ * @author Anders Bilfeldt
24
+ * @url www.smartsend.dk
25
+ */
26
+ /* Transactional Email for smartsend shipping */
27
+
28
+ $table = Mage::getSingleton('core/resource')->getTableName('core_email_template'); //checking the table
29
+ $writeAdapter = Mage::getSingleton('core/resource')->getConnection('core_write');
30
+ $readAdapter = Mage::getSingleton('core/resource')->getConnection('core_read');
31
+
32
+
33
+ $template = Mage::getModel('adminhtml/email_template');
34
+ $templateCode = "smartsend_new_shipment_email";
35
+
36
+ if (!Mage::registry('email_template')) {
37
+ Mage::register('email_template', $template);
38
+ }
39
+ if (!Mage::registry('current_email_template')) {
40
+ Mage::register('current_email_template', $template);
41
+ }
42
+
43
+ $template->loadDefault($templateCode, 'da_DK');
44
+ $template->setData('orig_template_code', $templateCode);
45
+ $template->setData('template_variables', Zend_Json::encode($template->getVariablesOptionArray(true)));
46
+
47
+ if (!Mage::registry('email_template')) {
48
+ Mage::register('email_template', $model);
49
+ }
50
+ if (!Mage::registry('current_email_template')) {
51
+ Mage::register('current_email_template', $model);
52
+ }
53
+
54
+ $templateBlock = Mage::app()->getLayout()->createBlock('adminhtml/system_email_template_edit');
55
+ $template->setData('orig_template_used_default_for', $templateBlock->getUsedDefaultForPaths(false));
56
+
57
+ $template_new = Mage::getModel('adminhtml/email_template');
58
+ $template_new->loadByCode('smartsend_sales_email_shipment_template');
59
+ if(!$template_new->getTemplateId()){
60
+ $template_new->setTemplateSubject($template->getData('template_subject'))
61
+ ->setTemplateCode('smartsend_sales_email_shipment_template')
62
+ ->setTemplateText($template->getData('template_text'))
63
+ ->setTemplateStyles($template->getData('template_styles'))
64
+ ->setModifiedAt(Mage::getSingleton('core/date')->gmtDate())
65
+ ->setOrigTemplateCode($template->getData('orig_template_code'))
66
+ ->setOrigTemplateVariables($template->getData('orig_template_variables'));
67
+
68
+ if (!$template_new->getId()) {
69
+ $template_new->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
70
+ $template_new->setTemplateType(Mage_Core_Model_Email_Template::TYPE_HTML);
71
+ }
72
+
73
+ $template_new->save();
74
+ }
75
+
app/code/community/Smartsend/Logistics/{Model/Swipbox.php → sql/logistics_setup/mysql4-upgrade-7.0.9-7.1.0.php} RENAMED
@@ -17,17 +17,25 @@
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
- * @folder /app/code/community/Smartsend/Logistics/Model/Swipbox.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
- class Smartsend_Logistics_Model_Swipbox extends Mage_Core_Model_Abstract {
27
 
28
- public function _construct() {
29
- parent::_construct();
30
- $this->_init('logistics/swipbox');
31
- }
32
 
33
- }
 
 
 
 
 
 
 
 
 
 
 
17
  * versions in the future. If you wish to customize the plugin for your
18
  * needs please refer to http://www.smartsend.dk
19
  *
20
+ * @folder /app/code/community/Smartsend/Logistics/sql/logistics_setup/mysql4-upgrade-7.0.9-7.1.0.php
21
  * @category Smartsend
22
  * @package Smartsend_Logistics
23
  * @author Anders Bilfeldt
24
  * @url www.smartsend.dk
25
  */
26
+ $installer = $this;
27
 
28
+ $installer->startSetup(); //start setup
 
 
 
29
 
30
+ $installer->run("
31
+ CREATE TABLE IF NOT EXISTS {$this->getTable('smartsend_flexdelivery')} (
32
+ `id` int(11) unsigned NOT NULL auto_increment,
33
+ `order_id` int(11) NOT NULL,
34
+ `store` varchar(255) NOT NULL default '',
35
+ `flexnote` varchar(255) NOT NULL default '',
36
+ PRIMARY KEY (`id`)
37
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
38
+ "); //creating table
39
+
40
+
41
+ $installer->endSetup(); //end setup
app/design/adminhtml/default/default/layout/logistics.xml CHANGED
@@ -1,36 +1,74 @@
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
- <logistics_adminhtml_pickup_index>
4
- <reference name="content">
5
- <block type="logistics/adminhtml_pickup" name="logistics" >
6
- </block>
7
- </reference>
8
- </logistics_adminhtml_pickup_index>
9
- <logistics_adminhtml_shipping_index>
10
- <reference name="content">
11
- <block type="logistics/adminhtml_shipping" name="shipping">
12
- </block>
13
- </reference>
14
- </logistics_adminhtml_shipping_index>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  <adminhtml_sales_order_view> <!-- sales order view update -->
16
  <reference name="order_info">
17
  <action method="setTemplate">
18
  <template>logistics/sales/order/view/info.phtml</template>
19
  </action>
20
  </reference>
21
-
22
  <reference name="sales_order_tabs">
23
- <block type="logistics/adminhtml_sales_order_view_tab_info" name="logistics_order_view_info_tab" template="logistics/sales/order/view/tab/info.phtml" >
24
- </block>
25
-
26
-
27
- <action method="addTab"><name>smart_send_pickup</name><block>logistics_order_view_info_tab</block></action>
28
  </reference>
29
  </adminhtml_sales_order_view>
30
-
31
-
32
-
33
-
34
-
35
-
36
- </layout>
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
+ <checkout_onepage_index>
4
+ <reference name='head'>
5
+ <reference name="head">
6
+ <action method="addItem">
7
+ <type>js</type>
8
+ <name>logistics/jquery-1.6.4.min.js</name>
9
+ </action>
10
+ <action method="addItem">
11
+ <type>js</type>
12
+ <name>logistics/noconflict.js</name>
13
+ </action>
14
+ </reference>
15
+ </reference>
16
+ <reference name='checkout.onepage.shipping_method.available'> <!-- available shipping methods -->
17
+ <action method='setTemplate'>
18
+ <template>logistics/checkout/onepage/shipping_method/available.phtml</template>
19
+ </action>
20
+ </reference>
21
+ </checkout_onepage_index>
22
+ <checkout_cart_index>
23
+ <reference name='checkout.cart.shipping'> <!-- available shipping methods -->
24
+ <action method='setTemplate'>
25
+ <template>logistics/checkout/cart/shipping.phtml</template>
26
+ </action>
27
+ </reference>
28
+ </checkout_cart_index>
29
+ <checkout_onepage_shippingmethod>
30
+ <reference name='root'> <!-- available shipping methods -->
31
+ <action method='setTemplate'>
32
+ <template>logistics/checkout/onepage/shipping_method/available.phtml</template>
33
+ </action>
34
+ </reference>
35
+ </checkout_onepage_shippingmethod>
36
+ <onestepcheckout_index_index>
37
+ <reference name="head">
38
+ <action method="addItem">
39
+ <type>js</type>
40
+ <name>logistics/jquery-1.6.4.min.js</name>
41
+ </action>
42
+ <action method="addItem">
43
+ <type>js</type>
44
+ <name>logistics/noconflict.js</name>
45
+ </action>
46
+ </reference>
47
+ <reference name ="choose-shipping-method">
48
+ <action method="setTemplate">
49
+ <template>logistics/onestepcheckout/shipping_method.phtml</template>
50
+ </action>
51
+ </reference>
52
+ </onestepcheckout_index_index>
53
+ <onestepcheckout_ajax_save_billing>
54
+ <reference name="choose-shipping-method">
55
+ <action method="setTemplate">
56
+ <template>logistics/onestepcheckout/shipping_method.phtml</template> <!-- show shipping methods -->
57
+ </action>
58
+ </reference>
59
+ </onestepcheckout_ajax_save_billing>
60
  <adminhtml_sales_order_view> <!-- sales order view update -->
61
  <reference name="order_info">
62
  <action method="setTemplate">
63
  <template>logistics/sales/order/view/info.phtml</template>
64
  </action>
65
  </reference>
 
66
  <reference name="sales_order_tabs">
67
+ <block type="logistics/adminhtml_sales_order_view_tab_info" name="logistics_order_view_info_tab" template="logistics/sales/order/view/tab/info.phtml" ></block>
68
+ <action method="addTab">
69
+ <name>smart_send_pickup</name>
70
+ <block>logistics_order_view_info_tab</block>
71
+ </action>
72
  </reference>
73
  </adminhtml_sales_order_view>
74
+ </layout>
 
 
 
 
 
 
app/design/adminhtml/default/default/template/logistics/array_dropdown.phtml CHANGED
@@ -65,6 +65,11 @@ $_colspan = $_colspan > 1 ? 'colspan="' . $_colspan . '"' : '';
65
  <span><?php echo $this->_addButtonLabel ?></span>
66
  </button>
67
  </div>
 
 
 
 
 
68
 
69
  <script type="text/javascript">
70
 
@@ -178,3 +183,35 @@ toggleValueElements({checked:true}, $('grid<?php echo $_htmlId ?>').parentNode);
178
  <?php endif;?>
179
  //]]>
180
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  <span><?php echo $this->_addButtonLabel ?></span>
66
  </button>
67
  </div>
68
+ <div>
69
+ <span><?php echo '<i>'.$this->_columns['orderminprice']['label'].'</i>: '.Mage::helper('logistics')->__( 'Input the order price' ).' <b>'. Mage::helper('logistics')->__( 'excluding tax' ) .'</b> '?></span></br>
70
+ <span><?php echo '<i>'.$this->_columns['ordermaxprice']['label'].'</i>: '.Mage::helper('logistics')->__( 'Input the order price' ).' <b>'. Mage::helper('logistics')->__( 'excluding tax' ) .'</b> ' ?></span></br>
71
+ <span><?php echo '<i>'.$this->_columns['pickupshippingfee']['label'].'</i>: '.Mage::helper('logistics')->__( 'Input the shipping fee' ).' <b>'.( (bool)Mage::getStoreConfig('tax/calculation/shipping_includes_tax') ? Mage::helper('logistics')->__( 'including tax' ) : Mage::helper('logistics')->__( 'excluding tax' ) ).'</b> '; ?></span>
72
+ </div>
73
 
74
  <script type="text/javascript">
75
 
183
  <?php endif;?>
184
  //]]>
185
  </script>
186
+
187
+ <style type="text/css">
188
+ #row_carriers_smartsend_validation .value input.input-text{
189
+ background: none repeat scroll 0 0 rgba(0, 0, 0, 0) !important;
190
+ border: none;
191
+ }
192
+ </style>
193
+ <script type="text/javascript">
194
+ document.getElementById('carriers_smartsend_validation').disabled=true;
195
+ if(document.getElementById('carriers_smartsend_validation').value === 0 || document.getElementById('carriers_smartsend_validation').value === '0' || document.getElementById('carriers_smartsend_validation').value === '') {
196
+ document.getElementById('carriers_smartsend_validation').value = '<?php echo Mage::helper('logistics')->__( 'Please enter valid user information' ); ?>';
197
+ document.getElementById('carriers_smartsend_validation').style.color = "red";
198
+ } else if(document.getElementById('carriers_smartsend_validation').value != '<?php echo Mage::helper('logistics')->__( 'Please enter valid user information' ); ?>'
199
+ && document.getElementById('carriers_smartsend_validation').value != '<?php echo Mage::helper('logistics')->__( 'Save settings to validate' ); ?>'
200
+ && document.getElementById('carriers_smartsend_validation').value != '<?php echo Mage::helper('logistics')->__( 'Valid user information' ); ?>') {
201
+
202
+ var date = new Date();
203
+ var timestamp = date.getTime();
204
+ var week = (60*60*24*7);
205
+
206
+ if(parseInt(document.getElementById('carriers_smartsend_validation').value) + week > timestamp/1000) {
207
+ document.getElementById('carriers_smartsend_validation').value = '<?php echo Mage::helper('logistics')->__( 'Valid user information' ); ?>';
208
+ document.getElementById('carriers_smartsend_validation').style.color = "green";
209
+ } else {
210
+ document.getElementById('carriers_smartsend_validation').value = '<?php echo Mage::helper('logistics')->__( 'Save settings to validate' ); ?>';
211
+ document.getElementById('carriers_smartsend_validation').style.color = "orange";
212
+ }
213
+ } else {
214
+ document.getElementById('carriers_smartsend_validation').value = '<?php echo Mage::helper('logistics')->__( 'Please enter valid user information' ); ?>';
215
+ document.getElementById('carriers_smartsend_validation').style.color = "red";
216
+ }
217
+ </script>
app/design/adminhtml/default/default/template/logistics/sales/order/view/info.phtml CHANGED
@@ -196,63 +196,94 @@ $orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium',
196
  <div class="clear"></div>
197
  <?php
198
  endif;
199
- if(strrpos($_order->getShippingMethod(), "smartsend") !== FALSE):
200
- //if ($_order->getShippingMethod() == "smartsendpickup_pickup" || $_order->getShippingMethod() == "smartsendposten_pickup" || $_order->getShippingMethod() == "smartsendpostdanmark_pickup" || $_order->getShippingMethod() == "smartsendbring_pickup" || $_order->getShippingMethod() == "smartsendgls_pickup" || $_order->getShippingMethod() == "smartsendswipbox_pickup"):
201
- ?>
 
 
 
202
  <div class="box-left">
203
  <!--Smart Send Pickup-->
204
  <div class="entry-edit">
205
  <div class="entry-edit-head">
206
- <h4 class="icon-head"><?php echo $this->__('Smart Send Pickup Address') ?></h4>
207
  </div>
208
  <fieldset>
209
- <div style="float: left" >
210
- <?php echo $this->__('Shipping method').': '.$_order->getShippingMethod(); ?>
211
- </div>
212
- <div class="clear"></div>
213
- <?php
214
- if(($temp = strlen($_order->getShippingMethod()) - strlen('pickup')) >= 0 && strpos($_order->getShippingMethod(), 'pickup', $temp) !== FALSE) {
 
 
 
 
 
 
 
 
 
215
 
216
- $order_id = $_order->getId(); //order id
217
- if ($_order->getShippingMethod() == "smartsendgls_pickup") { //smartsend shipping address
218
- $pickupModel = Mage::getModel('logistics/gls');
219
- } elseif ($_order->getShippingMethod() == "smartsendswipbox_pickup") {
220
- $pickupModel = Mage::getModel('logistics/swipbox');
221
- } elseif ($_order->getShippingMethod() == "smartsendpostdanmark_pickup") {
222
- $pickupModel = Mage::getModel('logistics/postdanmark');
223
- } elseif ($_order->getShippingMethod() == "smartsendposten_pickup") {
224
- $pickupModel = Mage::getModel('logistics/posten');
225
- } elseif ($_order->getShippingMethod() == "smartsendbring_pickup") {
226
- $pickupModel = Mage::getModel('logistics/bring');
227
- } elseif ($_order->getShippingMethod() == "smartsendpickup_pickup") {
228
- $pickupModel = Mage::getModel('logistics/pickup');
229
- }
230
 
231
- if ($pickupModel) {
232
- $pickupData = $pickupModel->getCollection()->addFieldToFilter('order_id', $order_id)->getFirstItem(); //pickup data
 
 
 
 
 
 
 
 
 
 
 
233
 
234
- if ($pickupData->getData()) {
235
- if($pickupData->getPickUpId() != '' && $pickupData->getPickUpId() != '000') {
236
- echo $this->__("Carrier") . ": ".$pickupData->getCarrier() . "<br><br>";
237
- echo $this->__("Pickup Point Id") . ": " . $pickupData->getPickUpId() . "<br>"; //pickup id
238
- echo $pickupData->getCompany() . "<br>" . $pickupData->getStreet() . "<br>" . $pickupData->getZip() . " " . $pickupData->getCity() . "<br>" . $pickupData->getCountry(); //pickup address
239
- } else {
240
- echo $this->__("Shipping to closest pickup point");
241
- }
242
- } else {
243
- echo $this->__("Record not found");
244
- }
245
- }
246
- } else {
247
- echo $this->__("Not a pickup point");
248
- }
249
- ?>
250
- <div style="float: right" >
251
- <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate label') ?>" onclick="setLocation('<?php echo $this->getUrl("logistics/logistics/label",array('order_id' => $_order->getId())); ?>')"/>
252
- <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" onclick="setLocation('<?php echo $this->getUrl("logistics/logistics/labelreturn",array('order_id' => $_order->getId())); ?>')" />
253
- </div>
254
- <div class="clear"></div>
255
- </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
256
  </div>
257
  </div>
258
  <div class="clear"></div>
196
  <div class="clear"></div>
197
  <?php
198
  endif;
199
+
200
+ // Smart Send
201
+ $smartsendorder = Mage::getModel('logistics/ordermagento');
202
+ $smartsendorder->setOrderObject($_order);
203
+
204
+ if( $smartsendorder->isSmartsendOrVConnect() ): ?>
205
  <div class="box-left">
206
  <!--Smart Send Pickup-->
207
  <div class="entry-edit">
208
  <div class="entry-edit-head">
209
+ <h4 class="icon-head"><?php echo $this->__('Smart Send Logistics') ?></h4>
210
  </div>
211
  <fieldset>
212
+ <table cellspacing="0" class="form-list">
213
+ <tbody>
214
+ <tr>
215
+ <td class="label"><label><?php echo $this->__('Shipping method').': '; ?></label></td>
216
+ <td class="value"><strong><?php echo $_order->getShippingDescription(); ?></label></td>
217
+ </tr>
218
+ <!--
219
+ <tr>
220
+ <td class="label"><label><?php echo $this->__('Debug').': '; ?></label></td>
221
+ <td class="value"><strong><?php echo $_order->getShippingMethod(); ?></strong></td>
222
+ </tr>
223
+ -->
224
+ <?php
225
+
226
+ $order_id = $_order->getId(); //order id
227
 
228
+ if( $smartsendorder->isPickup() ) {
229
+ try{
230
+ $pickuppoint = $smartsendorder->getPickupData($_order);
231
+ } catch(Exception $e) {
232
+ //Will be shipping to closest pickup point
233
+ }
234
+ ?>
235
+ <tr>
236
+ <td class="label"><label><?php echo $this->__("Pickuppoint"); ?></label></td>
237
+ <?php
 
 
 
 
238
 
239
+ if ($pickuppoint) {
240
+ ?>
241
+ <td class="value"><strong><?php echo $this->__("ID") .': '. $pickuppoint['agentno'].'<br>'.$pickuppoint['company'] . "<br>" . $pickuppoint['address1'] . "<br>" .$pickuppoint['country'] . ' ' . $pickuppoint['zip'] . " " . $pickuppoint['city']; ?></strong></td>
242
+ <?php
243
+ } else {
244
+ ?>
245
+ <td class="value"><strong><?php echo $this->__("Shipping to closest pickup point"); ?></strong></td>
246
+ <?php
247
+ }
248
+ ?>
249
+ <tr>
250
+ <?php
251
+ }
252
 
253
+ $carrier = explode('_', $_order->getShippingMethod());
254
+
255
+ if ($carrier[0] == 'smartsendpostdanmark' || $carrier[0] == 'smartsendposten') {
256
+ $flexModel = Mage::getModel('logistics/flex');
257
+ $flexData = $flexModel->getCollection()->addFieldToFilter('order_id', $order_id)->getFirstItem(); //pickup data
258
+ if ($flexData->getData()) {
259
+ ?>
260
+ <tr>
261
+ <?php
262
+ if ($flexData->getFlexnote() != '') {
263
+ ?>
264
+ <td class="label"><label><?php echo $this->__("Flexdelivery note"); ?></label></td>
265
+ <td class="value"><strong><?php echo $flexData->getFlexnote(); ?></label></td>
266
+ <?php
267
+ } else {
268
+ ?>
269
+ <td class="value"><strong><?php echo $this->__("Flexdelivery instruction not available"); ?></label></td>
270
+ <?php
271
+ }
272
+ ?>
273
+ <tr>
274
+ <?php
275
+ }
276
+ }
277
+ ?>
278
+ </tbody>
279
+ </table>
280
+ <div class="clear"></div>
281
+ <div style="float: right" >
282
+ <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate label') ?>" onclick="setLocation('<?php echo $this->getUrl("*/logistics/labelNormal",array('order_id' => $_order->getId())); ?>')"/>
283
+ <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" onclick="setLocation('<?php echo $this->getUrl("*/logistics/labelReturn",array('order_id' => $_order->getId())); ?>')" />
284
+ <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate normal and return label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate normal and return label') ?>" onclick="setLocation('<?php echo $this->getUrl("*/logistics/labelNormalReturn",array('order_id' => $_order->getId())); ?>')" />
285
+ </div>
286
+ </fieldset>
287
  </div>
288
  </div>
289
  <div class="clear"></div>
app/design/adminhtml/default/default/template/logistics/sales/order/view/tab/info.phtml CHANGED
@@ -24,10 +24,11 @@
24
  */
25
  $_order = $this->getOrder();
26
 
27
- if(strrpos($_order->getShippingMethod(), "smartsend") !== FALSE):
 
 
28
 
29
- //if ($_order->getShippingMethod() == "smartsendpickup_pickup" || $_order->getShippingMethod() == "smartsendposten_pickup" || $_order->getShippingMethod() == "smartsendpostdanmark_pickup" || $_order->getShippingMethod() == "smartsendbring_pickup" || $_order->getShippingMethod() == "smartsendgls_pickup" || $_order->getShippingMethod() == "smartsendswipbox_pickup"):
30
- ?>
31
  <div class="box-left">
32
  <!--Smart Send Pickup-->
33
  <div class="entry-edit">
@@ -35,53 +36,81 @@ if(strrpos($_order->getShippingMethod(), "smartsend") !== FALSE):
35
  <h4 class="icon-head"><?php echo $this->__('Smart Send Logistics') ?></h4>
36
  </div>
37
  <fieldset>
38
- <div style="float: left" >
39
- <?php echo $this->__('Shipping method').': '.$_order->getShippingMethod(); ?>
40
- </div>
41
- <div class="clear"></div>
42
- <?php
43
- if(($temp = strlen($_order->getShippingMethod()) - strlen('pickup')) >= 0 && strpos($_order->getShippingMethod(), 'pickup', $temp) !== FALSE) {
44
-
45
- $order_id = $_order->getId(); //order id
46
- if ($_order->getShippingMethod() == "smartsendgls_pickup") { //smartsend shipping address
47
- $pickupModel = Mage::getModel('logistics/gls');
48
- } elseif ($_order->getShippingMethod() == "smartsendswipbox_pickup") {
49
- $pickupModel = Mage::getModel('logistics/swipbox');
50
- } elseif ($_order->getShippingMethod() == "smartsendpostdanmark_pickup") {
51
- $pickupModel = Mage::getModel('logistics/postdanmark');
52
- } elseif ($_order->getShippingMethod() == "smartsendposten_pickup") {
53
- $pickupModel = Mage::getModel('logistics/posten');
54
- } elseif ($_order->getShippingMethod() == "smartsendbring_pickup") {
55
- $pickupModel = Mage::getModel('logistics/bring');
56
- } elseif ($_order->getShippingMethod() == "smartsendpickup_pickup") {
57
- $pickupModel = Mage::getModel('logistics/pickup');
58
- }
59
 
60
- if ($pickupModel) {
61
- $pickupData = $pickupModel->getCollection()->addFieldToFilter('order_id', $order_id)->getFirstItem(); //pickup data
 
 
 
 
 
 
 
 
62
 
63
- if ($pickupData->getData()) {
64
- if($pickupData->getPickUpId() != '' && $pickupData->getPickUpId() != '000') {
65
- echo $this->__("Carrier") . ": ".$pickupData->getCarrier() . "<br><br>";
66
- echo $this->__("Pickup Point Id") . ": " . $pickupData->getPickUpId() . "<br>"; //pickup id
67
- echo $pickupData->getCompany() . "<br>" . $pickupData->getStreet() . "<br>" . $pickupData->getZip() . " " . $pickupData->getCity() . "<br>" . $pickupData->getCountry(); //pickup address
68
- } else {
69
- echo $this->__("Shipping to closest pickup point");
70
- }
71
- } else {
72
- echo $this->__("Record not found");
73
- }
74
- }
75
- } else {
76
- echo $this->__("Not a pickup point");
77
- }
78
- ?>
79
- <div style="float: right" >
80
- <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate label') ?>" onclick="setLocation('<?php echo $this->getUrl("logistics/logistics/label",array('order_id' => $_order->getId())); ?>')"/>
81
- <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" onclick="setLocation('<?php echo $this->getUrl("logistics/logistics/labelreturn",array('order_id' => $_order->getId())); ?>')" />
82
- </div>
83
- <div class="clear"></div>
84
- </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  </div>
86
  </div>
87
  <div class="clear"></div>
24
  */
25
  $_order = $this->getOrder();
26
 
27
+ // Smart Send
28
+ $smartsendorder = Mage::getModel('logistics/ordermagento');
29
+ $smartsendorder->setOrderObject($_order);
30
 
31
+ if( $smartsendorder->isSmartsendOrVConnect() ): ?>
 
32
  <div class="box-left">
33
  <!--Smart Send Pickup-->
34
  <div class="entry-edit">
36
  <h4 class="icon-head"><?php echo $this->__('Smart Send Logistics') ?></h4>
37
  </div>
38
  <fieldset>
39
+ <table cellspacing="0" class="form-list">
40
+ <tbody>
41
+ <tr>
42
+ <td class="label"><label><?php echo $this->__('Shipping method').': '; ?></label></td>
43
+ <td class="value"><strong><?php echo $_order->getShippingDescription(); ?></label></td>
44
+ </tr>
45
+ <!--
46
+ <tr>
47
+ <td class="label"><label><?php echo $this->__('Debug').': '; ?></label></td>
48
+ <td class="value"><strong><?php echo $_order->getShippingMethod(); ?></strong></td>
49
+ </tr>
50
+ -->
51
+ <?php
52
+
53
+ $order_id = $_order->getId(); //order id
 
 
 
 
 
 
54
 
55
+ if( $smartsendorder->isPickup() ) {
56
+ try{
57
+ $pickuppoint = $smartsendorder->getPickupData($_order);
58
+ } catch(Exception $e) {
59
+ //Will be shipping to closest pickup point
60
+ }
61
+ ?>
62
+ <tr>
63
+ <td class="label"><label><?php echo $this->__("Pickuppoint"); ?></label></td>
64
+ <?php
65
 
66
+ if ($pickuppoint) {
67
+ ?>
68
+ <td class="value"><strong><?php echo $this->__("ID") .': '. $pickuppoint['agentno'].'<br>'.$pickuppoint['company'] . "<br>" . $pickuppoint['address1'] . "<br>" .$pickuppoint['country'] . ' ' . $pickuppoint['zip'] . " " . $pickuppoint['city']; ?></strong></td>
69
+ <?php
70
+ } else {
71
+ ?>
72
+ <td class="value"><strong><?php echo $this->__("Shipping to closest pickup point"); ?></strong></td>
73
+ <?php
74
+ }
75
+ ?>
76
+ <tr>
77
+ <?php
78
+ }
79
+
80
+ $carrier = explode('_', $_order->getShippingMethod());
81
+
82
+ if ($carrier[0] == 'smartsendpostdanmark' || $carrier[0] == 'smartsendposten') {
83
+ $flexModel = Mage::getModel('logistics/flex');
84
+ $flexData = $flexModel->getCollection()->addFieldToFilter('order_id', $order_id)->getFirstItem(); //pickup data
85
+ if ($flexData->getData()) {
86
+ ?>
87
+ <tr>
88
+ <?php
89
+ if ($flexData->getFlexnote() != '') {
90
+ ?>
91
+ <td class="label"><label><?php echo $this->__("Flexdelivery"); ?></label></td>
92
+ <td class="value"><strong><?php echo $flexData->getFlexnote(); ?></label></td>
93
+ <?php
94
+ } else {
95
+ ?>
96
+ <td class="value"><strong><?php echo $this->__("Flexdelivery instruction not available"); ?></label></td>
97
+ <?php
98
+ }
99
+ ?>
100
+ <tr>
101
+ <?php
102
+ }
103
+ }
104
+ ?>
105
+ </tbody>
106
+ </table>
107
+ <div class="clear"></div>
108
+ <div style="float: right" >
109
+ <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate label') ?>" onclick="setLocation('<?php echo $this->getUrl("*/logistics/labelNormal",array('order_id' => $_order->getId())); ?>')"/>
110
+ <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate return label') ?>" onclick="setLocation('<?php echo $this->getUrl("*/logistics/labelReturn",array('order_id' => $_order->getId())); ?>')" />
111
+ <input type="button" class="form-button" value="<?php echo Mage::helper('logistics')->__('Generate normal and return label') ?>" title="<?php echo Mage::helper('logistics')->__('Generate normal and return label') ?>" onclick="setLocation('<?php echo $this->getUrl("*/logistics/labelNormalReturn",array('order_id' => $_order->getId())); ?>')" />
112
+ </div>
113
+ </fieldset>
114
  </div>
115
  </div>
116
  <div class="clear"></div>
app/design/frontend/base/default/layout/logistics.xml CHANGED
@@ -1,29 +1,52 @@
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
  <checkout_onepage_index>
4
- <reference name='head'>
5
- <reference name="head">
6
- <action method="addItem"><type>js</type><name>logistics/jquery-1.6.4.min.js</name></action>
7
- <action method="addItem"><type>js</type><name>logistics/noconflict.js</name></action>
8
- </reference>
9
- </reference>
10
- <reference name='checkout.onepage.shipping_method.available'> <!-- available shipping methods -->
11
- <action method='setTemplate'>
12
- <template>logistics/checkout/onepage/shipping_method/available.phtml</template>
13
  </action>
14
- </reference>
 
 
 
 
 
 
 
 
 
 
15
  </checkout_onepage_index>
 
 
 
 
 
 
 
16
  <checkout_onepage_shippingmethod>
17
- <reference name='root'> <!-- available shipping methods -->
18
- <action method='setTemplate'>
19
- <template>logistics/checkout/onepage/shipping_method/available.phtml</template>
20
- </action>
21
- </reference>
22
  </checkout_onepage_shippingmethod>
23
  <onestepcheckout_index_index>
24
  <reference name="head">
25
- <action method="addItem"><type>js</type><name>logistics/jquery-1.6.4.min.js</name></action>
26
- <action method="addItem"><type>js</type><name>logistics/noconflict.js</name></action>
 
 
 
 
 
 
 
 
 
 
27
  </reference>
28
  <reference name ="choose-shipping-method">
29
  <action method="setTemplate">
@@ -38,4 +61,128 @@
38
  </action>
39
  </reference>
40
  </onestepcheckout_ajax_save_billing>
41
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?xml version="1.0"?>
2
  <layout version="0.1.0">
3
  <checkout_onepage_index>
4
+ <reference name='head'>
5
+ <reference name="head">
6
+ <action method="addItem">
7
+ <type>js</type>
8
+ <name>logistics/jquery-1.10.2.min.js</name>
 
 
 
 
9
  </action>
10
+ <action method="addItem">
11
+ <type>js</type>
12
+ <name>logistics/noconflict.js</name>
13
+ </action>
14
+ </reference>
15
+ </reference>
16
+ <reference name='checkout.onepage.shipping_method.available'> <!-- available shipping methods -->
17
+ <action method='setTemplate'>
18
+ <template>logistics/checkout/onepage/shipping_method/available.phtml</template>
19
+ </action>
20
+ </reference>
21
  </checkout_onepage_index>
22
+ <checkout_cart_index>
23
+ <reference name='checkout.cart.shipping'> <!-- available shipping methods -->
24
+ <action method='setTemplate'>
25
+ <template>logistics/checkout/cart/shipping.phtml</template>
26
+ </action>
27
+ </reference>
28
+ </checkout_cart_index>
29
  <checkout_onepage_shippingmethod>
30
+ <reference name='root'> <!-- available shipping methods -->
31
+ <action method='setTemplate'>
32
+ <template>logistics/checkout/onepage/shipping_method/available.phtml</template>
33
+ </action>
34
+ </reference>
35
  </checkout_onepage_shippingmethod>
36
  <onestepcheckout_index_index>
37
  <reference name="head">
38
+ <action method="addItem">
39
+ <type>js</type>
40
+ <name>logistics/jquery-1.10.2.min.js</name>
41
+ </action>
42
+ <action method="addItem">
43
+ <type>js</type>
44
+ <name>logistics/noconflict.js</name>
45
+ </action>
46
+ <action method="addItem">
47
+ <type>skin_js</type>
48
+ <name>js/logistics.js</name>
49
+ </action>
50
  </reference>
51
  <reference name ="choose-shipping-method">
52
  <action method="setTemplate">
61
  </action>
62
  </reference>
63
  </onestepcheckout_ajax_save_billing>
64
+
65
+ <!-- START: Overriding 'Magestore One Step Checkout' shipping method templates -->
66
+ <onestepcheckout_index_index_flat_20columns>
67
+ <reference name="head">
68
+ <action method="addItem">
69
+ <type>js</type>
70
+ <name>logistics/jquery-1.10.2.min.js</name>
71
+ </action>
72
+ <action method="addItem">
73
+ <type>js</type>
74
+ <name>logistics/noconflict.js</name>
75
+ </action>
76
+ </reference>
77
+ <reference name ="onestepcheckout_shipping_method">
78
+ <action method="setTemplate">
79
+ <template>logistics/magestoreOnestepcheckout/shipping_method.phtml</template>
80
+ </action>
81
+ </reference>
82
+ </onestepcheckout_index_index_flat_20columns>
83
+ <onestepcheckout_index_index_flat_25columns>
84
+ <reference name="head">
85
+ <action method="addItem">
86
+ <type>js</type>
87
+ <name>logistics/jquery-1.10.2.min.js</name>
88
+ </action>
89
+ <action method="addItem">
90
+ <type>js</type>
91
+ <name>logistics/noconflict.js</name>
92
+ </action>
93
+ </reference>
94
+ <reference name ="onestepcheckout_shipping_method">
95
+ <action method="setTemplate">
96
+ <template>logistics/magestoreOnestepcheckout/shipping_method.phtml</template>
97
+ </action>
98
+ </reference>
99
+ </onestepcheckout_index_index_flat_25columns>
100
+ <onestepcheckout_index_index_flat_30columns>
101
+ <reference name="head">
102
+ <action method="addItem">
103
+ <type>js</type>
104
+ <name>logistics/jquery-1.10.2.min.js</name>
105
+ </action>
106
+ <action method="addItem">
107
+ <type>js</type>
108
+ <name>logistics/noconflict.js</name>
109
+ </action>
110
+ </reference>
111
+ <reference name ="onestepcheckout_shipping_method">
112
+ <action method="setTemplate">
113
+ <template>logistics/magestoreOnestepcheckout/shipping_method.phtml</template>
114
+ </action>
115
+ </reference>
116
+ </onestepcheckout_index_index_flat_30columns>
117
+ <onestepcheckout_index_index_material_20columns>
118
+ <reference name="head">
119
+ <action method="addItem">
120
+ <type>js</type>
121
+ <name>logistics/jquery-1.10.2.min.js</name>
122
+ </action>
123
+ <action method="addItem">
124
+ <type>js</type>
125
+ <name>logistics/noconflict.js</name>
126
+ </action>
127
+ </reference>
128
+ <reference name ="onestepcheckout_shipping_method">
129
+ <action method="setTemplate">
130
+ <template>logistics/magestoreOnestepcheckout/shipping_method.phtml</template>
131
+ </action>
132
+ </reference>
133
+ </onestepcheckout_index_index_material_20columns>
134
+ <onestepcheckout_index_index_material_25columns>
135
+ <reference name="head">
136
+ <action method="addItem">
137
+ <type>js</type>
138
+ <name>logistics/jquery-1.10.2.min.js</name>
139
+ </action>
140
+ <action method="addItem">
141
+ <type>js</type>
142
+ <name>logistics/noconflict.js</name>
143
+ </action>
144
+ </reference>
145
+ <reference name ="onestepcheckout_shipping_method">
146
+ <action method="setTemplate">
147
+ <template>logistics/magestoreOnestepcheckout/shipping_method.phtml</template>
148
+ </action>
149
+ </reference>
150
+ </onestepcheckout_index_index_material_25columns>
151
+ <onestepcheckout_index_index_material_30columns>
152
+ <reference name="head">
153
+ <action method="addItem">
154
+ <type>js</type>
155
+ <name>logistics/jquery-1.10.2.min.js</name>
156
+ </action>
157
+ <action method="addItem">
158
+ <type>js</type>
159
+ <name>logistics/noconflict.js</name>
160
+ </action>
161
+ </reference>
162
+ <reference name ="onestepcheckout_shipping_method">
163
+ <action method="setTemplate">
164
+ <template>logistics/magestoreOnestepcheckout/shipping_method.phtml</template>
165
+ </action>
166
+ </reference>
167
+ </onestepcheckout_index_index_material_30columns>
168
+
169
+ <!-- START: on saving shipping address -->
170
+ <onestepcheckout_shipping_payment_review_material_20columns>
171
+ <block type="checkout/onepage_shipping_method_available" name="onestepcheckout_shipping_method" as="onestepcheckout_shipping_method" template="logistics/magestoreOnestepcheckout/shipping_method.phtml" />
172
+ <update handle="onestepcheckout_payment_review_material_20columns"/>
173
+ </onestepcheckout_shipping_payment_review_material_20columns>
174
+
175
+ <onestepcheckout_shipping_payment_review_flat_20columns>
176
+ <block type="checkout/onepage_shipping_method_available" name="onestepcheckout_shipping_method" as="onestepcheckout_shipping_method" template="logistics/magestoreOnestepcheckout/shipping_method.phtml" />
177
+ <update handle="onestepcheckout_payment_review_flat_20columns"/>
178
+ </onestepcheckout_shipping_payment_review_flat_20columns>
179
+
180
+ <onestepcheckout_shipping_payment_review_flat_30columns>
181
+ <block type="checkout/onepage_shipping_method_available" name="onestepcheckout_shipping_method" as="onestepcheckout_shipping_method" template="logistics/magestoreOnestepcheckout/shipping_method.phtml" />
182
+ <update handle="onestepcheckout_payment_review_flat_30columns"/>
183
+ </onestepcheckout_shipping_payment_review_flat_30columns>
184
+ <!-- END: on saving shipping address -->
185
+
186
+ <!-- END: START: Overriding 'Magestore One Step Checkout' shipping method templates -->
187
+
188
+ </layout>
app/design/frontend/base/default/template/logistics/.DS_Store ADDED
Binary file
app/design/frontend/base/default/template/logistics/checkout/.DS_Store ADDED
Binary file
app/design/frontend/base/default/template/logistics/checkout/cart/shipping.phtml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php /** @var $this Mage_Checkout_Block_Cart_Shipping */ ?>
28
+ <div class="shipping">
29
+ <h2><?php echo $this->__('Estimate Shipping and Tax') ?></h2>
30
+ <div class="shipping-form">
31
+ <form action="<?php echo $this->getFormActionUrl() ?>" method="post" id="shipping-zip-form">
32
+ <p><?php echo $this->__('Enter your destination to get a shipping estimate.') ?></p>
33
+ <ul class="form-list">
34
+ <li>
35
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
36
+ <div class="input-box">
37
+ <?php echo Mage::getBlockSingleton('directory/data')->getCountryHtmlSelect($this->getEstimateCountryId()) ?>
38
+ </div>
39
+ </li>
40
+ <?php //if($this->getStateActive()): ?>
41
+ <li>
42
+ <label for="region_id"<?php if ($this->isStateProvinceRequired()) echo ' class="required"' ?>><?php if ($this->isStateProvinceRequired()) echo '<em>*</em>' ?><?php echo $this->__('State/Province') ?></label>
43
+ <div class="input-box">
44
+ <select id="region_id" name="region_id" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" style="display:none;"<?php echo ($this->isStateProvinceRequired() ? ' class="validate-select"' : '') ?>>
45
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
46
+ </select>
47
+ <script type="text/javascript">
48
+ //<![CDATA[
49
+ $('region_id').setAttribute('defaultValue', "<?php echo $this->getEstimateRegionId() ?>");
50
+ //]]>
51
+ </script>
52
+ <input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getEstimateRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text" style="display:none;" />
53
+ </div>
54
+ </li>
55
+ <?php //endif; ?>
56
+ <?php if ($this->getCityActive()): ?>
57
+ <li>
58
+ <label for="city"<?php if ($this->isCityRequired()) echo ' class="required"' ?>><?php if ($this->isCityRequired()) echo '<em>*</em>' ?><?php echo $this->__('City') ?></label>
59
+ <div class="input-box">
60
+ <input class="input-text<?php if ($this->isCityRequired()): ?> required-entry<?php endif; ?>" id="city" type="text" name="estimate_city" value="<?php echo $this->escapeHtml($this->getEstimateCity()) ?>" />
61
+ </div>
62
+ </li>
63
+ <?php endif; ?>
64
+ <li>
65
+ <label for="postcode"<?php if ($this->isZipCodeRequired()) echo ' class="required"' ?>><?php if ($this->isZipCodeRequired()) echo '<em>*</em>' ?><?php echo $this->__('Zip/Postal Code') ?></label>
66
+ <div class="input-box">
67
+ <input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()): ?> required-entry<?php endif; ?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo $this->escapeHtml($this->getEstimatePostcode()) ?>" />
68
+ </div>
69
+ </li>
70
+ </ul>
71
+ <div class="buttons-set">
72
+ <button type="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Get a Quote')) ?>" onclick="coShippingMethodForm.submit()" class="button"><span><span><?php echo $this->__('Get a Quote') ?></span></span></button>
73
+ </div>
74
+ </form>
75
+ <script type="text/javascript">
76
+ //<![CDATA[
77
+ new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
78
+ //]]>
79
+ </script>
80
+
81
+ <?php if (($_shippingRateGroups = $this->getEstimateRates())): ?>
82
+ <form id="co-shipping-method-form" action="<?php echo $this->getUpdateFormActionUrl() ?>">
83
+ <dl class="sp-methods">
84
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
85
+ <dt><?php echo $this->escapeHtml($this->getCarrierName($code)) ?></dt>
86
+ <dd>
87
+ <ul>
88
+ <?php foreach ($_rates as $_rate): ?>
89
+ <li<?php if ($_rate->getErrorMessage()) echo ' class="error-msg"'; ?>>
90
+ <?php if ($_rate->getErrorMessage()): ?>
91
+ <?php echo $this->escapeHtml($_rate->getErrorMessage()) ?>
92
+ <?php else: ?>
93
+ <input name="estimate_method" type="radio" value="<?php echo $this->escapeHtml($_rate->getCode()) ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if ($_rate->getCode() === $this->getAddressShippingMethod()) echo ' checked="checked"' ?> class="radio" />
94
+ <?php
95
+ $shipping_method = $_rate->getCode();
96
+ $carrier = explode('_', $shipping_method);
97
+ $smartsend_carrier = $carrier['0'];
98
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
99
+
100
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax") && $excludedMethod) {
101
+ ?>
102
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
103
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), 0); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
104
+ <?php echo $_excl; ?>
105
+
106
+ </label>
107
+ <?php } else {
108
+ ?>
109
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $this->escapeHtml($_rate->getMethodTitle()) ?>
110
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
111
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
112
+ <?php echo $_excl; ?>
113
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
114
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
115
+ <?php endif; ?>
116
+ </label>
117
+ <?php
118
+ }
119
+ ?>
120
+ <?php endif ?>
121
+ </li>
122
+ <?php endforeach; ?>
123
+ </ul>
124
+ </dd>
125
+ <?php endforeach; ?>
126
+ </dl>
127
+ <div class="buttons-set">
128
+ <button type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Update Total')) ?>" class="button" name="do" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Update Total')) ?>"><span><span><?php echo $this->__('Update Total') ?></span></span></button>
129
+ </div>
130
+ </form>
131
+ <?php endif; ?>
132
+ <script type="text/javascript">
133
+ //<![CDATA[
134
+ var coShippingMethodForm = new VarienForm('shipping-zip-form');
135
+ var countriesWithOptionalZip = <?php echo $this->helper('directory')->getCountriesWithOptionalZip(true) ?>;
136
+
137
+ coShippingMethodForm.submit = function() {
138
+ var country = $F('country');
139
+ var optionalZip = false;
140
+
141
+ for (i = 0; i < countriesWithOptionalZip.length; i++) {
142
+ if (countriesWithOptionalZip[i] == country) {
143
+ optionalZip = true;
144
+ }
145
+ }
146
+ if (optionalZip) {
147
+ $('postcode').removeClassName('required-entry');
148
+ }
149
+ else {
150
+ $('postcode').addClassName('required-entry');
151
+ }
152
+ return VarienForm.prototype.submit.bind(coShippingMethodForm)();
153
+ }
154
+ //]]>
155
+ </script>
156
+ </div>
157
+ </div>
app/design/frontend/base/default/template/logistics/checkout/onepage/.DS_Store ADDED
Binary file
app/design/frontend/base/default/template/logistics/checkout/onepage/shipping_method/available.phtml CHANGED
@@ -22,9 +22,7 @@
22
  * @author Anders Bilfeldt
23
  * @url www.smartsend.dk
24
  */
25
- $pickupShippingFee = Mage::getSingleton('logistics/carrier_pickup')->getPickupShippingFee(); //pickup shipping fees
26
  $bringShippingFee = Mage::getSingleton('logistics/carrier_bring')->getBringShippingFee(); //bring shipping fees
27
- $swipboxShippingFee = Mage::getSingleton('logistics/carrier_swipbox')->getSwipboxShippingFee(); //swipbox shipping fees
28
  $glsShippingFee = Mage::getSingleton('logistics/carrier_gls')->getGlsShippingFee(); //gls shipping fees
29
  $postdanmarkShippingFee = Mage::getSingleton('logistics/carrier_postdanmark')->getPostdanmarkShippingFee(); //postdanmark shipping fees
30
  $postenShippingFee = Mage::getSingleton('logistics/carrier_posten')->getPostenShippingFee(); //posten shipping fees
@@ -45,11 +43,7 @@ if (!($_shippingRateGroups = $this->getShippingRates())): //if no
45
  <?php
46
  $_sole = $_sole && count($_rates) == 1;
47
  foreach ($_rates as $_rate):
48
- if ($_rate->getCode() === 'smartsendpickup_smartsendpickup') { //get shipping code
49
- $shippingFee = $pickupShippingFee;
50
- } elseif ($_rate->getCode() === 'smartsendswipbox_smartsendswipbox') {
51
- $shippingFee = $swipboxShippingFee;
52
- } elseif ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
53
  $shippingFee = $postdanmarkShippingFee;
54
  } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
55
  $shippingFee = $postenShippingFee;
@@ -86,11 +80,12 @@ if (!($_shippingRateGroups = $this->getShippingRates())): //if no
86
  $shipping_method = $_rate->getCode();
87
  $carrier = explode('_', $shipping_method);
88
  $smartsend_carrier = $carrier['0'];
 
89
 
90
- if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax")) {
91
  ?>
92
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
93
- <?php $_excl = Mage::helper('core')->currency($_rate->getPrice(), true, false); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
94
  <?php echo $_excl; ?>
95
 
96
  </label>
22
  * @author Anders Bilfeldt
23
  * @url www.smartsend.dk
24
  */
 
25
  $bringShippingFee = Mage::getSingleton('logistics/carrier_bring')->getBringShippingFee(); //bring shipping fees
 
26
  $glsShippingFee = Mage::getSingleton('logistics/carrier_gls')->getGlsShippingFee(); //gls shipping fees
27
  $postdanmarkShippingFee = Mage::getSingleton('logistics/carrier_postdanmark')->getPostdanmarkShippingFee(); //postdanmark shipping fees
28
  $postenShippingFee = Mage::getSingleton('logistics/carrier_posten')->getPostenShippingFee(); //posten shipping fees
43
  <?php
44
  $_sole = $_sole && count($_rates) == 1;
45
  foreach ($_rates as $_rate):
46
+ if ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
 
 
 
 
47
  $shippingFee = $postdanmarkShippingFee;
48
  } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
49
  $shippingFee = $postenShippingFee;
80
  $shipping_method = $_rate->getCode();
81
  $carrier = explode('_', $shipping_method);
82
  $smartsend_carrier = $carrier['0'];
83
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
84
 
85
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax") && $excludedMethod) {
86
  ?>
87
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
88
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(),0); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
89
  <?php echo $_excl; ?>
90
 
91
  </label>
app/design/frontend/base/default/template/logistics/email/order/shipment/track.phtml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Smartsend_Logistics
4
+ *
5
+ * This source file is subject to the GNU General Public License v3.0
6
+ * that is bundled with this package in the file license.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.html
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@smartsend.dk so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
16
+ * versions in the future. If you wish to customize the plugin for your
17
+ * needs please refer to http://www.smartsend.dk
18
+ *
19
+ * @folder /
20
+ * @category Smartsend
21
+ * @package Smartsend_Logistics
22
+ * @author Anders Bilfeldt
23
+ * @url www.smartsend.dk
24
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license GNU General Public License v3.0
26
+ */
27
+ ?>
28
+ <?php $_shipment=$this->getShipment() ?>
29
+ <?php $_order=$this->getOrder() ?>
30
+ <?php if ($_shipment && $_order && $_shipment->getAllTracks()): ?>
31
+ <table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
32
+ <thead>
33
+ <tr>
34
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Shipped By') ?></th>
35
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px"><?php echo $this->__('Tracking Number') ?></th>
36
+ </tr>
37
+ </thead>
38
+ <tbody>
39
+ <?php $i=0; foreach ($_shipment->getAllTracks() as $_track): $i++ ?>
40
+ <tr <?php echo $i%2?'bgcolor="#F6F6F6"':'' ?>>
41
+ <?php
42
+ /**
43
+ * Determine carrier.
44
+ * Title can be find using:
45
+ * echo $this->escapeHtml($_track->getTitle());
46
+ */
47
+ if( $carrier = Mage::getSingleton('shipping/config')->getCarrierInstance($_track->getCarrierCode()) ) {
48
+ $carrier = $carrier->getConfigData('title');
49
+ }
50
+ ?>
51
+ <td align="left" valign="top" style="padding:3px 9px"><?php echo (isset($carrier) && $carrier != '' ? $carrier : Mage::helper('sales')->__('Carrier name not found')); ?></td>
52
+
53
+ <?php if ($carrier=='Post Danmark'): ?>
54
+ <td align="center" valign="top" style="padding:3px 9px"><a href="http://www2.postdanmark.dk/tracktrace/TrackTrace.do?i_stregkode=<?php echo $this->escapeHtml($_track->getNumber()); ?>" target="_blank"><?php echo $this->escapeHtml($_track->getNumber()) ?></a></td>
55
+ <?php elseif ($carrier=='GLS'): ?>
56
+ <td align="center" valign="top" style="padding:3px 9px"><a href="http://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=<?php echo $this->escapeHtml($_track->getNumber()); ?>" target="_blank"><?php echo $this->escapeHtml($_track->getNumber()) ?></a></td>
57
+ <?php elseif ($carrier=='Bring'): ?>
58
+ <td align="center" valign="top" style="padding:3px 9px"><a href="http://sporing.bring.no/sporing.html?q=<?php echo $this->escapeHtml($_track->getNumber()); ?>" target="_blank"><?php echo $this->escapeHtml($_track->getNumber()) ?></a></td>
59
+ <?php elseif ($carrier=='Posten'): ?>
60
+ <td align="center" valign="top" style="padding:3px 9px"><a href="http://www.postnord.se/en/tools/track/Pages/track-and-trace.aspx?search=<?php echo $this->escapeHtml($_track->getNumber()); ?>" target="_blank"><?php echo $this->escapeHtml($_track->getNumber()) ?></a></td>
61
+ <?php else: ?>
62
+ <td align="center" valign="top" style="padding:3px 9px"><?php echo $this->escapeHtml($_track->getNumber()) ?></a></td>
63
+ <?php endif; ?>
64
+ </tr>
65
+ <?php endforeach ?>
66
+ </tbody>
67
+ </table>
68
+ <?php endif; ?>
app/design/frontend/base/default/template/logistics/magestoreOnestepcheckout/shipping_method.phtml ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Smartsend_Logistics
4
+ *
5
+ * This source file is subject to the GNU General Public License v3.0
6
+ * that is bundled with this package in the file license.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.html
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@smartsend.dk so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
16
+ * versions in the future. If you wish to customize the plugin for your
17
+ * needs please refer to http://www.smartsend.dk
18
+ *
19
+ * @folder /app/design/frontend/default/default/template/logistics/magestoreOnestepcheckout/shipping_method.phtml
20
+ * @category Smartsend
21
+ * @package Smartsend_Logistics
22
+ * @author Anders Bilfeldt
23
+ * @url www.smartsend.dk
24
+ */
25
+ $bringShippingFee = Mage::getSingleton('logistics/carrier_bring')->getBringShippingFee(); //bring shipping fees
26
+ $glsShippingFee = Mage::getSingleton('logistics/carrier_gls')->getGlsShippingFee(); //gls shipping fees
27
+ $postdanmarkShippingFee = Mage::getSingleton('logistics/carrier_postdanmark')->getPostdanmarkShippingFee(); //postdanmark shipping fees
28
+ $postenShippingFee = Mage::getSingleton('logistics/carrier_posten')->getPostenShippingFee(); //posten shipping fees
29
+ if (!($_shippingRateGroups = $this->getShippingRates())): //if no shipping rates
30
+ ?>
31
+ <strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
32
+ <?php else: ?>
33
+ <?php if (count($_shippingRateGroups) == '1' && Mage::getStoreConfig('onestepcheckout/general/hide_shipping_method')): ?> <!-- if hide shipping method -->
34
+ <dl class="sp-methods" style="display: none">
35
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?> <!-- shipping group -->
36
+ <dt><?php echo $this->getCarrierName($code) ?></dt> <!-- shipping carrier name -->
37
+ <?php
38
+ foreach ($_rates as $_rate):
39
+ if ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
40
+ $shippingFee = $postdanmarkShippingFee;
41
+ } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
42
+ $shippingFee = $postenShippingFee;
43
+ } elseif ($_rate->getCode() === 'smartsendgls_smartsendgls') {
44
+ $shippingFee = $glsShippingFee;
45
+ } elseif ($_rate->getCode() === 'smartsendbring_smartsendbring') {
46
+ $shippingFee = $bringShippingFee;
47
+ } else {
48
+ $shippingFee = $_rate->getPrice();
49
+ }
50
+
51
+ $_rate->setPrice($shippingFee);
52
+ ?>
53
+ <dd style="margin-bottom: 5px;">
54
+ <?php if ($_rate->getErrorMessage()): ?>
55
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
56
+ <?php else: ?>
57
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" />
58
+ <?php
59
+ $shipping_method = $_rate->getCode();
60
+ $carrier = explode('_', $shipping_method);
61
+ $smartsend_carrier = $carrier['0'];
62
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
63
+
64
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax") && $excludedMethod) {
65
+ ?>
66
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
67
+ <strong>
68
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), 0); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
69
+ <?php echo $_excl; ?>
70
+ </strong>
71
+ </label>
72
+ <?php
73
+ } else {
74
+ ?>
75
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
76
+ <strong>
77
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?> <!-- get shipping price excluding tax -->
78
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?> <!-- get shipping price with tax -->
79
+ <?php echo $_excl; ?>
80
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> <!-- display prices -->
81
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
82
+ <?php endif; ?>
83
+ </strong>
84
+ </label>
85
+ <?php
86
+ }
87
+ ?>
88
+
89
+ <?php endif ?>
90
+ </dd>
91
+ <?php endforeach; ?>
92
+ <?php endforeach; ?>
93
+ </dl>
94
+ <?php else: ?>
95
+ <dl class="sp-methods">
96
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?> <!-- getting shipping rates -->
97
+ <dt><?php echo $this->getCarrierName($code) ?></dt> <!-- getting carrier names -->
98
+
99
+ <dd>
100
+ <ul>
101
+ <?php
102
+ foreach ($_rates as $_rate):
103
+ if ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
104
+ $shippingFee = $postdanmarkShippingFee;
105
+ } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
106
+ $shippingFee = $postenShippingFee;
107
+ } elseif ($_rate->getCode() === 'smartsendgls_smartsendgls') {
108
+ $shippingFee = $glsShippingFee;
109
+ } elseif ($_rate->getCode() === 'smartsendbring_smartsendbring') {
110
+ $shippingFee = $bringShippingFee;
111
+ } else {
112
+ $shippingFee = $_rate->getPrice();
113
+ }
114
+
115
+ $_rate->setPrice($shippingFee);
116
+ ?>
117
+
118
+ <?php if ($_rate->getErrorMessage()): ?>
119
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
120
+ <?php else: ?>
121
+ <li class="radioparent">
122
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
123
+
124
+ <input name="shipping_method" type="radio" class=" radio validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if ($_rate->getCode() === $this->getAddressShippingMethod()) echo ' checked="checked"' ?> onclick="save_shipping_method(shipping_method_url, update_shipping_payment, update_shipping_review);
125
+ showShipping(<?php echo "'" . $_rate->getCode() . "'"; ?>, 's_method_<?php echo $_rate->getCode() ?>');" />
126
+ <?php if ($_rate->getCode() === $this->getAddressShippingMethod()) echo '<script type="text/javascript"> showShipping("' . $_rate->getCode() . '","s_method_' . $_rate->getCode() . '" );</script>;' ?>
127
+ <span class="outer"><span class="inner"></span></span>
128
+ <?php
129
+ $shipping_method = $_rate->getCode();
130
+ $carrier = explode('_', $shipping_method);
131
+ $smartsend_carrier = $carrier['0'];
132
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
133
+
134
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax") && $excludedMethod) {
135
+ ?>
136
+ <strong>
137
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), 0); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
138
+ <?php echo $_excl; ?>
139
+ </strong>
140
+ <?php
141
+ } else {
142
+ ?>
143
+
144
+ <strong> <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?> <!-- get shipping price excluding tax -->
145
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?> <!-- get shipping price with tax -->
146
+ <?php echo $_excl; ?>
147
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> <!-- display prices -->
148
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
149
+ <?php endif; ?>
150
+ </strong>
151
+ <?php
152
+ }
153
+ ?>
154
+
155
+ <?php
156
+ $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code); //get carrier instance
157
+ if ($_rate->getCode() != 'smartsendpostdanmark_smartsendpostdanmark' && $_rate->getCode() != 'smartsendposten_smartsendposten' && $_rate->getCode() != 'smartsendgls_smartsendgls' && $_rate->getCode() != 'smartsendbring_smartsendbring') {
158
+
159
+ if ($carrier->getFormBlock()) {
160
+ $block = $this->getLayout()->createBlock($carrier->getFormBlock());
161
+ $block->setMethodCode($code);
162
+ $block->setRate($_rate);
163
+ $block->setMethodInstance($carrier);
164
+ echo $block->_toHtml();
165
+ }
166
+ }
167
+ ?>
168
+ </label>
169
+
170
+ </li>
171
+ <?php endif; ?>
172
+ <?php endforeach; ?>
173
+ </ul>
174
+ </dd>
175
+ <?php endforeach; ?>
176
+ </dl>
177
+ <?php endif; ?>
178
+ <?php endif; ?>
app/design/frontend/base/default/template/logistics/onestepcheckout/shipping_method.phtml CHANGED
@@ -22,9 +22,7 @@
22
  * @author Anders Bilfeldt
23
  * @url www.smartsend.dk
24
  */
25
- $pickupShippingFee = Mage::getSingleton('logistics/carrier_pickup')->getPickupShippingFee(); //pickup shipping fees
26
  $bringShippingFee = Mage::getSingleton('logistics/carrier_bring')->getBringShippingFee(); //bring shipping fees
27
- $swipboxShippingFee = Mage::getSingleton('logistics/carrier_swipbox')->getSwipboxShippingFee(); //swipbox shipping fees
28
  $glsShippingFee = Mage::getSingleton('logistics/carrier_gls')->getGlsShippingFee(); //gls shipping fees
29
  $postdanmarkShippingFee = Mage::getSingleton('logistics/carrier_postdanmark')->getPostdanmarkShippingFee(); //postdanmark shipping fees
30
  $postenShippingFee = Mage::getSingleton('logistics/carrier_posten')->getPostenShippingFee(); //posten shipping fees
@@ -38,11 +36,7 @@ if (!($_shippingRateGroups = $this->getShippingRates())):
38
  <dd><?php echo $this->getCarrierName($code) ?></dd> <!-- shipping carrier name -->
39
  <?php
40
  foreach ($_rates as $_rate):
41
- if ($_rate->getCode() === 'smartsendpickup_smartsendpickup') {
42
- $shippingFee = $pickupShippingFee;
43
- } elseif ($_rate->getCode() === 'smartsendswipbox_smartsendswipbox') {
44
- $shippingFee = $swipboxShippingFee;
45
- } elseif ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
46
  $shippingFee = $postdanmarkShippingFee;
47
  } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
48
  $shippingFee = $postenShippingFee;
@@ -65,12 +59,13 @@ if (!($_shippingRateGroups = $this->getShippingRates())):
65
  $shipping_method = $_rate->getCode();
66
  $carrier = explode('_', $shipping_method);
67
  $smartsend_carrier = $carrier['0'];
 
68
 
69
- if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax")) {
70
  ?>
71
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
72
  <strong>
73
- <?php $_excl = Mage::helper('core')->currency($_rate->getPrice(), true, false); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
74
  <?php echo $_excl; ?>
75
  </strong>
76
  </label>
@@ -79,9 +74,9 @@ if (!($_shippingRateGroups = $this->getShippingRates())):
79
  ?>
80
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
81
  <strong>
82
- <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?> <!-- get shipping price excluding tax -->
83
- <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?> <!-- get shipping price with tax -->
84
- <?php echo $_excl; ?>
85
  <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> <!-- display prices -->
86
  (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
87
  <?php endif; ?>
@@ -102,11 +97,7 @@ if (!($_shippingRateGroups = $this->getShippingRates())):
102
  <dd><?php echo $this->getCarrierName($code) ?></dd> <!-- getting carrier names -->
103
  <?php
104
  foreach ($_rates as $_rate):
105
- if ($_rate->getCode() === 'smartsendpickup_smartsendpickup') {
106
- $shippingFee = $pickupShippingFee;
107
- } elseif ($_rate->getCode() === 'smartsendswipbox_smartsendswipbox') {
108
- $shippingFee = $swipboxShippingFee;
109
- } elseif ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
110
  $shippingFee = $postdanmarkShippingFee;
111
  } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
112
  $shippingFee = $postenShippingFee;
@@ -130,13 +121,14 @@ if (!($_shippingRateGroups = $this->getShippingRates())):
130
  $shipping_method = $_rate->getCode();
131
  $carrier = explode('_', $shipping_method);
132
  $smartsend_carrier = $carrier['0'];
 
133
 
134
- if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax")) {
135
  ?>
136
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
137
  <strong>
138
- <?php $_excl = Mage::helper('core')->currency($_rate->getPrice(), true, false); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
139
- <?php echo $_excl; ?>
140
  </strong>
141
  </label>
142
  <?php
@@ -158,7 +150,7 @@ if (!($_shippingRateGroups = $this->getShippingRates())):
158
 
159
  <?php
160
  $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code); //get carrier instance
161
- if ($_rate->getCode() != 'smartsendswipbox_smartsendswipbox' && $_rate->getCode() != 'smartsendpostdanmark_smartsendpostdanmark' && $_rate->getCode() != 'smartsendposten_smartsendposten' && $_rate->getCode() != 'smartsendgls_smartsendgls' && $_rate->getCode() != 'smartsendbring_smartsendbring') {
162
 
163
  if ($carrier->getFormBlock()) {
164
  $block = $this->getLayout()->createBlock($carrier->getFormBlock());
22
  * @author Anders Bilfeldt
23
  * @url www.smartsend.dk
24
  */
 
25
  $bringShippingFee = Mage::getSingleton('logistics/carrier_bring')->getBringShippingFee(); //bring shipping fees
 
26
  $glsShippingFee = Mage::getSingleton('logistics/carrier_gls')->getGlsShippingFee(); //gls shipping fees
27
  $postdanmarkShippingFee = Mage::getSingleton('logistics/carrier_postdanmark')->getPostdanmarkShippingFee(); //postdanmark shipping fees
28
  $postenShippingFee = Mage::getSingleton('logistics/carrier_posten')->getPostenShippingFee(); //posten shipping fees
36
  <dd><?php echo $this->getCarrierName($code) ?></dd> <!-- shipping carrier name -->
37
  <?php
38
  foreach ($_rates as $_rate):
39
+ if ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
 
 
 
 
40
  $shippingFee = $postdanmarkShippingFee;
41
  } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
42
  $shippingFee = $postenShippingFee;
59
  $shipping_method = $_rate->getCode();
60
  $carrier = explode('_', $shipping_method);
61
  $smartsend_carrier = $carrier['0'];
62
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
63
 
64
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax") && $excludedMethod) {
65
  ?>
66
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
67
  <strong>
68
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(),0); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
69
  <?php echo $_excl; ?>
70
  </strong>
71
  </label>
74
  ?>
75
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
76
  <strong>
77
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?> <!-- get shipping price excluding tax -->
78
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?> <!-- get shipping price with tax -->
79
+ <?php echo $_excl; ?>
80
  <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?> <!-- display prices -->
81
  (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
82
  <?php endif; ?>
97
  <dd><?php echo $this->getCarrierName($code) ?></dd> <!-- getting carrier names -->
98
  <?php
99
  foreach ($_rates as $_rate):
100
+ if ($_rate->getCode() === 'smartsendpostdanmark_smartsendpostdanmark') {
 
 
 
 
101
  $shippingFee = $postdanmarkShippingFee;
102
  } elseif ($_rate->getCode() === 'smartsendposten_smartsendposten') {
103
  $shippingFee = $postenShippingFee;
121
  $shipping_method = $_rate->getCode();
122
  $carrier = explode('_', $shipping_method);
123
  $smartsend_carrier = $carrier['0'];
124
+ $excludedMethod = Mage::getModel('logistics/shippingMethods')->excludedTax($shipping_method);
125
 
126
+ if (substr($shipping_method, 0, strlen('smartsend')) === 'smartsend' && Mage::getStoreConfig("carriers/" . $smartsend_carrier . "/excludetax") && $excludedMethod) {
127
  ?>
128
  <label for="s_method_<?php echo $_rate->getCode() ?>"><?php echo $_rate->getMethodTitle() ?> <!-- get method title and the code -->
129
  <strong>
130
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(),0); ?> <!-- get shipping price excluding tax if shipping method does not contains tax -->
131
+ <?php echo $_excl; ?>
132
  </strong>
133
  </label>
134
  <?php
150
 
151
  <?php
152
  $carrier = Mage::getModel('shipping/config')->getCarrierInstance($code); //get carrier instance
153
+ if ( $_rate->getCode() != 'smartsendpostdanmark_smartsendpostdanmark' && $_rate->getCode() != 'smartsendposten_smartsendposten' && $_rate->getCode() != 'smartsendgls_smartsendgls' && $_rate->getCode() != 'smartsendbring_smartsendbring') {
154
 
155
  if ($carrier->getFormBlock()) {
156
  $block = $this->getLayout()->createBlock($carrier->getFormBlock());
app/design/frontend/base/default/template/logistics/pickup.phtml CHANGED
@@ -22,14 +22,13 @@
22
  * @author Anders Bilfeldt
23
  * @url www.smartsend.dk
24
  */
25
- $_rate = $this->getRate(); //shipping method rate
26
- $carrier = explode('_', $_rate->getCode()); //shipping method carrier
27
- $method = $_rate->getMethod(); //shipping method
28
- if ($method == 'pickup' || $carrier[1] == 'smartsendpickup') { //if shipping method is delivery ponint or is pickup then the pickup points will show
29
- $_code = $this->getMethodCode(); //shipping method code
30
- $carrier = $this->getMethodInstance();
31
- $pickupData = $this->getQuote()->getPickupData(); //shipping method pickup
32
- $result = $this->getPickupData(); //shipping method pickup data
33
 
34
  if (!isset($pickupData['store'])) {
35
  $pickupData['store'] = -1;
@@ -43,14 +42,14 @@ if ($method == 'pickup' || $carrier[1] == 'smartsendpickup') { //if shipping me
43
  <?php
44
  if (count($result) <= 0 || $result == FALSE) { //if no pickup data available
45
  ?>
46
- <span id="no_record_<?php echo $_rate->getCode() ?>"><?php echo $this->__('Delivered to closest pickup point'); ?></span>
47
  <!-- <script type="text/javascript">
48
  jQuery(document).ready(function() {
49
- var rm = jQuery("#no_record_<?php //echo $_rate->getCode() ?>").parent('li').parent('ul').parent('li').parent('ul').parent('dd');
50
  jQuery(rm).prev('dt').remove();
51
  jQuery(rm).remove();
52
  /* hack for onepagecheckout */
53
- var op = jQuery("#shipping_form_<?php //echo $_rate->getCode() ?>").parent("dt");
54
  jQuery(op).prev("dd").remove();
55
  jQuery(op).remove();
56
  /* hack for onepagecheckout */
@@ -59,10 +58,10 @@ if ($method == 'pickup' || $carrier[1] == 'smartsendpickup') { //if shipping me
59
  <?php
60
  } else { //displaying pickup data
61
  ?>
62
- <label for="<?php echo $_code ?>_store" class="required"><em>*</em><?php echo $this->__('Choose Store Location:') ?></label>
63
  <span class="input-box">
64
  <select class="required-entry" name="shipping_pickup[store][<?php echo $_rate->getCode() ?>]"> <!-- table rate shipping code -->
65
- <option value=''><?php echo $this->__('Select Store..'); ?></option>
66
  <?php
67
  foreach ($result as $key => $value) {
68
  $s = '';
@@ -84,3 +83,44 @@ if ($method == 'pickup' || $carrier[1] == 'smartsendpickup') { //if shipping me
84
  </li>
85
  </ul>
86
  <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  * @author Anders Bilfeldt
23
  * @url www.smartsend.dk
24
  */
25
+ $_rate = $this->getRate(); //shipping method rate
26
+ $method = $_rate->getMethod(); //shipping method
27
+ if ($method == 'pickup') { //if shipping method is pickup then the pickup points will show
28
+ $_code = $this->getMethodCode(); //shipping method code
29
+ $carrier = $this->getMethodInstance();
30
+ $pickupData = $this->getQuote()->getPickupData(); //shipping method pickup
31
+ $result = $this->getPickupData(); //shipping method pickup data
 
32
 
33
  if (!isset($pickupData['store'])) {
34
  $pickupData['store'] = -1;
42
  <?php
43
  if (count($result) <= 0 || $result == FALSE) { //if no pickup data available
44
  ?>
45
+ <span id="no_record_<?php echo $_rate->getCode() ?>"><?php echo $this->__('Shipping to closest pick-up point'); ?></span>
46
  <!-- <script type="text/javascript">
47
  jQuery(document).ready(function() {
48
+ var rm = jQuery("#no_record_<?php //echo $_rate->getCode() ?>").parent('li').parent('ul').parent('li').parent('ul').parent('dd');
49
  jQuery(rm).prev('dt').remove();
50
  jQuery(rm).remove();
51
  /* hack for onepagecheckout */
52
+ var op = jQuery("#shipping_form_<?php //echo $_rate->getCode() ?>").parent("dt");
53
  jQuery(op).prev("dd").remove();
54
  jQuery(op).remove();
55
  /* hack for onepagecheckout */
58
  <?php
59
  } else { //displaying pickup data
60
  ?>
61
+ <label for="<?php echo $_code ?>_store" class="required"><em>*</em><?php echo $this->__('Select a pick-up point').':'; ?></label>
62
  <span class="input-box">
63
  <select class="required-entry" name="shipping_pickup[store][<?php echo $_rate->getCode() ?>]"> <!-- table rate shipping code -->
64
+ <option value=''><?php echo $this->__('Select a pick-up point'); ?></option>
65
  <?php
66
  foreach ($result as $key => $value) {
67
  $s = '';
83
  </li>
84
  </ul>
85
  <?php } ?>
86
+
87
+
88
+
89
+ <?php
90
+ $carrier = explode('_', $_rate->getCode()); //shipping method carrier
91
+
92
+ if ($carrier[0] == 'smartsendpostdanmark' || $carrier[0] == 'smartsendposten') { //if shipping method is smartsendposten or smartsendpostdanmark, then the Flex points will show
93
+ $_code = $this->getMethodCode(); //shipping method code
94
+
95
+ $carrier = $_rate->getCode();
96
+ $result = $this->getFlexData($carrier); //shipping method flex data
97
+ ?>
98
+ <ul class="form-list" id="shipping_form_<?php echo $_rate->getCode() ?>" style="display:none;">
99
+ <li>
100
+ <?php
101
+ if (count($result) > 0 || $result == true) {
102
+ //displaying flex data
103
+ ?>
104
+ <label for="<?php echo $_code ?>_store" class="required"><em>*</em><?php echo $this->__('Select a flexdelivery option').':'; ?></label>
105
+ <span class="input-box">
106
+ <select class="required-entry" name="shipping_flex[store][<?php echo $_rate->getCode() ?>]"> <!-- table rate shipping code -->
107
+ <option value=''><?php echo $this->__('Select a flexdelivery option'); ?></option>
108
+ <?php
109
+ foreach ($result as $key => $value) {
110
+ $s = '';
111
+ if ($value == 'zip_code') {
112
+ $s .= $value . " ";
113
+ } else {
114
+ $s .= $value . ", ";
115
+ }
116
+ ?>
117
+ <option value='<?php echo $key ?>'><?php echo substr($s, 0, -2) ?></option>
118
+ <?php
119
+ }
120
+ ?>
121
+ </select>
122
+ </span>
123
+ <?php } ?>
124
+ </li>
125
+ </ul>
126
+ <?php } ?>
app/locale/da_DK/Smartsend_Logistics.csv CHANGED
@@ -1,95 +1,150 @@
1
- Username, Brugernavn
2
- Licencekey, Licenskode
3
- Combine PDF files?, Kombiner PDF filer?
4
- Seperate pdf's, Opdel PDF'er
5
- Combine pdf's into one file, Saml PDF filer til én
6
- Method, Metode
7
- Min Price,Min pris
8
- Max Price,Maks pris
9
- Min Weight,Min vægt
10
- Max Weight,Maks vægt
11
- Shipping Fee,Fragt pris
12
- Countries, Lande
13
- Add Rate,Tilføj Rate
14
- Enabled,Aktiveret
15
- Disabled,Deaktiveret
16
- Delete,Slet
17
- the order confirmation email was sent,ordrebekræftelses e-mail blev sendt
18
- the order confirmation email was not sent,ordrebekræftelses e-mail blev ikke sendt
19
- Order Date,Ordre dato
20
- Order Status,Ordrestatus
21
- Purchased From,Indkøbt fra
22
- Link to the New Order,Link til den nye orden
23
- Link to the Previous Order,Link til den tidligere ordre
24
- Placed from IP,Placeret fra IP
25
- Account Information,Kontooplysninger
26
- Customer Name,Kundenavn
27
- Email,Email
28
- Email notification,Email notifikation
29
- SMS notification,SMS notifikation
30
- Pre-notification,Pre-notifikation
31
- Return,Retur
32
- Return methode,Retur metode
33
- Which carrier should handle return packages?,Hvilket fragtfirma skal håndtere returpakker?
34
- Customer Group,Customer Group
35
- Billing Address,Faktureringsadresse
36
- Shipping Address,Leveringsadresse
37
- Smart Send Pickup Address,Smart Send Afhentningsadresse
38
- Pickup Point Id: ,Afhentnings ID:
39
- Shipping Method: ,Forsendelses Metode:
40
- Record not found,Optag ikke fundet
41
- Choose Store Location:,Vælg afhentningssted:
42
- Select Store..,Vælg afhentningssted..
43
- "Sorry, no quotes are available for this order at this time.","Beklager, ingen fragtpris er til rådighed for denne ordre på nuværende tidspunkt."
44
- Incl. Tax,Inkl. Moms
45
- Title,Titel
46
- Carrier Title,Titel på fragtfirma
47
- Method Name,Metode navn
48
- Consumer ID,Forbruger ID
49
- Price,Pris
50
- Cheapest or most expensive?,Billigste eller dyreste?
51
- Cheapest, Billigste
52
- Most Expensive, Dyreste
53
- PDF file, PDF fil
54
- Yes, Ja
55
- No, Nej
56
- Displayed Error Message,Vist fejlmeddelelse
57
- Timeout,Timeout
58
- Number Of Results,Antal resultater
59
- Dropdown format,Dropdown format
60
- "This shipping method is currently unavailable.####### If you would like to ship using this shipping method, please contact us.","Denne forsendelsesmetode er ikke tilgængelig i øjeblikket . ####### Hvis du ønsker at sende ved hjælp af denne forsendelsesmetode , så kontakt os."
61
- Closest Pickup,Nærmeste afhentningssted
62
- Small,Lille
63
- Medium,Medium
64
- Large,Stor
65
- Delivered to closest pickup point, Leveres til nærmeste afhentningssted
66
- Username and licencekey must be entered in settings, Brugernavn og licenskode skal indtastes i indstillingerne før brug
67
- Unknown carrier, Ukendt fragtmetode
68
- No orders selected, Ingen ordre valgt
69
- Method not yet implemented, Metoden er ikke implementeret endnu
70
- Trying to send empty order array, Prøver at sende et tomt order array
71
- An error occurred while sending order, En fejl opstod mens ordren blev sendt
72
- Response, Svar
73
- Unknown status, Ukendt status
74
- Unknown content type, Ukendt indholds format
75
- Had shipments, Havde forsendelser
76
- Unknown pickup method, Ukendt pickup metode
77
- Unable to fetch pickup data, Kunne ikke læse data om pickup
78
- Not a pickup shipping method, Ikke en pickup forsendelsesmetode
79
- Unsupported carrier, Ikke understøttet fragtfirma
80
- Unsupported shipping method, Ikke understøttet forsendelses metode
81
- Unknown carrier, Ukendt fragtfirma
82
- Unknown carrier when adding services, Ukendt fragtfirma ved tilføjelse af service
83
- Generate label, Lav label
84
- Generate return label, Lav retur label,
85
- How the dropdown is formatted, Formatet af dropdown listen
86
- Carrier is excluded from TAX even though there is a Shipping Tax defined, Der udregnes ikke moms af fragten selvom der er defineret en moms for fragt
87
- Order has no shipments without trace code and cannot be shipped, Ordren har ikke en forsendelse uden track&trace kode
88
- Failed to insert tracecode, Kunne ikke indsætte track and trace kode
89
- Unable to determine carrier for pickup shipping method, Kunne ikke bestemme fragtfirma for pickup forsendelsesmetode
90
- No items that could be shipped, Ingen produkter kunne sendes
91
- Shipping to closest pickup point, Sendes til nærmeste afhentningssted
92
- "Either just an id or a semicolon separated list of 'country,id' (* is all countries). Eg: SE,123;NO,321;*,44", "Enten blot et id eller en semikolon separeret liste af 'land,id' (* er all lande). Fx: SE,123;NO,321;*,44"
93
- No parcels without trace code, Ingen forsendelser uden tracking nummer
94
- No unshipped items, Ingen usendte varer
95
- No parcels to ship, Ingen varer kan sendes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Username","Brugernavn"
2
+ "License key","Licensnøgle"
3
+ "Validation","Validering"
4
+ "Valid user information","Gyldig bruger"
5
+ "Please enter valid user information","Indtast venligt gyldig bruger-information"
6
+ "Save settings to validate","Gem indstillingerne for at validere"
7
+ "Merge labels from multiple orders","Sammensæt PDF-labels fra flere ordre"
8
+ "Separate PDF files","Seperate PDF-filer"
9
+ "Merged PDF file","Sammensat PDF-fil"
10
+ "Generate PDF file containing all labels or create a single PDF file for each order","Generer PDF indeholdende alle fragtlabels eller generer én PDF-fil for hver ordre"
11
+ "Dropdown format","Dropdown-format"
12
+ "How the pickup points are listed during checkout","Hvordan listen af afhentningssteder vises i checkout"
13
+ "Set order status after label print","Ændre ordre-status efter label-generering"
14
+ "Company","Firma"
15
+ "City","By"
16
+ "Street","Adresse"
17
+ "Zipcode","Postnummer"
18
+ "Don't change order status","Ændre ikke ordre-status"
19
+ "Send shipment email","Send forsendelses-email"
20
+ "Send system shipment email to the customer after generating label","Afsend forsendelses-email fra systemet efter genering af label"
21
+ "Enabled","Aktiveret"
22
+ "Carrier title","Titel fragtfirma"
23
+ "Carrier title shown in frontend at customer checkout","Titel på fragtfirma som vises til kunden under checkout"
24
+ "Table rate","Forsendelsestabel"
25
+ "Handle multiple rates for same shipping method","Håndtering af fragtlinie-doubletter"
26
+ "Shipping method","Fragtmetode"
27
+ "Min. price","Min. pris"
28
+ "Max. price","Maks pris"
29
+ "Min. weight","Min. vægt"
30
+ "Max. weight","Maks vægt"
31
+ "Shipping fee","Fragtpris"
32
+ "Countries","Lande"
33
+ "Title","Titel"
34
+ "Add rate","Tilføj rate"
35
+ "Countries can be entered as a comma-separated list in ISO 3166-1 alpha-2 format. Use * for all valid countries.","Lande kan indtastes som en komma-separeret liste i ISO-3166-1 alpha-2 format. Brug * for alle gyldige lande."
36
+ "Cheapest","Billigste"
37
+ "Most expensive","Dyreste"
38
+ "If multiple rates are valid for the same method, use either the cheapest or the most expensive rate","Hvis flere fragtlinier er gyldig for samme fragtmetode, benyt da enten den billigste eller dyreste fragtpris"
39
+ "Exclude from TAX","Momsfritag"
40
+ "Excluded private shipping methods to Denmark from TAX","Momsfritag forsendelsesmetoder til privatpersoner i Danmark"
41
+ "Services","Tillægsydelser"
42
+ "Email notification", "Email-notifikation"
43
+ "Send an email to the customer with info about delivery","Send en email til kunden med information om forsendelsen"
44
+ "SMS notification","SMS-notifikation"
45
+ "Send a SMS to the customer with info about delivery","Send en SMS til kunden med information om forsendelsen"
46
+ "Pre-notification","Pre-notifikation"
47
+ "Pre-notification receiver","Pre-notifikations modtager"
48
+ "Leave blank if receiver should be the user","Efterlad blank hvis modtageren skal være brugeren"
49
+ "Pre-notification sender","Pre-notifikations afsender"
50
+ "Pre-notification message","Pre-notifikations besked"
51
+ "Send and email with info about delivery at soon as a label is created","Send en email med informationer om forsendelsen så snart en pakkelabel bliver lavet"
52
+ "Label format","Labelformat"
53
+ "Pacsoft link","Pacsoft-link"
54
+ "PDF file","PDF-fil"
55
+ "Pacsoft QuickID","Pacsoft QuickID"
56
+ "ID of the Pacsoft sender appearing on the label","ID på den Pacsoft afsender der er synlig på pakkelabel"
57
+ "Waybill ID","Waybill-ID"
58
+ "Either just an id or a semicolon separated list of 'country,id' (* is all countries). Eg: SE,123;NO,321;*,44", "Indtast enten et ID eller en semikolon-separeret liste af typen 'land,id' (* angiver alle lande). Fx. SE,123;NO,321;*,44"
59
+ "Flex delivery","Flexlevering"
60
+ "Enable flex delivery for the selected shipping methods","Aktiver flexlevering for de valgte fragtmetoder"
61
+ "Return","Returfragt"
62
+ "Return method","Retur-fragtfirma"
63
+ "Determines what carrier handles return packages","Angivet hvilket fragtfirma der håndterer retur-pakker"
64
+ "Same carrier","Samme fragtfirma"
65
+ "Delete","Slet"
66
+ "Yes","Ja"
67
+ "No","Nej"
68
+ "Include order comment on label","Påsæt ordrekommentar pakkelabel"
69
+ "<div class=""smartsend""><p style=""background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px"">If you don't have a Smart Send subscription please create one at our website: <a href=""http://www.smartsend.dk/signup"" target=""_blank"">Smart Send</a></p></div>","<div class=""smartsend""><p style=""background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px"">Hvis du ikke har et abonnement hos Smart Send, opret da et på vores hjemmeside: <a href=""http://www.smartsend.dk/signup"" target=""_blank"">Smart Send</a></p></div>"
70
+ "<div class=""smartsend""><p style=""background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px"">This shipping method may only be used if a valid Smart Send license is purchased. Please see <a href=""http://www.smartsend.dk"" target=""_blank"">Smart Send</a> for further information.</p></div>","<div class=""smartsend""><p style=""background: #FFFFFF;border: 1px solid orange;font-weight: bold; padding: 20px"">Denne forsendelsesmetode må kun benyttes med en gyldig Smart Send licens. Se venligst <a href=""http://www.smartsend.dk"" target=""_blank"">Smart Send</a> for nærmere information.</p></div>"
71
+ "Input the order price","Indtast ordrens samlede pris"
72
+ "Input the shipping fee","Indtast fragtprisen"
73
+ "including tax","inklusiv moms"
74
+ "excluding tax","eksklusiv moms"
75
+
76
+ "Pickuppoint","Afhentningssted"
77
+ "Private to home","Privatpakke med omdeling"
78
+ "Commercial","Erhvervspakke"
79
+ "Private","Privatpakke uden omdeling"
80
+ "DPD Classic","DPD Classic"
81
+ "DPD Guarantee","DPD Garantipakke"
82
+ "Value mail","Varebrev"
83
+ "Value mail first class","Varebrev første klasse"
84
+ "Value mail economy","VarReturn methodebrev økonomi"
85
+ "Maxi mail","Stort brev"
86
+ "Commercial Bulksplit","Erhverv Bulksplit"
87
+ "Private Bulksplit","Privatpakke uden omdeling Bulksplit"
88
+ "Private to home Bulksplit","Privatpakke med omdeling Bulksplit"
89
+ "Private collective","Privat samsending"
90
+ "Private priority","Privatpakke prioritet"
91
+ "Private economy","Privatpakke økonomi"
92
+ "Service Logistics","Service Logistik"
93
+ "Express","Express"
94
+ "Mini parcel","Minipakke"
95
+ "Commercial priority","Erhvervspakke prioritet"
96
+
97
+ "Generate label","Opret label"
98
+ "Generate return label","Opret retur label"
99
+ "Generate normal and return label","Opret almindelig og retur label"
100
+
101
+ "Order","Order"
102
+ "Download combined PDF label","Hent samlet PDF-label"
103
+ "Link to print labels","Link til print af labels"
104
+ "Download PDF label","Hent PDF-label"
105
+ "Link to print label","Link til print af label"
106
+ "Label generated with Smart Send Logistics","Label genereret via Smart Send Logistics"
107
+ "Tracecode","Trackingnummer"
108
+ "Unknown API method","Ukendt API-metode"
109
+ "Trying to send empty order array","Forsøger at sende et tomt order array"
110
+ "Error from server","Serverfejl"
111
+ "No orders returned from server","Ingen ordre returneret fra server"
112
+ "No parcels returned from server","Ingen forsendelser returneret fra serveren"
113
+ "Unknown order was returned from server","Ukendt order returneret fra server"
114
+ "No PDF file or link returned from server","Ingen PDF-fil eller link til udskrift tilgængeligt"
115
+ "Failed to insert tracecode. No tracecode available.","Fejl under indsættese af trackingnummer. Trackingnummer er ikke tilgængeligt."
116
+ "Failed to change order status. Status unchanged.","Fejl ved opdatering af ordrestatus. Ordrestatus er ikke opdateret."
117
+ "Failed to send shipment mail. No mail sent.","Fejl ved udsendelse af forsendelsemail. Forsendelsesmail blev ikke udsendt."
118
+ "Failed to add order comment","Fejl ved opdatering af ordrehistorikken"
119
+ "Please enter a username in the modules settings","Indtast venligst et brugernavn i modulets indstillinger"
120
+ "Please enter a license key in the modules settings","Indtast venligst en licenskode i modulets indstillinger"
121
+
122
+ "Unable to determine the shipping method used for return parcels","Kunne ikke bestemme forsendelsesmetoden til returpakker"
123
+ "Unable to determine the shipping carrier","Kunne ikke bestemme fragtfirmaet"
124
+ "Unable to determine the shipping method","Kunne ikke bestemme fragtmetoden"
125
+ "Unable to determine carrier for pickup shipping method","Kunne ikke bestemme fragtfirma for fragtmetode til afhentningssted"
126
+ "Unsupported carrier","Ikke supporteret fragtmetode"
127
+ "Unable to determine shipping method for carrier","Kunne ikke bestemme fragtmetoden for fragtfirmaet"
128
+ "Unable to determine shipping carrier","Kunne ikke bestemme fragtfirmaet"
129
+ "Unknown shipping carrier","Ukendt fragtmetode"
130
+ "Unable to determine shipping method","Kunne ikke bestemme fragtmetoden"
131
+ "All packages has been shipped. No parcels without trace code exists. Remove existing tracecodes to re-generate labels.","Alle pakker er allerede afsendt. Ingen pakker mangler trackingnummer. Fjern eksisterende trackingnumre for at lave nye labels."
132
+ "No items to ship","Ingen produkter kan afsendes"
133
+ "No parcels to ship","Ingen forsendelser at sende"
134
+ "Trying to access pickup data for an order that is not a pickup point order","Kunne ikke hente data om afhentningssted for en ordre der er sendt med anden metode"
135
+
136
+ "Pickuppoint","Afhentningssted"
137
+ "ID","ID"
138
+ "Shipping to closest pick-up point","Sendes til nærmeste afhentningssted"
139
+ "Select a pick-up point","Vælg et afhentningssted"
140
+ "Not a pickup point","Ikke et afhentningssted"
141
+ "Select a flexdelivery option","Vælg en flexleverings mulighed"
142
+ "Flexdelivery","Flexlevering"
143
+ "Flexdelivery note","Flexleveringsnote"
144
+ "Flexdelivery instruction not available","Flexleveringsinstruktion ikke valgt"
145
+ "By the frontdoor","Foran hoveddøren"
146
+ "By the carport","Ved carporten eller garagen"
147
+ "By the back dor","Ved bagdøren"
148
+ "I have Modtagerflex","Jeg har Modtagerflex"
149
+ "Can be left unattended","Må stilles et andet sted"
150
+ "Debug","Fejlfinding"
app/locale/da_DK/template/email/smartsend_new_shipment_email.html ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject {{var store.getFrontendName()}}: Shipment #{{var shipment.increment_id}} for Order #{{var order.increment_id}} @-->
2
+ <!--@vars
3
+ {"store url=\"\"":"Store Url",
4
+ "var logo_url":"Email Logo Image Url",
5
+ "var logo_alt":"Email Logo Image Alt",
6
+ "var message":"Wishlist Message",
7
+ "var items":"Wishlist Items"}
8
+ @-->
9
+ <!--@styles
10
+ body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
11
+ @-->
12
+
13
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
14
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
15
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
16
+ <tr>
17
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
18
+ <!-- [ header starts here] -->
19
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
20
+ <tr>
21
+ <td valign="top"><a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
22
+ </tr>
23
+ <!-- [ middle starts here] -->
24
+ <tr>
25
+ <td valign="top">
26
+ <h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;"">Ordre #{{var order.increment_id}} er nu afsendt</h1>
27
+ <p style="font-size:12px; line-height:16px; margin:0;">
28
+ Vi er glade for at kunne oplyse dig at din ordre nu er sendt.
29
+ </p>
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td>
34
+ {{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}
35
+ {{block type='core/template' area='frontend' template='logistics/email/order/shipment/track.phtml' shipment=$shipment order=$order}}
36
+ </td>
37
+ </tr>
38
+ <tr>
39
+ <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Tak fordi du handlede hos <strong>{{var store.getFrontendName()}}</strong></p></center></td>
40
+ </tr>
41
+ </table>
42
+ </td>
43
+ </tr>
44
+ </table>
45
+ </div>
46
+ </body>
js/logistics/jquery-1.10.2.min.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /*! jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
2
+ //@ sourceMappingURL=jquery-1.10.2.min.map
3
+ */
4
+ (function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.2",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=st(),k=st(),E=st(),S=!1,A=function(e,t){return e===t?(S=!0,0):0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=mt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+yt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return kt(e.replace(z,"$1"),t,n,i)}function st(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function lt(e){return e[b]=!0,e}function ut(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function ct(e,t){var n=e.split("|"),r=e.length;while(r--)o.attrHandle[n[r]]=t}function pt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function ft(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function dt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function ht(e){return lt(function(t){return t=+t,lt(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.defaultView;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.attachEvent&&i!==i.top&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ut(function(e){return e.className="i",!e.getAttribute("className")}),r.getElementsByTagName=ut(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ut(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ut(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=K.test(n.querySelectorAll))&&(ut(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ut(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=K.test(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ut(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=K.test(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return pt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?pt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:lt,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=mt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?lt(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:lt(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?lt(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:lt(function(e){return function(t){return at(e,t).length>0}}),contains:lt(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:lt(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:ht(function(){return[0]}),last:ht(function(e,t){return[t-1]}),eq:ht(function(e,t,n){return[0>n?n+t:n]}),even:ht(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:ht(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:ht(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:ht(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}},o.pseudos.nth=o.pseudos.eq;for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=ft(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=dt(n);function gt(){}gt.prototype=o.filters=o.pseudos,o.setFilters=new gt;function mt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function yt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function vt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function bt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function xt(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function wt(e,t,n,r,i,o){return r&&!r[b]&&(r=wt(r)),i&&!i[b]&&(i=wt(i,o)),lt(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||Nt(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:xt(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=xt(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=xt(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function Tt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=vt(function(e){return e===t},s,!0),p=vt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[vt(bt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return wt(l>1&&bt(f),l>1&&yt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&Tt(e.slice(l,r)),i>r&&Tt(e=e.slice(r)),i>r&&yt(e))}f.push(n)}return bt(f)}function Ct(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=xt(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?lt(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=mt(e)),n=t.length;while(n--)o=Tt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Ct(i,r))}return o};function Nt(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function kt(e,t,n,i){var a,s,u,c,p,f=mt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&yt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}r.sortStable=b.split("").sort(A).join("")===b,r.detectDuplicates=S,p(),r.sortDetached=ut(function(e){return 1&e.compareDocumentPosition(f.createElement("div"))}),ut(function(e){return e.innerHTML="<a href='#'></a>","#"===e.firstChild.getAttribute("href")})||ct("type|href|height|width",function(e,n,r){return r?t:e.getAttribute(n,"type"===n.toLowerCase()?1:2)}),r.attributes&&ut(function(e){return e.innerHTML="<input/>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||ct("value",function(e,n,r){return r||"input"!==e.nodeName.toLowerCase()?t:e.defaultValue}),ut(function(e){return null==e.getAttribute("disabled")})||ct(B,function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&i.specified?i.value:e[n]===!0?n.toLowerCase():null}),x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return!l||i&&!u||(t=t||[],t=[e,t.slice?t.slice():t],n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML=" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t
5
+ }({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var t,r=0,o=x(this),a=e.match(T)||[];while(t=a[r++])o.hasClass(t)?o.removeClass(t):o.addClass(t)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);
6
+ u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){nn(this)?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);
package.xml CHANGED
@@ -1,23 +1,72 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Smartsend_Logistics</name>
4
- <version>7.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Shipping methods for Post Danmark, GLS, Bring, SwipBox and Posten.</summary>
10
- <description>Shipping methods for Post Danmark, GLS, Bring, SwipBox and Posten.&#xD;
11
- Description :: Shipping methods for Post Danmark, GLS, Bring, SwipBox and Posten.&#xD;
12
  &#xD;
13
- This modules enables table rate shipping methods for all the listed carriers. The module includes pickup points where the customer are presented a dropdown with nearby pickup locations based on shipping address.&#xD;
14
  &#xD;
15
- The module can also create labels for the shipments.</description>
16
- <notes>Lates stable release</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  <authors><author><name>Smart Send ApS</name><user>SmartSendDK</user><email>anders@smartsend.dk</email></author></authors>
18
- <date>2015-08-04</date>
19
- <time>18:31:40</time>
20
- <contents><target name="magecommunity"><dir name="Smartsend"><dir name="Logistics"><dir name="Block"><dir name="Adminhtml"><file name="PickupShipping.php" hash="caca818fedd479b76a405b8238b2d002"/><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Info.php" hash="1e5269928626d3817b62cd4f382ac47a"/></dir></dir></dir></dir><file name="Shipping.php" hash="1afb1a9495366a2583f50dc7233a22df"/><dir name="System"><dir name="Config"><file name="Excludetax.php" hash="cf6ee2a8f49bca55781ec9f9372b065b"/></dir></dir></dir><file name="Bring.php" hash="a42e6e7c448902d7644012d409f84260"/><file name="Gls.php" hash="711d248f9e4575a91b1a86c7d8127681"/><file name="Pickup.php" hash="8962c1e695c16390a80080d38abf5322"/><file name="Postdanmark.php" hash="a24825141eeb2c9cbe07fbaf1caa6bba"/><file name="Posten.php" hash="6ca7e2336c659f032fde01a5a90152ad"/><file name="Swipbox.php" hash="4fe9c67f82e031c69c52e39e07bac148"/></dir><dir name="Helper"><file name="Data.php" hash="2a7ebc0b1cc73dbfa20179294a4db144"/></dir><dir name="Model"><file name="Bring.php" hash="d085d49eb215752102ab74926a0d5c79"/><dir name="Carrier"><file name="Bring.php" hash="62840c94debe7792396c5fcbab1db9ff"/><file name="Gls.php" hash="ff0e230e167337a82285c846cdc79caf"/><file name="Pickup.php" hash="8f652de7f2bf11893a2f02649f107b38"/><file name="Postdanmark.php" hash="f5adfe23cc73e7239372f69d3f59421a"/><file name="Posten.php" hash="14657ff2445cfa6cf60bde02e6c0bdb9"/><file name="Swipbox.php" hash="2fc3cd65e7e334ed61eac3ac03e15e7b"/></dir><file name="Gls.php" hash="a40e74472e611bbd955c752f97d9769c"/><dir name="Mysql4"><dir name="Bring"><file name="Collection.php" hash="fbab7b8475845cd8c724f81f8da318cd"/></dir><file name="Bring.php" hash="2761ca69301f65d7c50dab039f832489"/><dir name="Gls"><file name="Collection.php" hash="ff85ba1838f20c88909cac240d484e90"/></dir><file name="Gls.php" hash="c6c4d58ebf7bde0fd13d010efc34771a"/><dir name="Pickup"><file name="Collection.php" hash="51b13cbc4eba93b1a4f97e15c403738b"/></dir><file name="Pickup.php" hash="a227429c1b4e405e96b42ca48a8f83fd"/><dir name="Postdanmark"><file name="Collection.php" hash="340ad97e9348c794b6c5af36c063c716"/></dir><file name="Postdanmark.php" hash="0eb4991832f7a7915e4b683aec0dd5bf"/><dir name="Posten"><file name="Collection.php" hash="0ce6dbb1ce831f71c53d924fb7bab360"/></dir><file name="Posten.php" hash="82adc2661f43b5fb1cd7e1cd8a77c367"/><dir name="Swipbox"><file name="Collection.php" hash="75b0c0ea34408963902fe138fa5365ca"/></dir><file name="Swipbox.php" hash="f102c53886fc157b3a82d8640738c396"/></dir><file name="Observer.php" hash="e323d6eda0f7b9462923f4f6d345c6a3"/><file name="Order.php" hash="a54ca26d6df8c2014679788ad3f4e80b"/><file name="Pickup.php" hash="accf417ad67bec5432ba7ee328776c64"/><file name="Postdanmark.php" hash="049fd41acaeb28e3acbe6741fd2c3f1f"/><file name="Posten.php" hash="054949a6cd0f076f78587668e07cd723"/><dir name="Rewrite"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Shipping.php" hash="8cbeeb87faa1894729bda69eb84d2a6c"/><file name="Tax.php" hash="ffe46d9acdf5c6675deaa79db7b9f3bd"/></dir></dir></dir></dir><file name="ShippingMethods.php" hash="e5a27d0288de87bcdc9843055f83e651"/><file name="Status.php" hash="1e747a56f6fa5bfdff090d503178363a"/><file name="Swipbox.php" hash="095ca2a9420043b648831eadf765f8aa"/><dir name="System"><file name="CombinePdf.php" hash="5943d5b5f5091c0cca79366255c01d0e"/><file name="Listformat.php" hash="38cbc44456711d3dd275ba53609fb6a1"/><file name="OrderOption.php" hash="1261cd9302ef30ae3a1efc785990e3b0"/><file name="Pacsoftformat.php" hash="9b188ba263db84ba53065b934f1e7b58"/><dir name="Pickup"><file name="Listformat.php" hash="251eac7e1d2768787bc67e9ca038ce0d"/></dir><file name="PickupMethods.php" hash="66bf089dd5dd04b5e32ae5b9308a4d26"/><file name="Return.php" hash="357ae4d4cd7214dfc6f2be19b4533c16"/><file name="Size.php" hash="72f40a99360d5adb90ad9d5558f43571"/></dir></dir><dir name="controllers"><file name="LogisticsController.php" hash="6d39e924b192ec1e2d23309aa464467d"/></dir><dir name="etc"><file name="config.xml" hash="a649a03271e167e0425a8960fe92ef38"/><file name="system.xml" hash="a5acfd1f538f3ab5ff8cf6f0a5b97f40"/></dir><dir name="sql"><dir name="logistics_setup"><file name="mysql4-install-7.0.1.php" hash="19b72dc9f075dc0920d6f74840b637ce"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="logistics.xml" hash="b29335c04ab5dd624da41604f4c06b20"/></dir><dir name="template"><dir name="logistics"><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="73eff637d40c99cb6400f4e64ef2926e"/></dir><file name="info.phtml" hash="8ee1a2c05e4b19e5f9a20a5d526455a0"/></dir></dir></dir><dir name="system"><dir name="config"><file name="excludetax.phtml" hash="8e67e3bf0d3817cfc32d718e0435f8e6"/></dir></dir><file name="array_dropdown.phtml" hash="734326ecd1c545c4166c42d4410ab33c"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="logistics.xml" hash="9c56854ed306a7bcd5d8855ecf1b183e"/></dir><dir name="template"><dir name="logistics"><dir name="checkout"><dir name="onepage"><dir name="shipping_method"><file name="available.phtml" hash="512dc29908a55f1bd0d48eed5a3053b2"/></dir></dir></dir><dir name="onestepcheckout"><file name="shipping_method.phtml" hash="f844d1f8fb2d782452edd106420db4c0"/></dir><file name="pickup.phtml" hash="0e045ffdaa3a42c35f5359019f327c8a"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Smartsend_Logistics.xml" hash="f54aeead0ec93bc9e7d5150bac2b6907"/></dir></target><target name="magelocale"><dir name="da_DK"><file name="Smartsend_Logistics.csv" hash="dd4f03fb66555411cbcdb0310ab788a4"/></dir></target><target name="mageweb"><dir name="js"><dir name="logistics"><file name="jquery-1.6.4.min.js" hash="9118381924c51c89d9414a311ec9c97f"/><file name="noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/></dir></dir></target></contents>
21
  <compatible/>
22
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.9</max></package><extension><name>curl</name><min></min><max></max></extension></required></dependencies>
23
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Smartsend_Logistics</name>
4
+ <version>7.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl.html">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Table rate shipping methods with flexible conditions determining the rate and even let the customer chose a pick-up point during checkout. Integrates the shipping methods directly with carrier systems and create PDF labels directly from the backend.</summary>
10
+ <description>The module is a complete user friendly shipping system that allows for easy setup of multiple shipping methods and allows for a direct integration to the carries. Integrate tracking information directly in the system and customer emails.&#xD;
 
11
  &#xD;
12
+ Supported carriers:&#xD;
13
  &#xD;
14
+ * GLS (YourGLS)&#xD;
15
+ * Bring (MyBring)&#xD;
16
+ * Post Danmark (Pacsoft)&#xD;
17
+ * Posten (Pacsoft)&#xD;
18
+ * Post Nord (Pacsoft)&#xD;
19
+ &#xD;
20
+ Supports worldwide shipping from these countries:&#xD;
21
+ &#xD;
22
+ * Denmark&#xD;
23
+ * Sweden&#xD;
24
+ * Finland&#xD;
25
+ * Norway&#xD;
26
+ &#xD;
27
+ = Table rates =&#xD;
28
+ Table rate settings enables multiple shipping methods to be easily configured in one table. Determine the shipping price for each method based on multiple condition.&#xD;
29
+ &#xD;
30
+ Calculate shipping rate based on:&#xD;
31
+ &#xD;
32
+ * Shipping address&#xD;
33
+ * Order weight&#xD;
34
+ * Order subtotal&#xD;
35
+ * Shipping class&#xD;
36
+ &#xD;
37
+ = Services =&#xD;
38
+ Enable services for shipping methods:&#xD;
39
+ &#xD;
40
+ * Customer notification by email&#xD;
41
+ * Customer notification by SMS&#xD;
42
+ * Pickup point (collect the parcel at a shop near the customer)&#xD;
43
+ * Flex delivery (leave parcel at specified location)&#xD;
44
+ * Home delivery&#xD;
45
+ * Handling of special good, eg food&#xD;
46
+ * TAX handling&#xD;
47
+ * Enable free delivery based on condition&#xD;
48
+ &#xD;
49
+ = Pickup point =&#xD;
50
+ Let the customer choose a close by pickup point during checkout. The package will be delivered to that pickup point. The customer can collect the package at selected pickup point at convenience.&#xD;
51
+ &#xD;
52
+ * Nearest pickup points based on customer address&#xD;
53
+ * Automatically updated list&#xD;
54
+ * User friendly dropdown list&#xD;
55
+ * One step/page checkout compatible&#xD;
56
+ &#xD;
57
+ = Shipping labels =&#xD;
58
+ Create shipping labels directly from the backend by a single click. The information is automatically formatted and send to the carrier for processing. A PDF label is immediately shown and ready to print. Tracking information is automatically saved in the system and can be included in customer emails or can be sendt by text message.&#xD;
59
+ &#xD;
60
+ Easily create:&#xD;
61
+ &#xD;
62
+ * Shipping labels as PDF files&#xD;
63
+ * Return shipping labels&#xD;
64
+ * Tracking information</description>
65
+ <notes>Latest stable release</notes>
66
  <authors><author><name>Smart Send ApS</name><user>SmartSendDK</user><email>anders@smartsend.dk</email></author></authors>
67
+ <date>2016-06-12</date>
68
+ <time>16:25:05</time>
69
+ <contents><target name="magecommunity"><dir name="Smartsend"><dir name="Logistics"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Info.php" hash="1e5269928626d3817b62cd4f382ac47a"/></dir></dir></dir></dir><file name="Shipping.php" hash="6713003ed07238480a8c557a6571d4ec"/><dir name="System"><dir name="Config"><file name="Excludetax.php" hash="cf6ee2a8f49bca55781ec9f9372b065b"/></dir></dir></dir><file name="Bring.php" hash="6d47c8c3aa92f25e664a21f27dc02025"/><file name="Gls.php" hash="38024ad65c26293f917add14cb724994"/><file name="Postdanmark.php" hash="398364cad843f3cc65f2a1782f9358ee"/><file name="Posten.php" hash="de7a5d756b77ba1111b47517b6e91909"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="Helper"><file name="Data.php" hash="2a7ebc0b1cc73dbfa20179294a4db144"/></dir><dir name="Model"><dir name="Api"><file name="Pickups.php" hash="1728e9b8d75963ff20000bfc543b1eab"/><file name="Validation.php" hash="1b79d70115a27dc6ea60513a8b63b6e2"/></dir><file name="Bring.php" hash="d085d49eb215752102ab74926a0d5c79"/><dir name="Carrier"><file name="Bring.php" hash="77ed23574ecab8ce681b70464a767836"/><file name="Gls.php" hash="c1ea91a8dfd267f3935dbd758daa6e07"/><file name="Postdanmark.php" hash="001379f18cfa1d56707bc079e62b3d8b"/><file name="Posten.php" hash="e91c9cd9b9dcb83674ff0b5fc93b7f0a"/></dir><file name="Flex.php" hash="387ef50380f86a4f5b81384cfd63e5d7"/><file name="Gls.php" hash="a40e74472e611bbd955c752f97d9769c"/><file name="Label.php" hash="b0e9298b054af05aa993b0d839288cd4"/><file name="Labelmagento.php" hash="e38d8b8e1febb2358b3c0bfe1f744575"/><dir name="Mysql4"><dir name="Bring"><file name="Collection.php" hash="fbab7b8475845cd8c724f81f8da318cd"/></dir><file name="Bring.php" hash="2761ca69301f65d7c50dab039f832489"/><dir name="Flex"><file name="Collection.php" hash="b753243d0e12e93075d85b839bdf0cf3"/></dir><file name="Flex.php" hash="4ac593e8fa8be6a7d7cb26a325c01806"/><dir name="Gls"><file name="Collection.php" hash="ff85ba1838f20c88909cac240d484e90"/></dir><file name="Gls.php" hash="c6c4d58ebf7bde0fd13d010efc34771a"/><dir name="Pickup"><file name="Collection.php" hash="51b13cbc4eba93b1a4f97e15c403738b"/></dir><file name="Pickup.php" hash="a227429c1b4e405e96b42ca48a8f83fd"/><dir name="Postdanmark"><file name="Collection.php" hash="340ad97e9348c794b6c5af36c063c716"/></dir><file name="Postdanmark.php" hash="0eb4991832f7a7915e4b683aec0dd5bf"/><dir name="Posten"><file name="Collection.php" hash="0ce6dbb1ce831f71c53d924fb7bab360"/></dir><file name="Posten.php" hash="82adc2661f43b5fb1cd7e1cd8a77c367"/></dir><file name="Observer.php" hash="2e33d276e543c2ef08e9f68c10e8488d"/><file name="Order.php" hash="f194cbf00cc287f45a58c965d24213ca"/><file name="Ordermagento.php" hash="a41d5f03e9b615a1187497198b131810"/><file name="Postdanmark.php" hash="049fd41acaeb28e3acbe6741fd2c3f1f"/><file name="Posten.php" hash="054949a6cd0f076f78587668e07cd723"/><dir name="Rewrite"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Shipping.php" hash="3d717941aea1845c65e0856bfbd2c66c"/><file name="Tax.php" hash="6ce18cd1aba07c4969d5d7edaf3ad042"/></dir></dir></dir></dir><file name="ShippingMethods.php" hash="6a05a45a3089eec8cc769b80c79a640f"/><file name="Status.php" hash="1e747a56f6fa5bfdff090d503178363a"/><dir name="System"><file name="CombinePdf.php" hash="8cf30d3e5ae6122d3df1f62e9020dbb3"/><file name="Listformat.php" hash="44dc7ae56508fd0d6cb6f7b6497b6648"/><file name="OrderOption.php" hash="c3dc4faae2f992a419c155ab3dbacc42"/><file name="Pacsoftformat.php" hash="ca53392c16a6cc90fcd2ca96f11d3cd6"/><dir name="Postdanmark"><file name="Flexdelivery.php" hash="39206f9b3449b523f1d8c2cdbe49ad1a"/></dir><dir name="Posten"><file name="Flexdelivery.php" hash="b48d69d668dcb72e7aa1a7e552346953"/></dir><file name="Return.php" hash="fafdb0b8f936dd53cc57304a12b3d63c"/><file name="Status.php" hash="ffc60450fe14ad83045d85819bd35468"/><file name="Validateuser.php" hash="a8d355bf2d6bf20faea75cf79e78f644"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir></dir><dir name="controllers"><file name="LogisticsController.php" hash="e78823727898fe6fd968549bc23a76b0"/></dir><dir name="etc"><file name="config.xml" hash="b0c61adb042c82367c8c1140407b32f0"/><file name="system.xml" hash="e06653406d7b0e6c6909fa066aee5e19"/><file name=".DS_Store" hash="b1ea3be3ec6afda43ee062206ee5f3ab"/></dir><dir name="sql"><dir name="logistics_setup"><file name="mysql4-install-7.0.1.php" hash="20adc2e823e38d1f6a8768ca7884cbdb"/><file name="mysql4-upgrade-7.0.5-7.0.6.php" hash="84015d08da1d57e444ab49a94d20ccac"/><file name="mysql4-upgrade-7.0.9-7.1.0.php" hash="900722f3b1da348dc862999d4046e3a9"/></dir></dir><file name=".DS_Store" hash="e3d054c2cac95fd07c5f218ce38574c9"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="logistics.xml" hash="5316ef75675bc3b2616a33347dcf2bb0"/></dir><dir name="template"><dir name="logistics"><file name="array_dropdown.phtml" hash="849e900694188359cf6a33b7594c3e1b"/><dir name="sales"><dir name="order"><dir name="view"><file name="info.phtml" hash="21c113f17c39865d2dfcb99316c36a60"/><dir name="tab"><file name="info.phtml" hash="bd6f569633cb9db29ea41647b51a7d88"/></dir></dir></dir></dir><dir name="system"><dir name="config"><file name="excludetax.phtml" hash="8e67e3bf0d3817cfc32d718e0435f8e6"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="logistics.xml" hash="9bab67a5d56c65e36b7c823fcc0d97d1"/></dir><dir name="template"><dir name="logistics"><dir name="checkout"><dir name="cart"><file name="shipping.phtml" hash="210de86c632932ebd6cd174aaa966b91"/></dir><dir name="onepage"><dir name="shipping_method"><file name="available.phtml" hash="dbb6bb045fce61dacfb9aa00753c300d"/></dir><file name=".DS_Store" hash="5b95a9100fb147754073c530fe402082"/></dir><file name=".DS_Store" hash="a07247b3453e9d52dcddf0f81e03203f"/></dir><dir name="email"><dir name="order"><dir name="shipment"><file name="track.phtml" hash="a6e681503ed9697583fcf8a6bb8a8e1f"/></dir></dir></dir><dir name="magestoreOnestepcheckout"><file name="shipping_method.phtml" hash="61ccbcea879644c7c409d6dfb0963d76"/></dir><dir name="onestepcheckout"><file name="shipping_method.phtml" hash="f863700aaf72e850518bf93fd48493a8"/></dir><file name="pickup.phtml" hash="5b771237f30cdd667c9c5b504ccd7e40"/><file name=".DS_Store" hash="11a1882b870d496b2d7caab4a8b3b2a4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Smartsend_Logistics.xml" hash="f54aeead0ec93bc9e7d5150bac2b6907"/></dir></target><target name="magelocale"><dir name="da_DK"><file name="Smartsend_Logistics.csv" hash="c6f719727535bf840e5f7ccb9f768386"/><dir name="template"><dir name="email"><file name="smartsend_new_shipment_email.html" hash="1810230f1ac214ed68f396ebbd94bebc"/></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="logistics"><file name="jquery-1.10.2.min.js" hash="841dc30647f93349b7d8ef61deebe411"/><file name="jquery-1.6.4.min.js" hash="9118381924c51c89d9414a311ec9c97f"/><file name="noconflict.js" hash="3179f2255b046d5f2e9a71e365287bef"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="logistics.js" hash="e0dfee4a43a32d6814f415d83417f6fe"/></dir></dir></dir></dir></target></contents>
70
  <compatible/>
71
+ <dependencies><required><php><min>5.1.0</min><max>7.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.9</max></package><extension><name>curl</name><min>6.0</min><max/></extension></required></dependencies>
72
  </package>
skin/frontend/base/default/js/logistics.js ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Smartsend_Logistics
3
+ *
4
+ * This source file is subject to the GNU General Public License v3.0
5
+ * that is bundled with this package in the file license.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.html
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to license@smartsend.dk so we can send you a copy immediately.
11
+ *
12
+ * DISCLAIMER
13
+ *
14
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
15
+ * versions in the future. If you wish to customize the plugin for your
16
+ * needs please refer to http://www.smartsend.dk
17
+ *
18
+ * @folder /skin/frontend/base/default/js/logistics.js
19
+ * @category Smartsend
20
+ * @package Smartsend_Logistics
21
+ * @author Anders Bilfeldt
22
+ * @url www.smartsend.dk
23
+ */
24
+
25
+
26
+ function showShipping(code, id) {
27
+ hideShippingAll();
28
+
29
+ if (jQuery('#' + id).is(':checked')) {
30
+ if (jQuery('#' + 'shipping_form_' + code).length != 0) {
31
+ jQuery('#' + 'shipping_form_' + code).show();
32
+ jQuery('#' + id).find('.required-entry').attr('disabled', 'false');
33
+ }
34
+ }
35
+ }
36
+ function hideShippingAll() {
37
+ jQuery('input[type="radio"][name="shipping_method"]').each(function() {
38
+ var code = jQuery(this).val();
39
+
40
+ jQuery('#' + 'shipping_form_' + code).hide();
41
+ jQuery(this).find('.required-entry').attr('disabled', 'true');
42
+ });
43
+ }
44
+