Aramex_Shipping_Tracking_API - Version 1.0.1

Version Notes

stable

Download this release

Release Info

Developer Aramex
Extension Aramex_Shipping_Tracking_API
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

Files changed (35) hide show
  1. app/code/community/Aramex/.DS_Store +0 -0
  2. app/code/community/Aramex/Core/.DS_Store +0 -0
  3. app/code/community/Aramex/Core/Aramex_Core.xml +28 -0
  4. app/code/community/Aramex/Core/Helper/Data.php +5 -0
  5. app/code/community/Aramex/Core/Model/Settings.php +0 -0
  6. app/code/community/Aramex/Core/etc/config.xml +41 -0
  7. app/code/community/Aramex/Core/etc/system.xml +81 -0
  8. app/code/community/Aramex/Core/etc/system.xml-15-Jan-2013 +81 -0
  9. app/code/community/Aramex/Core/etc/system.xml-7-Jan-2013 +82 -0
  10. app/code/community/Aramex/Shipment/.DS_Store +0 -0
  11. app/code/community/Aramex/Shipment/Aramex_Shipment.xml +9 -0
  12. app/code/community/Aramex/Shipment/Block/Sales/Order/View.php +15 -0
  13. app/code/community/Aramex/Shipment/Model/Carrier/Aramex.php +329 -0
  14. app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Dropoff.php +39 -0
  15. app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Freemethod.php +36 -0
  16. app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Method.php +39 -0
  17. app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Packaging.php +39 -0
  18. app/code/community/Aramex/Shipment/Model/Carrier/~$Aramex.php +0 -0
  19. app/code/community/Aramex/Shipment/controllers/.DS_Store +0 -0
  20. app/code/community/Aramex/Shipment/controllers/IndexController.php +1 -0
  21. app/code/community/Aramex/Shipment/controllers/ShipmentController.php +455 -0
  22. app/code/community/Aramex/Shipment/etc/config.xml +112 -0
  23. app/code/community/Aramex/Shipping/Model/Carrier/Aramex.php +329 -0
  24. app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Dropoff.php +39 -0
  25. app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Freemethod.php +36 -0
  26. app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Method.php +39 -0
  27. app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Packaging.php +39 -0
  28. app/code/community/Aramex/Shipping/etc/config.xml +78 -0
  29. app/code/community/Aramex/Shipping/etc/system.xml +374 -0
  30. app/design/adminhtml/default/default/template/sales/order/view/tab/info.phtml +1273 -0
  31. app/etc/modules/Aramex_Core.xml +28 -0
  32. aramex/desktop.ini +4 -0
  33. aramex/shipping.wsdl +494 -0
  34. package.xml +18 -0
  35. wsdl/Tracking.wsdl +176 -0
app/code/community/Aramex/.DS_Store ADDED
Binary file
app/code/community/Aramex/Core/.DS_Store ADDED
Binary file
app/code/community/Aramex/Core/Aramex_Core.xml ADDED
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Aramex_Core>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Aramex_Core>
8
+ <!--
9
+ <Aramex_Tracking>
10
+ <active>true</active>
11
+ <codePool>community</codePool>
12
+ <depends>Aramex_Core</depends>
13
+ </Aramex_Tracking>
14
+
15
+ <Aramex_Calculator>
16
+ <active>true</active>
17
+ <codePool>community</codePool>
18
+ <depends>Aramex_Core</depends>
19
+ </Aramex_Calculator>
20
+
21
+ <Aramex_Shipping>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ <depends>Aramex_Core</depends>
25
+ </Aramex_Shipping>
26
+ -->
27
+ </modules>
28
+ </config>
app/code/community/Aramex/Core/Helper/Data.php ADDED
@@ -0,0 +1,5 @@
1
+ <?php
2
+ class Aramex_Core_Helper_Data
3
+ {
4
+ public function __(){}
5
+ }
app/code/community/Aramex/Core/Model/Settings.php ADDED
File without changes
app/code/community/Aramex/Core/etc/config.xml ADDED
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Aramex_Core>
5
+ <version>0.6.0</version>
6
+ </Aramex_Core>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <aramex_core>
11
+ <class>Aramex_Core_Model</class>
12
+ </aramex_core>
13
+ </models>
14
+ <helpers>
15
+ <aramex_core>
16
+ <class>Aramex_Core_Helper</class>
17
+ </aramex_core>
18
+ </helpers>
19
+ </global>
20
+ <adminhtml>
21
+ <acl>
22
+ <resources>
23
+ <admin>
24
+ <children>
25
+ <system>
26
+ <children>
27
+ <config>
28
+ <children>
29
+ <aramexsettings module="aramex_core">
30
+ <title>aramex</title>
31
+ </aramexsettings>
32
+ </children>
33
+ </config>
34
+ </children>
35
+ </system>
36
+ </children>
37
+ </admin>
38
+ </resources>
39
+ </acl>
40
+ </adminhtml>
41
+ </config>
app/code/community/Aramex/Core/etc/system.xml ADDED
@@ -0,0 +1,81 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <aramex translate="label">
5
+ <label>Aramex</label>
6
+ <sort_order>1</sort_order>
7
+ </aramex>
8
+ </tabs>
9
+ <sections>
10
+ <aramexsettings translate="label">
11
+ <label>Aramex Global Settings</label>
12
+ <tab>aramex</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <settings translate="label">
20
+ <label>Client Information</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</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
+ <fields>
27
+ <account_country_code>
28
+ <label>Account Country Code</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>1</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
+ </account_country_code>
35
+ <account_entity>
36
+ <label>Account Entity</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </account_entity>
43
+ <account_number>
44
+ <label>Account Number</label>
45
+ <frontend_type>text</frontend_type>
46
+ <validate>validate-number</validate>
47
+ <sort_order>1</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </account_number>
52
+ <account_pin>
53
+ <label>Account Pin</label>
54
+ <frontend_type>text</frontend_type>
55
+ <validate>validate-number</validate>
56
+ <sort_order>1</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </account_pin>
61
+ <user_name>
62
+ <label>Email</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>1</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </user_name>
69
+ <password>
70
+ <label>Password</label>
71
+ <frontend_type>Password</frontend_type>
72
+ <sort_order>1</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </password>
77
+ </fields>
78
+ </settings> <shipperdetail translate="label"> <label>Shipper Details</label> <frontend_type>text</frontend_type> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <name> <label>Name</label> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </name> <email> <label>Email</label> <frontend_type>text</frontend_type> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </email> <company> <label>Company</label> <frontend_type>text</frontend_type> <sort_order>3</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </company> <address> <label>Address</label> <frontend_type>text</frontend_type> <sort_order>4</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </address> <country> <label>Country Code</label> <frontend_type>text</frontend_type> <sort_order>5</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </country> <city> <label>City</label> <frontend_type>text</frontend_type> <sort_order>6</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </city> <postalcode> <label>Postal Code</label> <frontend_type>text</frontend_type> <sort_order>7</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </postalcode> <state> <label>State</label> <frontend_type>text</frontend_type> <sort_order>8</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </state> <phone> <label>Phone</label> <frontend_type>text</frontend_type> <sort_order>9</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </phone> </fields> </shipperdetail> </groups>
79
+ </aramexsettings>
80
+ </sections>
81
+ </config>
app/code/community/Aramex/Core/etc/system.xml-15-Jan-2013 ADDED
@@ -0,0 +1,81 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <aramex translate="label">
5
+ <label>ARAMEX</label>
6
+ <sort_order>1</sort_order>
7
+ </aramex>
8
+ </tabs>
9
+ <sections>
10
+ <aramexsettings translate="label">
11
+ <label>ARAMEX Global Settings</label>
12
+ <tab>aramex</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <settings translate="label">
20
+ <label>Client Information</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</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
+ <fields>
27
+ <account_country_code>
28
+ <label>Account Country Code</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>1</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
+ </account_country_code>
35
+ <account_entity>
36
+ <label>Account Entity</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </account_entity>
43
+ <account_number>
44
+ <label>Account Number</label>
45
+ <frontend_type>text</frontend_type>
46
+ <validate>validate-number</validate>
47
+ <sort_order>1</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </account_number>
52
+ <account_pin>
53
+ <label>Account Pin</label>
54
+ <frontend_type>text</frontend_type>
55
+ <validate>validate-number</validate>
56
+ <sort_order>1</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </account_pin>
61
+ <user_name>
62
+ <label>Username</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>1</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </user_name>
69
+ <password>
70
+ <label>Password</label>
71
+ <frontend_type>Password</frontend_type>
72
+ <sort_order>1</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </password>
77
+ </fields>
78
+ </settings> <shipperdetail translate="label"> <label>Shipper Detail</label> <frontend_type>text</frontend_type> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> <fields> <name> <label>Name</label> <frontend_type>text</frontend_type> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </name> <email> <label>Email</label> <frontend_type>text</frontend_type> <sort_order>2</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </email> <company> <label>Company</label> <frontend_type>text</frontend_type> <sort_order>3</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </company> <address> <label>Address</label> <frontend_type>text</frontend_type> <sort_order>4</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </address> <country> <label>Country Code</label> <frontend_type>text</frontend_type> <sort_order>5</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </country> <city> <label>City</label> <frontend_type>text</frontend_type> <sort_order>6</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </city> <postalcode> <label>Postal Code</label> <frontend_type>text</frontend_type> <sort_order>7</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </postalcode> <state> <label>State</label> <frontend_type>text</frontend_type> <sort_order>8</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </state> <phone> <label>Phone</label> <frontend_type>text</frontend_type> <sort_order>9</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </phone> </fields> </shipperdetail> </groups>
79
+ </aramexsettings>
80
+ </sections>
81
+ </config>
app/code/community/Aramex/Core/etc/system.xml-7-Jan-2013 ADDED
@@ -0,0 +1,82 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <aramex translate="label">
5
+ <label>ARAMEX</label>
6
+ <sort_order>1</sort_order>
7
+ </aramex>
8
+ </tabs>
9
+ <sections>
10
+ <aramexsettings translate="label">
11
+ <label>ARAMEX Global Settings</label>
12
+ <tab>aramex</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <settings translate="label">
20
+ <label>Client Information</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</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
+ <fields>
27
+ <account_country_code>
28
+ <label>Account Country Code</label>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>1</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
+ </account_country_code>
35
+ <account_entity>
36
+ <label>Account Entity</label>
37
+ <frontend_type>text</frontend_type>
38
+ <sort_order>1</sort_order>
39
+ <show_in_default>1</show_in_default>
40
+ <show_in_website>1</show_in_website>
41
+ <show_in_store>1</show_in_store>
42
+ </account_entity>
43
+ <account_number>
44
+ <label>Account Number</label>
45
+ <frontend_type>text</frontend_type>
46
+ <validate>validate-number</validate>
47
+ <sort_order>1</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>1</show_in_store>
51
+ </account_number>
52
+ <account_pin>
53
+ <label>Account Pin</label>
54
+ <frontend_type>text</frontend_type>
55
+ <validate>validate-number</validate>
56
+ <sort_order>1</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </account_pin>
61
+ <user_name>
62
+ <label>Username</label>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>1</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </user_name>
69
+ <password>
70
+ <label>Password</label>
71
+ <frontend_type>Password</frontend_type>
72
+ <sort_order>1</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </password>
77
+ </fields>
78
+ </settings>
79
+ </groups>
80
+ </aramexsettings>
81
+ </sections>
82
+ </config>
app/code/community/Aramex/Shipment/.DS_Store ADDED
Binary file
app/code/community/Aramex/Shipment/Aramex_Shipment.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <modules>
4
+ <Aramex_Shipment>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Aramex_Shipment>
8
+ </modules>
9
+ </config>
app/code/community/Aramex/Shipment/Block/Sales/Order/View.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ class Aramex_Shipment_Block_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
3
+ {
4
+ function __construct()
5
+ { $itemscount = 0; $totalWeight = 0; $_order = Mage::getModel('sales/order')->load($this->getRequest()->getParam('order_id')); $itemsv = $_order->getAllVisibleItems(); foreach($itemsv as $itemvv){ if($itemvv->getQtyOrdered() > $itemvv->getQtyShipped()){ $itemscount += $itemvv->getQtyOrdered() - $itemvv->getQtyShipped(); } if($itemvv->getWeight() != 0){ $weight = $itemvv->getWeight()*$itemvv->getQtyOrdered(); } else { $weight = 0.5*$itemvv->getQtyOrdered(); } $totalWeight += $weight; }
6
+ $this->_addButton('create_aramex_shipment', array(
7
+ 'label' => Mage::helper('Sales')->__('Prepare Aramex Shipment'),
8
+ 'onclick' => 'aramexpop('.$itemscount.')',
9
+ 'class' => 'go'
10
+ ), 0, 100, 'header', 'header');
11
+
12
+ parent::__construct();
13
+ }
14
+ }
15
+ ?>
app/code/community/Aramex/Shipment/Model/Carrier/Aramex.php ADDED
@@ -0,0 +1,329 @@
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Usa
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+ class Aramex_Shipping_Model_Carrier_Aramex extends Mage_Usa_Model_Shipping_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
28
+
29
+ protected $_code = 'aramex';
30
+ protected $_request = null;
31
+ protected $_result = null;
32
+ protected $_defaultGatewayUrl = null;
33
+
34
+ function __construct()
35
+ {
36
+ $this->_defaultGatewayUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'wsdl/Tracking2.wsdl';
37
+ }
38
+
39
+ protected function _doShipmentRequest(Varien_Object $request)
40
+ {
41
+ return $result;
42
+ }
43
+
44
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
45
+ {
46
+ if (!$this->getConfigFlag($this->_activeFlag)) {
47
+ return false;
48
+ }
49
+
50
+ $this->setRequest($request);
51
+
52
+ $this->_result = $this->_getQuotes();
53
+
54
+ $this->_updateFreeMethodQuote($request);
55
+
56
+ return $this->getResult();
57
+ }
58
+
59
+ public function setRequest(Mage_Shipping_Model_Rate_Request $request) {
60
+ $this->_request = $request;
61
+
62
+ $r = new Varien_Object();
63
+
64
+ if ($request->getLimitMethod()) {
65
+ $r->setService($request->getLimitMethod());
66
+ } else {
67
+ $r->setService('ALL');
68
+ }
69
+
70
+ if ($request->getAramexUserid()) {
71
+ $userId = $request->getAramexUserid();
72
+ } else {
73
+ $userId = $this->getConfigData('userid');
74
+ }
75
+ $r->setUserId($userId);
76
+
77
+ if ($request->getAramexContainer()) {
78
+ $container = $request->getAramexContainer();
79
+ } else {
80
+ $container = $this->getConfigData('container');
81
+ }
82
+ $r->setContainer($container);
83
+
84
+ if ($request->getAramexSize()) {
85
+ $size = $request->getAramexSize();
86
+ } else {
87
+ $size = $this->getConfigData('size');
88
+ }
89
+ $r->setSize($size);
90
+
91
+ if ($request->getAramexMachinable()) {
92
+ $machinable = $request->getAramexMachinable();
93
+ } else {
94
+ $machinable = $this->getConfigData('machinable');
95
+ }
96
+ $r->setMachinable($machinable);
97
+
98
+ if ($request->getOrigPostcode()) {
99
+ $r->setOrigPostal($request->getOrigPostcode());
100
+ } else {
101
+ $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode'));
102
+ }
103
+
104
+ if ($request->getDestCountryId()) {
105
+ $destCountry = $request->getDestCountryId();
106
+ } else {
107
+ $destCountry = self::USA_COUNTRY_ID;
108
+ }
109
+
110
+ $r->setDestCountryId($destCountry);
111
+
112
+
113
+ $countries = Mage::getResourceModel('directory/country_collection')
114
+ ->addCountryIdFilter($destCountry)
115
+ ->load()
116
+ ->getItems();
117
+ $country = array_shift($countries);
118
+ $countryName = $country->getName();
119
+
120
+ $r->setDestCountryName($countryName);
121
+
122
+ if ($request->getDestPostcode()) {
123
+ $r->setDestPostal($request->getDestPostcode());
124
+ }
125
+
126
+ $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
127
+ $r->setWeightPounds(floor($weight));
128
+ $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
129
+ if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
130
+ $r->setFreeMethodWeight($request->getFreeMethodWeight());
131
+ }
132
+
133
+ $r->setValue($request->getPackageValue());
134
+ $r->setValueWithDiscount($request->getPackageValueWithDiscount());
135
+
136
+ $this->_rawRequest = $r;
137
+
138
+ return $this;
139
+ }
140
+
141
+ public function getCode($type, $code='') {
142
+ return false;
143
+ }
144
+
145
+ protected function _getQuotes() {
146
+ return false;
147
+ }
148
+
149
+ public function getResult() {
150
+ return $this->_result;
151
+ }
152
+
153
+ protected function _setFreeMethodRequest($freeMethod) {
154
+ $r = $this->_rawRequest;
155
+
156
+ $weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight());
157
+ $r->setWeightPounds(floor($weight));
158
+ $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
159
+ $r->setService($freeMethod);
160
+ }
161
+
162
+ /**
163
+ * Get allowed shipping methods
164
+ *
165
+ * @return array
166
+ */
167
+ public function getAllowedMethods()
168
+ {
169
+ $allowed = explode(',', $this->getConfigData('allowed_methods'));
170
+ $arr = array();
171
+ foreach ($allowed as $k) {
172
+ $arr[$k] = $this->getCode('method', $k);
173
+ }
174
+ return $arr;
175
+ }
176
+
177
+ /**
178
+ * Return array of authenticated information
179
+ *
180
+ * @return array
181
+ */
182
+ protected function _getAuthDetails()
183
+ {
184
+ return array(
185
+ 'ClientInfo' => array(
186
+ 'AccountCountryCode' => Mage::getStoreConfig('aramexsettings/settings/account_country_code'),
187
+ 'AccountEntity' => Mage::getStoreConfig('aramexsettings/settings/account_entity'),
188
+ 'AccountNumber' => Mage::getStoreConfig('aramexsettings/settings/account_number'),
189
+ 'AccountPin' => Mage::getStoreConfig('aramexsettings/settings/account_pin'),
190
+ 'UserName' => Mage::getStoreConfig('aramexsettings/settings/user_name'),
191
+ 'Password' => Mage::getStoreConfig('aramexsettings/settings/password'),
192
+ 'Version' => 'v1.0'
193
+ )
194
+ );
195
+ }
196
+
197
+ public function getTracking($trackings) {
198
+ $this->setTrackingReqeust();
199
+
200
+ if (!is_array($trackings)) {
201
+ $trackings = array($trackings);
202
+ }
203
+
204
+ $this->_getXmlTracking($trackings);
205
+
206
+ return $this->_result;
207
+ }
208
+
209
+ protected function setTrackingReqeust() {
210
+ $r = new Varien_Object();
211
+
212
+ $userId = $this->getConfigData('userid');
213
+ $r->setUserId($userId);
214
+
215
+ $this->_rawTrackRequest = $r;
216
+ }
217
+
218
+ protected function _getXmlTracking($trackings) {
219
+ $r = $this->_rawTrackRequest;
220
+
221
+ foreach ($trackings as $tracking) {
222
+ $this->_parseXmlTrackingResponse($tracking);
223
+ }
224
+ }
225
+
226
+ protected function _parseXmlTrackingResponse($trackingvalue) {
227
+ $resultArr = array();
228
+
229
+ if (!$this->_result) {
230
+ $this->_result = Mage::getModel('shipping/tracking_result');
231
+ }
232
+ $defaults = $this->getDefaults();
233
+
234
+ //$url = 'http://localhost:8080/soap_test/wsdl/Tracking.wsdl';
235
+ //if (!$url) {
236
+ $url = $this->_defaultGatewayUrl;
237
+ //}
238
+
239
+ $clientAramex = new SoapClient($url);
240
+ $aramexParams = $this->_getAuthDetails();
241
+
242
+ $aramexParams['Transaction'] = array('Reference1' => '001' );
243
+ $aramexParams['Shipments'] = array($trackingvalue);
244
+
245
+ $_resAramex = $clientAramex->TrackShipments($aramexParams);
246
+
247
+ if(is_object($_resAramex) && !$_resAramex->HasErrors){
248
+ $tracking = Mage::getModel('shipping/tracking_result_status');
249
+ $tracking->setCarrier('aramex');
250
+ $tracking->setCarrierTitle($this->getConfigData('title'));
251
+ $tracking->setTracking($trackingvalue);
252
+ if(!empty($_resAramex->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult)){
253
+ $tracking->setTrackSummary($this->getTrackingInfoTable($_resAramex->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult));
254
+ } else {
255
+ $tracking->setTrackSummary('Unable to retrieve quotes, please check if the Tracking Number is valid or contact your administrator.');
256
+ }
257
+ $this->_result->append($tracking);
258
+ } else {
259
+ $errorMessage = '';
260
+ foreach($_resAramex->Notifications as $notification){
261
+ $errorMessage .= '<b>' . $notification->Code . '</b>' . $notification->Message;
262
+ }
263
+ $error = Mage::getModel('shipping/tracking_result_error');
264
+ $error->setCarrier('aramex');
265
+ $error->setCarrierTitle($this->getConfigData('title'));
266
+ $error->setTracking($trackingvalue);
267
+ $error->setErrorMessage($errorMessage);
268
+ $this->_result->append($error);
269
+ }
270
+ }
271
+
272
+ public function getResponse() {
273
+ $statuses = '';
274
+ if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result) {
275
+ if ($trackings = $this->_result->getAllTrackings()) {
276
+ foreach ($trackings as $tracking) {
277
+ if ($data = $tracking->getAllData()) {
278
+ if (!empty($data['track_summary'])) {
279
+ $statuses .= Mage::helper('usa')->__($data['track_summary']);
280
+ } else {
281
+ $statuses .= Mage::helper('usa')->__('Empty response');
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ if (empty($statuses)) {
288
+ $statuses = Mage::helper('usa')->__('Empty response');
289
+ }
290
+ return $statuses;
291
+ }
292
+
293
+ /**
294
+ * Get allowed shipping methods
295
+ *
296
+ * @return array
297
+ */
298
+ public function getTrackingInfoTable($HAWBHistory) {
299
+
300
+ $_resultTable = '<table summary="Item Tracking" class="data-table">';
301
+ $_resultTable .= '<col width="1">
302
+ <col width="1">
303
+ <col width="1">
304
+ <col width="1">
305
+ <thead>
306
+ <tr class="first last">
307
+ <th>Location</th>
308
+ <th>Action Date/Time</th>
309
+ <th class="a-right">Tracking Description</th>
310
+ <th class="a-center">Comments</th>
311
+ </tr>
312
+ </thead><tbody>';
313
+
314
+ foreach ($HAWBHistory as $HAWBUpdate) {
315
+
316
+ $_resultTable .= '<tr>
317
+ <td>' . $HAWBUpdate->UpdateLocation . '</td>
318
+ <td>' . $HAWBUpdate->UpdateDateTime . '</td>
319
+ <td>' . $HAWBUpdate->UpdateDescription . '</td>
320
+ <td>' . $HAWBUpdate->Comments . '</td>
321
+ </tr>';
322
+ }
323
+ $_resultTable .= '</tbody></table>';
324
+
325
+ return $_resultTable;
326
+ }
327
+ }
328
+
329
+ ?>
app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Dropoff.php ADDED
@@ -0,0 +1,39 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Dropoff
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $fedex = Mage::getSingleton('Aramex_Shipping_Model_Carrier_Aramex');
33
+ $arr = array();
34
+ foreach ($fedex->getCode('dropoff') as $k=>$v) {
35
+ $arr[] = array('value'=>$k, 'label'=>$v);
36
+ }
37
+ return $arr;
38
+ }
39
+ }
app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Freemethod.php ADDED
@@ -0,0 +1,36 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Freemethod extends Aramex_Shipping_Model_Carrier_Aramex_Source_Method
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $arr = parent::toOptionArray();
33
+ array_unshift($arr, array('value'=>'', 'label'=>Mage::helper('shipping')->__('None')));
34
+ return $arr;
35
+ }
36
+ }
app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Method.php ADDED
@@ -0,0 +1,39 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Method
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $fedex = Mage::getSingleton('Aramex_Shipping_Model_Carrier_Aramex');
33
+ $arr = array();
34
+ foreach ($fedex->getCode('method') as $k=>$v) {
35
+ $arr[] = array('value'=>$k, 'label'=>$v);
36
+ }
37
+ return $arr;
38
+ }
39
+ }
app/code/community/Aramex/Shipment/Model/Carrier/Aramex/Source/Packaging.php ADDED
@@ -0,0 +1,39 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Packaging
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $fedex = Mage::getSingleton('Aramex_Shipping_Model_Carrier_Aramex');
33
+ $arr = array();
34
+ foreach ($fedex->getCode('packaging') as $k=>$v) {
35
+ $arr[] = array('value'=>$k, 'label'=>$v);
36
+ }
37
+ return $arr;
38
+ }
39
+ }
app/code/community/Aramex/Shipment/Model/Carrier/~$Aramex.php ADDED
Binary file
app/code/community/Aramex/Shipment/controllers/.DS_Store ADDED
Binary file
app/code/community/Aramex/Shipment/controllers/IndexController.php ADDED
@@ -0,0 +1 @@
1
+ <?php class Aramex_Shipment_IndexController extends Mage_Adminhtml_Controller_Action { public function indexAction() { $this->loadLayout(); $this->renderLayout(); } }?>
app/code/community/Aramex/Shipment/controllers/ShipmentController.php ADDED
@@ -0,0 +1,455 @@
1
+ <?php
2
+ class Aramex_Shipment_ShipmentController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+ public function postAction()
6
+ {
7
+
8
+ //removing index.php from base url to include wsdl file
9
+ $baseUrl = str_replace("index.php/", "", Mage::getUrl());
10
+
11
+ //SOAP object
12
+ $soapClient = new SoapClient($baseUrl . 'aramex/shipping.wsdl');
13
+
14
+
15
+ $aramex_errors = false;
16
+ $post = $this->getRequest()->getPost();
17
+
18
+ $flag = true;
19
+ $error = "";
20
+
21
+
22
+
23
+ try {
24
+ if (empty($post)) {
25
+ Mage::throwException($this->__('Invalid form data.'));
26
+ }
27
+
28
+
29
+
30
+
31
+ /* here's your form processing */
32
+ $order = Mage::getModel('sales/order')->loadByIncrementId($post['aramex_shipment_original_reference']);
33
+ $payment = $order->getPayment();
34
+
35
+ $totalWeight = 0;
36
+ $totalItems = 0;
37
+
38
+ $items = $order->getAllItems();
39
+
40
+ $aramex_items_counter = 0;
41
+ foreach($post['aramex_items'] as $key => $value){
42
+ $aramex_items_counter++;
43
+ if($value != 0){
44
+ //itrating order items
45
+ foreach($items as $item){
46
+ if($item->getId() == $key){
47
+ //get weight
48
+ if($item->getWeight() != 0){
49
+ $weight = $item->getWeight()*$item->getQtyOrdered();
50
+ } else {
51
+ $weight = 0.5*$item->getQtyOrdered();
52
+ }
53
+
54
+ // collect items for aramex
55
+ $aramex_items[] = array(
56
+ 'PackageType' => 'Box',
57
+ 'Quantity' => $post[$item->getId()],
58
+ 'Weight' => array(
59
+ 'Value' => $weight,
60
+ 'Unit' => 'Kg'
61
+ ),
62
+ 'Comments' => $item->getName(), //'',
63
+ 'Reference' => ''
64
+ );
65
+
66
+ $totalWeight += $weight;
67
+ $totalItems += $post[$item->getId()];
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ $aramex_atachments=array();
74
+ //attachment
75
+ for($i=1;$i<=3;$i++){
76
+ $fileName = $_FILES['file'.$i]['name'];
77
+ if(isset($fileName)){
78
+ $fileName = explode('.', $fileName);
79
+ $fileName = $fileName[0]; //filename without extension
80
+ $fileData = file_get_contents($_FILES['file'.$i]['tmp_name']);
81
+ //$fileData = base64_encode($fileData); //base64binary encode
82
+ $ext = pathinfo($_FILES['file'.$i]['name'], PATHINFO_EXTENSION); //file extension
83
+ if($fileName&&$ext&&$fileData)
84
+ $aramex_atachments[] = array(
85
+ 'FileName' => $fileName,
86
+ 'FileExtension' => $ext,
87
+ 'FileContents' => $fileData
88
+ );
89
+ }
90
+ }
91
+
92
+
93
+
94
+
95
+
96
+ $totalWeight = $post['order_weight'];
97
+ //$totalItems += $post[$item->getId()];
98
+
99
+ $params = array();
100
+
101
+ //shipper parameters
102
+ $params['Shipper'] = array(
103
+ 'Reference1' => $post['aramex_shipment_shipper_reference'], //'ref11111',
104
+ 'Reference2' => '',
105
+ 'AccountNumber' => ($post['aramex_shipment_info_billing_account'] == 1) ? $post['aramex_shipment_shipper_account'] : '', //'43871',
106
+
107
+ //Party Address
108
+ 'PartyAddress' => array(
109
+ 'Line1' => mysql_escape_string($post['aramex_shipment_shipper_street']), //'13 Mecca St',
110
+ 'Line2' => '',
111
+ 'Line3' => '',
112
+ 'City' => $post['aramex_shipment_shipper_city'], //'Dubai',
113
+ 'StateOrProvinceCode' => $post['aramex_shipment_shipper_state'], //'',
114
+ 'PostCode' => $post['aramex_shipment_shipper_postal'],
115
+ 'CountryCode' => $post['aramex_shipment_shipper_country'], //'AE'
116
+ ),
117
+
118
+ //Contact Info
119
+ 'Contact' => array(
120
+ 'Department' => '',
121
+ 'PersonName' => $post['aramex_shipment_shipper_name'], //'Suheir',
122
+ 'Title' => '',
123
+ 'CompanyName' => $post['aramex_shipment_shipper_company'], //'Aramex',
124
+ 'PhoneNumber1' => $post['aramex_shipment_shipper_phone'], //'55555555',
125
+ 'PhoneNumber1Ext' => '',
126
+ 'PhoneNumber2' => '',
127
+ 'PhoneNumber2Ext' => '',
128
+ 'FaxNumber' => '',
129
+ 'CellPhone' => $post['aramex_shipment_shipper_phone'],
130
+ 'EmailAddress' => $post['aramex_shipment_shipper_email'], //'',
131
+ 'Type' => ''
132
+ ),
133
+ );
134
+
135
+ //consinee parameters
136
+ $params['Consignee'] = array(
137
+ 'Reference1' => $post['aramex_shipment_receiver_reference'], //'',
138
+ 'Reference2' => '',
139
+ 'AccountNumber' => ($post['aramex_shipment_info_billing_account'] == 2) ? $post['aramex_shipment_shipper_account'] : '',
140
+
141
+ //Party Address
142
+ 'PartyAddress' => array(
143
+ 'Line1' => $post['aramex_shipment_receiver_street'], //'15 ABC St',
144
+ 'Line2' => '',
145
+ 'Line3' => '',
146
+ 'City' => $post['aramex_shipment_receiver_city'], //'Amman',
147
+ 'StateOrProvinceCode' => '',
148
+ 'PostCode' => $post['aramex_shipment_receiver_postal'],
149
+ 'CountryCode' => $post['aramex_shipment_receiver_country'], //'JO'
150
+ ),
151
+
152
+ //Contact Info
153
+ 'Contact' => array(
154
+ 'Department' => '',
155
+ 'PersonName' => $post['aramex_shipment_receiver_name'], //'Mazen',
156
+ 'Title' => '',
157
+ 'CompanyName' => $post['aramex_shipment_receiver_company'], //'Aramex',
158
+ 'PhoneNumber1' => $post['aramex_shipment_receiver_phone'], //'6666666',
159
+ 'PhoneNumber1Ext' => '',
160
+ 'PhoneNumber2' => '',
161
+ 'PhoneNumber2Ext' => '',
162
+ 'FaxNumber' => '',
163
+ 'CellPhone' => $post['aramex_shipment_receiver_phone'],
164
+ 'EmailAddress' => $post['aramex_shipment_receiver_email'], //'mazen@aramex.com',
165
+ 'Type' => ''
166
+ )
167
+ );
168
+
169
+ //new
170
+
171
+ if($post['aramex_shipment_info_billing_account'] == 3){
172
+ $params['ThirdParty'] = array(
173
+ 'Reference1' => $post['aramex_shipment_shipper_reference'], //'ref11111',
174
+ 'Reference2' => '',
175
+ 'AccountNumber' => $post['aramex_shipment_shipper_account'], //'43871',
176
+
177
+ //Party Address
178
+ 'PartyAddress' => array(
179
+ 'Line1' => mysql_escape_string(Mage::getStoreConfig('aramexsettings/shipperdetail/address')), //'13 Mecca St',
180
+ 'Line2' => '',
181
+ 'Line3' => '',
182
+ 'City' => Mage::getStoreConfig('aramexsettings/shipperdetail/city'), //'Dubai',
183
+ 'StateOrProvinceCode' => Mage::getStoreConfig('aramexsettings/shipperdetail/state'), //'',
184
+ 'PostCode' => Mage::getStoreConfig('aramexsettings/shipperdetail/postalcode'),
185
+ 'CountryCode' => Mage::getStoreConfig('aramexsettings/shipperdetail/country'), //'AE'
186
+ ),
187
+
188
+ //Contact Info
189
+ 'Contact' => array(
190
+ 'Department' => '',
191
+ 'PersonName' => Mage::getStoreConfig('aramexsettings/shipperdetail/name'), //'Suheir',
192
+ 'Title' => '',
193
+ 'CompanyName' => Mage::getStoreConfig('aramexsettings/shipperdetail/company'), //'Aramex',
194
+ 'PhoneNumber1' => Mage::getStoreConfig('aramexsettings/shipperdetail/phone'), //'55555555',
195
+ 'PhoneNumber1Ext' => '',
196
+ 'PhoneNumber2' => '',
197
+ 'PhoneNumber2Ext' => '',
198
+ 'FaxNumber' => '',
199
+ 'CellPhone' => Mage::getStoreConfig('aramexsettings/shipperdetail/phone'),
200
+ 'EmailAddress' => Mage::getStoreConfig('aramexsettings/shipperdetail/email'), //'',
201
+ 'Type' => ''
202
+ ),
203
+ );
204
+
205
+ }
206
+
207
+
208
+
209
+ // Other Main Shipment Parameters
210
+
211
+ $params['Reference1'] = $post['aramex_shipment_info_reference']; //'Shpt0001';
212
+ $params['Reference2'] = '';
213
+ $params['Reference3'] = '';
214
+ $params['ForeignHAWB'] = $post['aramex_shipment_info_foreignhawb'];
215
+
216
+ $params['TransportType'] = 0;
217
+ $params['ShippingDateTime'] = time(); //date('m/d/Y g:i:sA');
218
+ $params['DueDate'] = time() + (7 * 24 * 60 * 60); //date('m/d/Y g:i:sA');
219
+ $params['PickupLocation'] = 'Reception';
220
+ $params['PickupGUID'] = '';
221
+ /*if($post['aramex_shipment_shipper_country'] == $post['aramex_shipment_receiver_country']){
222
+ $cod_currency_value = $post['aramex_shipment_info_cod_value'];
223
+ $cod_currency = $order->getData('base_currency_code');
224
+ } else {
225
+
226
+ //TODO (dynamic base currency)
227
+
228
+ $cod_currency_value = round(Mage::helper('directory')->currencyConvert($post['aramex_shipment_info_cod_value'], 'INR', 'USD'), 2);
229
+ $cod_currency = 'USD';
230
+ }
231
+
232
+ if($payment->getData('method') == 'ig_cashondelivery'){
233
+ $payment_comment = 'Please collect COD amount '.$cod_currency_value.' '.$cod_currency;
234
+ } else {
235
+ $payment_comment = 'Paid online by credit card';
236
+ }
237
+ */
238
+ $params['Comments'] = $post['aramex_shipment_info_comment'];
239
+ $params['AccountingInstrcutions'] = '';
240
+ $params['OperationsInstructions'] = '';
241
+
242
+
243
+ $params['Details'] = array(
244
+ 'Dimensions' => array(
245
+ 'Length' => '0',
246
+ 'Width' => '0',
247
+ 'Height' => '0',
248
+ 'Unit' => 'cm'
249
+ ),
250
+
251
+ 'ActualWeight' => array(
252
+ 'Value' => $totalWeight,
253
+ 'Unit' => 'Kg'
254
+ ),
255
+
256
+ 'ProductGroup' => $post['aramex_shipment_info_product_group'], //'EXP',
257
+ 'ProductType' => $post['aramex_shipment_info_product_type'], //,'PDX'
258
+
259
+
260
+ 'PaymentType' => $post['aramex_shipment_info_payment_type'],
261
+
262
+
263
+ 'PaymentOptions' => $post['aramex_shipment_info_payment_option'], //$post['aramex_shipment_info_payment_option']
264
+
265
+
266
+ 'Services' => $post['aramex_shipment_info_service_type'],
267
+
268
+ 'NumberOfPieces' => $totalItems,
269
+ 'DescriptionOfGoods' => $post['aramex_shipment_description'],
270
+ 'GoodsOriginCountry' => $post['aramex_shipment_shipper_country'], //'JO',
271
+ 'Items' => $aramex_items,
272
+ );
273
+ if(count($aramex_atachments)){
274
+ $params['Attachments'] = $aramex_atachments;
275
+ }
276
+ //print_r($params);exit;
277
+ //if($payment->getData('method') == 'ig_cashondelivery'){
278
+ if($post['aramex_shipment_info_product_type'] == 'CDA'){
279
+ /*if($post['aramex_shipment_shipper_country'] == $post['aramex_shipment_receiver_country']){
280
+ $params['Details']['CashOnDeliveryAmount'] = array(
281
+ 'Value' => $post['aramex_shipment_info_cod_amount'], //$payment->getData('amount_authorized'),
282
+ 'CurrencyCode' => $order->getData('base_currency_code')
283
+ );
284
+ } else {
285
+ $aramex_amount = round(Mage::helper('directory')->currencyConvert($post['aramex_shipment_info_cod_amount'], $order->getData('base_currency_code'), 'USD'), 2);
286
+ if($aramex_amount > 500){
287
+ Mage::getSingleton('adminhtml/session')->addError('Aramex: shipment COD amount is over 500#x27;);
288
+ } else {
289
+ $params['Details']['CashOnDeliveryAmount'] = array(
290
+ 'Value' => round(Mage::helper('directory')->currencyConvert($post['aramex_shipment_info_cod_amount'], $order->getData('base_currency_code'), 'USD'), 2),
291
+ 'CurrencyCode' => 'USD'
292
+ );
293
+ }
294
+ }
295
+
296
+
297
+ $params['Details']['CashOnDeliveryAmount'] = array(
298
+ 'Value' => $post['aramex_shipment_info_cod_amount'], //$payment->getData('amount_authorized'),
299
+ 'CurrencyCode' => $post['aramex_shipment_currency_code']
300
+ );
301
+ */
302
+
303
+ }
304
+
305
+ $params['Details']['CashOnDeliveryAmount'] = array(
306
+ 'Value' => $post['aramex_shipment_info_cod_amount'], //$payment->getData('amount_authorized'),
307
+ 'CurrencyCode' => $post['aramex_shipment_currency_code']
308
+ );
309
+
310
+ $params['Details']['CustomsValueAmount'] = array(
311
+ 'Value' => $post['aramex_shipment_info_custom_amount'], //$payment->getData('amount_authorized'),
312
+ 'CurrencyCode' => $post['aramex_shipment_currency_code']
313
+ );
314
+
315
+ $major_par['Shipments'][] = $params;
316
+
317
+ $major_par['ClientInfo'] = array(
318
+ 'AccountCountryCode' => Mage::getStoreConfig('aramexsettings/settings/account_country_code',Mage::app()->getStore()),
319
+ 'AccountEntity' => Mage::getStoreConfig('aramexsettings/settings/account_entity',Mage::app()->getStore()),
320
+ 'AccountNumber' => Mage::getStoreConfig('aramexsettings/settings/account_number',Mage::app()->getStore()),
321
+ 'AccountPin' => Mage::getStoreConfig('aramexsettings/settings/account_pin',Mage::app()->getStore()),
322
+ 'UserName' => Mage::getStoreConfig('aramexsettings/settings/user_name',Mage::app()->getStore()),
323
+ 'Password' => Mage::getStoreConfig('aramexsettings/settings/password',Mage::app()->getStore()),
324
+ 'Version' => '1.0'
325
+ );
326
+
327
+ $major_par['LabelInfo'] = array(
328
+ 'ReportID' => 9729, //'9201',
329
+ 'ReportType' => 'URL'
330
+ );
331
+
332
+ //print_r($major_par);exit;
333
+
334
+ //print_r($major_par);exit;
335
+
336
+ $_SESSION['form_data'] = $_POST;
337
+
338
+ //print_r($params['Attachment']);die;
339
+
340
+
341
+
342
+ try {
343
+ //create shipment call
344
+ $auth_call = $soapClient->CreateShipments($major_par);
345
+
346
+
347
+
348
+ if($auth_call->HasErrors){
349
+ if(empty($auth_call->Shipments)){
350
+ if(count($auth_call->Notifications->Notification) > 1){
351
+ foreach($auth_call->Notifications->Notification as $notify_error){
352
+ Mage::throwException($this->__('Aramex: ' . $notify_error->Code .' - '. $notify_error->Message));
353
+ }
354
+ } else {
355
+ Mage::throwException($this->__('Aramex: ' . $auth_call->Notifications->Notification->Code . ' - '. $auth_call->Notifications->Notification->Message));
356
+ }
357
+ } else {
358
+ if(count($auth_call->Shipments->ProcessedShipment->Notifications->Notification) > 1){
359
+ $notification_string = '';
360
+ foreach($auth_call->Shipments->ProcessedShipment->Notifications->Notification as $notification_error){
361
+ $notification_string .= $notification_error->Code .' - '. $notification_error->Message . ' <br />';
362
+ }
363
+ Mage::throwException($notification_string);
364
+ } else {
365
+ Mage::throwException($this->__('Aramex: ' . $auth_call->Shipments->ProcessedShipment->Notifications->Notification->Code .' - '. $auth_call->Shipments->ProcessedShipment->Notifications->Notification->Message));Mage::throwException($this->__('Aramex: ' . $auth_call->Shipments->ProcessedShipment->Notifications->Notification->Code .' - '. $auth_call->Shipments->ProcessedShipment->Notifications->Notification->Message));
366
+ }
367
+ }
368
+ } else {
369
+ if($order->canShip()) {
370
+
371
+ //Create shipment in magento
372
+ $shipmentid = Mage::getModel('sales/order_shipment_api')->create($order->getIncrementId(), $post['aramex_items'], "AWB No. ".$auth_call->Shipments->ProcessedShipment->ID." - Order No. ".$auth_call->Shipments->ProcessedShipment->Reference1." - " .$auth_call->Shipments->ProcessedShipment->ShipmentLabel->LabelURL);
373
+
374
+
375
+
376
+ //Add tracking information
377
+ $ship = true;
378
+
379
+ //$ship = Mage::getModel('sales/order_shipment_api')->addTrack($shipmentid, 'aramex', 'Aramex', $auth_call->Shipments->ProcessedShipment->ID);
380
+
381
+ //sending mail
382
+ if($ship){
383
+ // if($post['aramex_email_customer'] == 'yes'){
384
+
385
+
386
+ $fromEmail = $post['aramex_shipment_shipper_email']; // sender email address
387
+ $fromName = $post['aramex_shipment_shipper_name']; // sender name
388
+
389
+ $toEmail = $post['aramex_shipment_receiver_email']; // recipient email address
390
+ $toName = $post['aramex_shipment_receiver_name']; // recipient name
391
+
392
+ $body = "Your shipment has been created for order id : ".$post['aramex_shipment_info_reference']."<br />Shipment No : ".$auth_call->Shipments->ProcessedShipment->ID."<br />"; // body text
393
+ $subject = "Aramex Shipment"; // subject text
394
+
395
+ // $mail = new Zend_Mail();
396
+ //
397
+ // $mail->setBodyText($body);
398
+ //
399
+ // $mail->setFrom($fromEmail, $fromName);
400
+ //
401
+ // $mail->addTo($toEmail, $toName);
402
+ //
403
+ // $mail->setSubject($subject);
404
+ //
405
+ // try {
406
+ // $mail->send();
407
+ // }
408
+ // catch(Exception $ex) {
409
+ // Mage::getSingleton('core/session')
410
+ // ->addError('Unable to send email.');
411
+ // }
412
+ $body = 'Airway bill number: '.$auth_call->Shipments->ProcessedShipment->ID.'<br />Order number: '.$order->getIncrementId().'<br />You can track shipment on <a href="http://www.aramex.com/express/track.aspx">http://www.aramex.com/express/track.aspx</a><br />';
413
+ $mail = new Zend_Mail();
414
+ $mail->setBodyText($body);
415
+ $fromEmail=Mage::getStoreConfig('trans_email/ident_general/email');
416
+ $fromName=Mage::getStoreConfig('trans_email/ident_general/name');
417
+ $mail->setFrom($fromEmail, $fromName);
418
+ $toEmail=$order->getCustomerEmail();
419
+ $toName=$order->getCustomerName();
420
+ $mail->addTo($toEmail, $toName);
421
+ $mail->setSubject($subject);
422
+
423
+ try {
424
+ $mail->send();
425
+ }
426
+
427
+ catch(Exception $ex) {
428
+ Mage::getSingleton('core/session')
429
+ ->addError('Unable to send email.');
430
+ }
431
+
432
+ // }
433
+ }
434
+
435
+ Mage::getSingleton('core/session')->addSuccess('Aramex Shipment Number: '.$auth_call->Shipments->ProcessedShipment->ID.' has been created.');
436
+ //$order->setState('warehouse_pickup_shipped', true);
437
+ }
438
+ }
439
+ } catch (Exception $e) {
440
+ $aramex_errors = true;
441
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
442
+ }
443
+
444
+ if($aramex_errors){
445
+ $this->_redirectUrl($post['aramex_shipment_referer'] . 'aramexpopup/show');
446
+ } else {
447
+ $this->_redirectUrl($post['aramex_shipment_referer']);
448
+ }
449
+
450
+ } catch (Exception $e) {
451
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
452
+ }
453
+ }
454
+ }
455
+ ?>
app/code/community/Aramex/Shipment/etc/config.xml ADDED
@@ -0,0 +1,112 @@
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <modules>
4
+ <Aramex_Shipment>
5
+ <version>0.1.0</version>
6
+ </Aramex_Shipment>
7
+ </modules>
8
+ <global>
9
+ <blocks>
10
+ <adminhtml>
11
+ <rewrite>
12
+ <sales_order_view>Aramex_Shipment_Block_Sales_Order_View</sales_order_view>
13
+ </rewrite>
14
+ </adminhtml>
15
+ </blocks>
16
+ <template>
17
+ <email>
18
+ <aramex_general_email_template>
19
+ <label>Aramex New Shipment</label>
20
+ <file>aramex_shipment_created.html</file>
21
+ <type>html</type>
22
+ </aramex_general_email_template>
23
+ </email>
24
+ </template>
25
+ </global>
26
+ <admin>
27
+ <routers>
28
+ <aramexshipment>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Aramex_Shipment</module>
32
+ <frontName>aramexshipment</frontName>
33
+ </args>
34
+ </aramexshipment>
35
+ </routers>
36
+ </admin>
37
+
38
+ <sales>
39
+ <shipping>
40
+ <carriers>
41
+ <aramex>
42
+ <class>Aramex_Shipment_Model_Carrier_Aramex</class>
43
+ </aramex>
44
+ </carriers>
45
+ </shipping>
46
+ </sales>
47
+
48
+ <default>
49
+ <carriers>
50
+ <!-- Use group alias -->
51
+ <aramex>
52
+ <active>1</active>
53
+ <sallowspecific>0</sallowspecific>
54
+ <!--model>shipping/carrier_aramex</model-->
55
+ <!--model>newmodule/carrier_newmodule</model-->
56
+
57
+ <model>Aramex_Shipping_Model_Carrier_Aramex</model>
58
+ <name>aramex</name>
59
+ <gateway_url>wsdl/Tracking.wsdl</gateway_url>
60
+ <price>10.00</price>
61
+ <title>aramex</title>
62
+ <specificerrmsg>
63
+ This shipping method is currently unavailable.If you would like to ship using this shipping method, please contact us.
64
+ </specificerrmsg>
65
+ <handling_type>F</handling_type>
66
+ </aramex>
67
+ </carriers>
68
+ </default>
69
+
70
+ <modules>
71
+ <!-- declare module's version information -->
72
+ <!-- Use module name_Shipping -->
73
+ <Aramex_Shipping>
74
+ <!-- this version number will be used for database upgrades -->
75
+ <version>0.6.0</version>
76
+ <!-- Use module name_Shipping -->
77
+ </Aramex_Shipping>
78
+ </modules>
79
+
80
+ <global>
81
+ <!-- declare model group for new module -->
82
+ <models>
83
+ <!-- model group alias to be used in Mage::getModel() -->
84
+ <!-- Use group alias -->
85
+ <aramex>
86
+ <!-- base class name for the model group -->
87
+ <!-- Use module name_Shipping_Model -->
88
+ <class>Aramex_Shipping_Model</class>
89
+ <!-- Use group alias -->
90
+ </aramex>
91
+ </models>
92
+ <!-- declare resource setup for new module -->
93
+ <resources>
94
+ <!-- resource identifier -->
95
+ <!-- Use group alias_setup -->
96
+ <aramex_setup>
97
+ <!-- specify that this resource is a setup resource and used for upgrades -->
98
+ <setup>
99
+ <!-- which module to look for install/upgrade files in -->
100
+ <!-- Use module name_Shipping_Model -->
101
+ <module>Aramex_Shipping</module>
102
+ </setup>
103
+ <!-- specify database connection for this resource -->
104
+ <connection>
105
+ <!-- do not create new connection, use predefined core setup connection -->
106
+ <use>core_setup</use>
107
+ </connection>
108
+ <!-- Use group alias_setup -->
109
+ </aramex_setup>
110
+ </resources>
111
+ </global>
112
+ </config>
app/code/community/Aramex/Shipping/Model/Carrier/Aramex.php ADDED
@@ -0,0 +1,329 @@
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category Mage
23
+ * @package Mage_Usa
24
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+ class Aramex_Shipping_Model_Carrier_Aramex extends Mage_Usa_Model_Shipping_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface {
28
+
29
+ protected $_code = 'aramex';
30
+ protected $_request = null;
31
+ protected $_result = null;
32
+ protected $_defaultGatewayUrl = null;
33
+
34
+ function __construct()
35
+ {
36
+ $this->_defaultGatewayUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . 'wsdl/Tracking.wsdl';
37
+ }
38
+
39
+ protected function _doShipmentRequest(Varien_Object $request)
40
+ {
41
+ return $result;
42
+ }
43
+
44
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
45
+ {
46
+ if (!$this->getConfigFlag($this->_activeFlag)) {
47
+ return false;
48
+ }
49
+
50
+ $this->setRequest($request);
51
+
52
+ $this->_result = $this->_getQuotes();
53
+
54
+ $this->_updateFreeMethodQuote($request);
55
+
56
+ return $this->getResult();
57
+ }
58
+
59
+ public function setRequest(Mage_Shipping_Model_Rate_Request $request) {
60
+ $this->_request = $request;
61
+
62
+ $r = new Varien_Object();
63
+
64
+ if ($request->getLimitMethod()) {
65
+ $r->setService($request->getLimitMethod());
66
+ } else {
67
+ $r->setService('ALL');
68
+ }
69
+
70
+ if ($request->getAramexUserid()) {
71
+ $userId = $request->getAramexUserid();
72
+ } else {
73
+ $userId = $this->getConfigData('userid');
74
+ }
75
+ $r->setUserId($userId);
76
+
77
+ if ($request->getAramexContainer()) {
78
+ $container = $request->getAramexContainer();
79
+ } else {
80
+ $container = $this->getConfigData('container');
81
+ }
82
+ $r->setContainer($container);
83
+
84
+ if ($request->getAramexSize()) {
85
+ $size = $request->getAramexSize();
86
+ } else {
87
+ $size = $this->getConfigData('size');
88
+ }
89
+ $r->setSize($size);
90
+
91
+ if ($request->getAramexMachinable()) {
92
+ $machinable = $request->getAramexMachinable();
93
+ } else {
94
+ $machinable = $this->getConfigData('machinable');
95
+ }
96
+ $r->setMachinable($machinable);
97
+
98
+ if ($request->getOrigPostcode()) {
99
+ $r->setOrigPostal($request->getOrigPostcode());
100
+ } else {
101
+ $r->setOrigPostal(Mage::getStoreConfig('shipping/origin/postcode'));
102
+ }
103
+
104
+ if ($request->getDestCountryId()) {
105
+ $destCountry = $request->getDestCountryId();
106
+ } else {
107
+ $destCountry = self::USA_COUNTRY_ID;
108
+ }
109
+
110
+ $r->setDestCountryId($destCountry);
111
+
112
+
113
+ $countries = Mage::getResourceModel('directory/country_collection')
114
+ ->addCountryIdFilter($destCountry)
115
+ ->load()
116
+ ->getItems();
117
+ $country = array_shift($countries);
118
+ $countryName = $country->getName();
119
+
120
+ $r->setDestCountryName($countryName);
121
+
122
+ if ($request->getDestPostcode()) {
123
+ $r->setDestPostal($request->getDestPostcode());
124
+ }
125
+
126
+ $weight = $this->getTotalNumOfBoxes($request->getPackageWeight());
127
+ $r->setWeightPounds(floor($weight));
128
+ $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
129
+ if ($request->getFreeMethodWeight() != $request->getPackageWeight()) {
130
+ $r->setFreeMethodWeight($request->getFreeMethodWeight());
131
+ }
132
+
133
+ $r->setValue($request->getPackageValue());
134
+ $r->setValueWithDiscount($request->getPackageValueWithDiscount());
135
+
136
+ $this->_rawRequest = $r;
137
+
138
+ return $this;
139
+ }
140
+
141
+ public function getCode($type, $code='') {
142
+ return false;
143
+ }
144
+
145
+ protected function _getQuotes() {
146
+ return false;
147
+ }
148
+
149
+ public function getResult() {
150
+ return $this->_result;
151
+ }
152
+
153
+ protected function _setFreeMethodRequest($freeMethod) {
154
+ $r = $this->_rawRequest;
155
+
156
+ $weight = $this->getTotalNumOfBoxes($r->getFreeMethodWeight());
157
+ $r->setWeightPounds(floor($weight));
158
+ $r->setWeightOunces(round(($weight - floor($weight)) * 16, 1));
159
+ $r->setService($freeMethod);
160
+ }
161
+
162
+ /**
163
+ * Get allowed shipping methods
164
+ *
165
+ * @return array
166
+ */
167
+ public function getAllowedMethods()
168
+ {
169
+ $allowed = explode(',', $this->getConfigData('allowed_methods'));
170
+ $arr = array();
171
+ foreach ($allowed as $k) {
172
+ $arr[$k] = $this->getCode('method', $k);
173
+ }
174
+ return $arr;
175
+ }
176
+
177
+ /**
178
+ * Return array of authenticated information
179
+ *
180
+ * @return array
181
+ */
182
+ protected function _getAuthDetails()
183
+ {
184
+ return array(
185
+ 'ClientInfo' => array(
186
+ 'AccountCountryCode' => Mage::getStoreConfig('aramexsettings/settings/account_country_code'),
187
+ 'AccountEntity' => Mage::getStoreConfig('aramexsettings/settings/account_entity'),
188
+ 'AccountNumber' => Mage::getStoreConfig('aramexsettings/settings/account_number'),
189
+ 'AccountPin' => Mage::getStoreConfig('aramexsettings/settings/account_pin'),
190
+ 'UserName' => Mage::getStoreConfig('aramexsettings/settings/user_name'),
191
+ 'Password' => Mage::getStoreConfig('aramexsettings/settings/password'),
192
+ 'Version' => 'v1.0'
193
+ )
194
+ );
195
+ }
196
+
197
+ public function getTracking($trackings) {
198
+ $this->setTrackingReqeust();
199
+
200
+ if (!is_array($trackings)) {
201
+ $trackings = array($trackings);
202
+ }
203
+
204
+ $this->_getXmlTracking($trackings);
205
+
206
+ return $this->_result;
207
+ }
208
+
209
+ protected function setTrackingReqeust() {
210
+ $r = new Varien_Object();
211
+
212
+ $userId = $this->getConfigData('userid');
213
+ $r->setUserId($userId);
214
+
215
+ $this->_rawTrackRequest = $r;
216
+ }
217
+
218
+ protected function _getXmlTracking($trackings) {
219
+ $r = $this->_rawTrackRequest;
220
+
221
+ foreach ($trackings as $tracking) {
222
+ $this->_parseXmlTrackingResponse($tracking);
223
+ }
224
+ }
225
+
226
+ protected function _parseXmlTrackingResponse($trackingvalue) {
227
+ $resultArr = array();
228
+
229
+ if (!$this->_result) {
230
+ $this->_result = Mage::getModel('shipping/tracking_result');
231
+ }
232
+ $defaults = $this->getDefaults();
233
+
234
+ //$url = 'http://localhost:8080/soap_test/wsdl/Tracking.wsdl';
235
+ //if (!$url) {
236
+ $url = $this->_defaultGatewayUrl;
237
+ //}
238
+
239
+ $clientAramex = new SoapClient($url);
240
+ $aramexParams = $this->_getAuthDetails();
241
+
242
+ $aramexParams['Transaction'] = array('Reference1' => '001' );
243
+ $aramexParams['Shipments'] = array($trackingvalue);
244
+
245
+ $_resAramex = $clientAramex->TrackShipments($aramexParams);
246
+
247
+ if(is_object($_resAramex) && !$_resAramex->HasErrors){
248
+ $tracking = Mage::getModel('shipping/tracking_result_status');
249
+ $tracking->setCarrier('aramex');
250
+ $tracking->setCarrierTitle($this->getConfigData('title'));
251
+ $tracking->setTracking($trackingvalue);
252
+ if(!empty($_resAramex->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult)){
253
+ $tracking->setTrackSummary($this->getTrackingInfoTable($_resAramex->TrackingResults->KeyValueOfstringArrayOfTrackingResultmFAkxlpY->Value->TrackingResult));
254
+ } else {
255
+ $tracking->setTrackSummary('Unable to retrieve quotes, please check if the Tracking Number is valid or contact your administrator.');
256
+ }
257
+ $this->_result->append($tracking);
258
+ } else {
259
+ $errorMessage = '';
260
+ foreach($_resAramex->Notifications as $notification){
261
+ $errorMessage .= '<b>' . $notification->Code . '</b>' . $notification->Message;
262
+ }
263
+ $error = Mage::getModel('shipping/tracking_result_error');
264
+ $error->setCarrier('aramex');
265
+ $error->setCarrierTitle($this->getConfigData('title'));
266
+ $error->setTracking($trackingvalue);
267
+ $error->setErrorMessage($errorMessage);
268
+ $this->_result->append($error);
269
+ }
270
+ }
271
+
272
+ public function getResponse() {
273
+ $statuses = '';
274
+ if ($this->_result instanceof Mage_Shipping_Model_Tracking_Result) {
275
+ if ($trackings = $this->_result->getAllTrackings()) {
276
+ foreach ($trackings as $tracking) {
277
+ if ($data = $tracking->getAllData()) {
278
+ if (!empty($data['track_summary'])) {
279
+ $statuses .= Mage::helper('usa')->__($data['track_summary']);
280
+ } else {
281
+ $statuses .= Mage::helper('usa')->__('Empty response');
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ if (empty($statuses)) {
288
+ $statuses = Mage::helper('usa')->__('Empty response');
289
+ }
290
+ return $statuses;
291
+ }
292
+
293
+ /**
294
+ * Get allowed shipping methods
295
+ *
296
+ * @return array
297
+ */
298
+ public function getTrackingInfoTable($HAWBHistory) {
299
+
300
+ $_resultTable = '<table summary="Item Tracking" class="data-table">';
301
+ $_resultTable .= '<col width="1">
302
+ <col width="1">
303
+ <col width="1">
304
+ <col width="1">
305
+ <thead>
306
+ <tr class="first last">
307
+ <th>Location</th>
308
+ <th>Action Date/Time</th>
309
+ <th class="a-right">Tracking Description</th>
310
+ <th class="a-center">Comments</th>
311
+ </tr>
312
+ </thead><tbody>';
313
+
314
+ foreach ($HAWBHistory as $HAWBUpdate) {
315
+
316
+ $_resultTable .= '<tr>
317
+ <td>' . $HAWBUpdate->UpdateLocation . '</td>
318
+ <td>' . $HAWBUpdate->UpdateDateTime . '</td>
319
+ <td>' . $HAWBUpdate->UpdateDescription . '</td>
320
+ <td>' . $HAWBUpdate->Comments . '</td>
321
+ </tr>';
322
+ }
323
+ $_resultTable .= '</tbody></table>';
324
+
325
+ return $_resultTable;
326
+ }
327
+ }
328
+
329
+ ?>
app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Dropoff.php ADDED
@@ -0,0 +1,39 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Dropoff
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $fedex = Mage::getSingleton('Aramex_Shipping_Model_Carrier_Aramex');
33
+ $arr = array();
34
+ foreach ($fedex->getCode('dropoff') as $k=>$v) {
35
+ $arr[] = array('value'=>$k, 'label'=>$v);
36
+ }
37
+ return $arr;
38
+ }
39
+ }
app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Freemethod.php ADDED
@@ -0,0 +1,36 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Freemethod extends Aramex_Shipping_Model_Carrier_Aramex_Source_Method
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $arr = parent::toOptionArray();
33
+ array_unshift($arr, array('value'=>'', 'label'=>Mage::helper('shipping')->__('None')));
34
+ return $arr;
35
+ }
36
+ }
app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Method.php ADDED
@@ -0,0 +1,39 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.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.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Usa
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Aramex_Shipping_Model_Carrier_Aramex_Source_Method
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ $fedex = Mage::getSingleton('Aramex_Shipping_Model_Carrier_Aramex');
33
+ $arr = array();
34
+ foreach ($fedex->getCode('method') as $k=>$v) {
35
+ $arr[] = array('value'=>$k, 'label'=>$v);
36
+ }
37
+ return $arr;
38
+ }
39
+ }
app/code/community/Aramex/Shipping/Model/Carrier/Aramex/Source/Packaging.php ADDED
@@ -0,0 +1,39 @@